12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130 |
- #pragma once
- #include "rect.h"
- #include "SColor.h"
- #include "IImage.h"
- #include "ITexture.h"
- #include "irrArray.h"
- #include "matrix4.h"
- #include "dimension2d.h"
- #include "position2d.h"
- #include "EDriverTypes.h"
- #include "EDriverFeatures.h"
- #include "EPrimitiveTypes.h"
- #include "EVideoTypes.h"
- #include "SExposedVideoData.h"
- #include "SOverrideMaterial.h"
- #include "S3DVertex.h"
- #include "SVertexIndex.h"
- namespace irr
- {
- namespace io
- {
- class IAttributes;
- class IReadFile;
- class IWriteFile;
- }
- namespace scene
- {
- class IMeshBuffer;
- class IVertexBuffer;
- class IIndexBuffer;
- class IMesh;
- class IMeshManipulator;
- class ISceneNode;
- }
- namespace video
- {
- class IImageLoader;
- class IImageWriter;
- class IMaterialRenderer;
- class IGPUProgrammingServices;
- class IRenderTarget;
- const c8 *const FogTypeNames[] = {
- "FogExp",
- "FogLinear",
- "FogExp2",
- 0,
- };
- struct SFrameStats {
-
- u32 Drawcalls = 0;
-
- u32 PrimitivesDrawn = 0;
-
- u32 HWBuffersUploaded = 0;
-
- u32 HWBuffersUploadedSize = 0;
- };
- class IVideoDriver : public virtual IReferenceCounted
- {
- public:
-
-
- virtual bool beginScene(u16 clearFlag = (u16)(ECBF_COLOR | ECBF_DEPTH), SColor clearColor = SColor(255, 0, 0, 0), f32 clearDepth = 1.f, u8 clearStencil = 0,
- const SExposedVideoData &videoData = SExposedVideoData(), core::rect<s32> *sourceRect = 0) = 0;
-
- bool beginScene(bool backBuffer, bool zBuffer, SColor color = SColor(255, 0, 0, 0),
- const SExposedVideoData &videoData = SExposedVideoData(), core::rect<s32> *sourceRect = 0)
- {
- u16 flag = 0;
- if (backBuffer)
- flag |= ECBF_COLOR;
- if (zBuffer)
- flag |= ECBF_DEPTH;
- return beginScene(flag, color, 1.f, 0, videoData, sourceRect);
- }
-
-
- virtual bool endScene() = 0;
-
-
- virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const = 0;
-
-
- virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag = true) = 0;
-
-
- virtual const io::IAttributes &getDriverAttributes() const = 0;
-
-
- virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4 &mat) = 0;
-
-
- virtual const core::matrix4 &getTransform(E_TRANSFORMATION_STATE state) const = 0;
-
-
- virtual u32 getImageLoaderCount() const = 0;
-
-
- virtual IImageLoader *getImageLoader(u32 n) = 0;
-
-
- virtual u32 getImageWriterCount() const = 0;
-
-
- virtual IImageWriter *getImageWriter(u32 n) = 0;
-
-
- virtual void setMaterial(const SMaterial &material) = 0;
-
-
- virtual ITexture *getTexture(const io::path &filename) = 0;
-
-
- virtual ITexture *getTexture(io::IReadFile *file) = 0;
-
-
- virtual u32 getTextureCount() const = 0;
-
-
- virtual ITexture *addTexture(const core::dimension2d<u32> &size,
- const io::path &name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0;
-
-
- virtual ITexture *addTexture(const io::path &name, IImage *image) = 0;
-
-
- virtual ITexture *addTextureCubemap(const io::path &name, IImage *imagePosX, IImage *imageNegX, IImage *imagePosY,
- IImage *imageNegY, IImage *imagePosZ, IImage *imageNegZ) = 0;
-
-
- virtual ITexture *addTextureCubemap(const irr::u32 sideLen, const io::path &name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0;
-
-
- virtual ITexture *addRenderTargetTexture(const core::dimension2d<u32> &size,
- const io::path &name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) = 0;
-
-
- virtual ITexture *addRenderTargetTextureMs(const core::dimension2d<u32> &size, u8 msaa,
- const io::path &name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) = 0;
-
-
- virtual ITexture *addRenderTargetTextureCubemap(const irr::u32 sideLen,
- const io::path &name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) = 0;
-
-
- virtual void removeTexture(ITexture *texture) = 0;
-
-
- virtual void removeAllTextures() = 0;
-
- virtual void removeHardwareBuffer(const scene::IVertexBuffer *vb) = 0;
-
- virtual void removeHardwareBuffer(const scene::IIndexBuffer *ib) = 0;
-
- virtual void removeAllHardwareBuffers() = 0;
-
-
- virtual void addOcclusionQuery(scene::ISceneNode *node,
- const scene::IMesh *mesh = 0) = 0;
-
- virtual void removeOcclusionQuery(scene::ISceneNode *node) = 0;
-
- virtual void removeAllOcclusionQueries() = 0;
-
-
- virtual void runOcclusionQuery(scene::ISceneNode *node, bool visible = false) = 0;
-
-
- virtual void runAllOcclusionQueries(bool visible = false) = 0;
-
-
- virtual void updateOcclusionQuery(scene::ISceneNode *node, bool block = true) = 0;
-
-
- virtual void updateAllOcclusionQueries(bool block = true) = 0;
-
-
- virtual u32 getOcclusionQueryResult(scene::ISceneNode *node) const = 0;
-
- virtual IRenderTarget *addRenderTarget() = 0;
-
- virtual void removeRenderTarget(IRenderTarget *renderTarget) = 0;
-
- virtual void removeAllRenderTargets() = 0;
-
-
- virtual void blitRenderTarget(IRenderTarget *from, IRenderTarget *to) = 0;
-
-
- virtual void makeColorKeyTexture(video::ITexture *texture,
- video::SColor color) const = 0;
-
-
- virtual void makeColorKeyTexture(video::ITexture *texture,
- core::position2d<s32> colorKeyPixelPos) const = 0;
-
-
- virtual bool setRenderTargetEx(IRenderTarget *target, u16 clearFlag, SColor clearColor = SColor(255, 0, 0, 0),
- f32 clearDepth = 1.f, u8 clearStencil = 0) = 0;
-
-
- virtual bool setRenderTarget(ITexture *texture, u16 clearFlag = ECBF_COLOR | ECBF_DEPTH, SColor clearColor = SColor(255, 0, 0, 0),
- f32 clearDepth = 1.f, u8 clearStencil = 0) = 0;
-
-
-
- bool setRenderTarget(ITexture *texture, bool clearBackBuffer, bool clearZBuffer, SColor color = SColor(255, 0, 0, 0))
- {
- u16 flag = 0;
- if (clearBackBuffer)
- flag |= ECBF_COLOR;
- if (clearZBuffer)
- flag |= ECBF_DEPTH;
- return setRenderTarget(texture, flag, color);
- }
-
-
- virtual void setViewPort(const core::rect<s32> &area) = 0;
-
-
- virtual const core::rect<s32> &getViewPort() const = 0;
-
-
- virtual void drawVertexPrimitiveList(const void *vertices, u32 vertexCount,
- const void *indexList, u32 primCount,
- E_VERTEX_TYPE vType = EVT_STANDARD,
- scene::E_PRIMITIVE_TYPE pType = scene::EPT_TRIANGLES,
- E_INDEX_TYPE iType = EIT_16BIT) = 0;
-
-
- virtual void draw2DVertexPrimitiveList(const void *vertices, u32 vertexCount,
- const void *indexList, u32 primCount,
- E_VERTEX_TYPE vType = EVT_STANDARD,
- scene::E_PRIMITIVE_TYPE pType = scene::EPT_TRIANGLES,
- E_INDEX_TYPE iType = EIT_16BIT) = 0;
-
-
- void drawIndexedTriangleList(const S3DVertex *vertices,
- u32 vertexCount, const u16 *indexList, u32 triangleCount)
- {
- drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT);
- }
-
-
- void drawIndexedTriangleList(const S3DVertex2TCoords *vertices,
- u32 vertexCount, const u16 *indexList, u32 triangleCount)
- {
- drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES, EIT_16BIT);
- }
-
-
- void drawIndexedTriangleList(const S3DVertexTangents *vertices,
- u32 vertexCount, const u16 *indexList, u32 triangleCount)
- {
- drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES, EIT_16BIT);
- }
-
-
- void drawIndexedTriangleFan(const S3DVertex *vertices,
- u32 vertexCount, const u16 *indexList, u32 triangleCount)
- {
- drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
- }
-
-
- void drawIndexedTriangleFan(const S3DVertex2TCoords *vertices,
- u32 vertexCount, const u16 *indexList, u32 triangleCount)
- {
- drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
- }
-
-
- void drawIndexedTriangleFan(const S3DVertexTangents *vertices,
- u32 vertexCount, const u16 *indexList, u32 triangleCount)
- {
- drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
- }
-
-
- virtual void draw3DLine(const core::vector3df &start,
- const core::vector3df &end, SColor color = SColor(255, 255, 255, 255)) = 0;
-
-
- virtual void draw3DBox(const core::aabbox3d<f32> &box,
- SColor color = SColor(255, 255, 255, 255)) = 0;
-
-
- virtual void draw2DImage(const video::ITexture *texture,
- const core::position2d<s32> &destPos, bool useAlphaChannelOfTexture = false) = 0;
-
-
- virtual void draw2DImage(const video::ITexture *texture, const core::position2d<s32> &destPos,
- const core::rect<s32> &sourceRect, const core::rect<s32> *clipRect = 0,
- SColor color = SColor(255, 255, 255, 255), bool useAlphaChannelOfTexture = false) = 0;
-
-
- virtual void draw2DImageBatch(const video::ITexture *texture,
- const core::array<core::position2d<s32>> &positions,
- const core::array<core::rect<s32>> &sourceRects,
- const core::rect<s32> *clipRect = 0,
- SColor color = SColor(255, 255, 255, 255),
- bool useAlphaChannelOfTexture = false) = 0;
-
-
- virtual void draw2DImage(const video::ITexture *texture, const core::rect<s32> &destRect,
- const core::rect<s32> &sourceRect, const core::rect<s32> *clipRect = 0,
- const video::SColor *const colors = 0, bool useAlphaChannelOfTexture = false) = 0;
-
-
- virtual void draw2DRectangle(SColor color, const core::rect<s32> &pos,
- const core::rect<s32> *clip = 0) = 0;
-
-
- virtual void draw2DRectangle(const core::rect<s32> &pos,
- SColor colorLeftUp, SColor colorRightUp,
- SColor colorLeftDown, SColor colorRightDown,
- const core::rect<s32> *clip = 0) = 0;
-
-
- virtual void draw2DLine(const core::position2d<s32> &start,
- const core::position2d<s32> &end,
- SColor color = SColor(255, 255, 255, 255)) = 0;
-
-
- virtual void drawMeshBuffer(const scene::IMeshBuffer *mb) = 0;
-
- virtual void drawBuffers(const scene::IVertexBuffer *vb,
- const scene::IIndexBuffer *ib, u32 primCount,
- scene::E_PRIMITIVE_TYPE pType = scene::EPT_TRIANGLES) = 0;
-
-
- virtual void drawMeshBufferNormals(const scene::IMeshBuffer *mb, f32 length = 10.f, SColor color = 0xffffffff) = 0;
-
-
- virtual void setFog(SColor color = SColor(0, 255, 255, 255),
- E_FOG_TYPE fogType = EFT_FOG_LINEAR,
- f32 start = 50.0f, f32 end = 100.0f, f32 density = 0.01f,
- bool pixelFog = false, bool rangeFog = false) = 0;
-
- virtual void getFog(SColor &color, E_FOG_TYPE &fogType,
- f32 &start, f32 &end, f32 &density,
- bool &pixelFog, bool &rangeFog) = 0;
-
-
- virtual ECOLOR_FORMAT getColorFormat() const = 0;
-
-
- virtual const core::dimension2d<u32> &getScreenSize() const = 0;
-
-
- virtual const core::dimension2d<u32> &getCurrentRenderTargetSize() const = 0;
-
-
- virtual s32 getFPS() const = 0;
-
- virtual SFrameStats getFrameStats() const = 0;
-
-
- virtual const char *getName() const = 0;
-
-
- virtual void addExternalImageLoader(IImageLoader *loader) = 0;
-
-
- virtual void addExternalImageWriter(IImageWriter *writer) = 0;
-
-
- virtual u32 getMaximalPrimitiveCount() const = 0;
-
-
- virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled = true) = 0;
-
-
- virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const = 0;
-
-
- virtual IImage *createImageFromFile(const io::path &filename) = 0;
-
-
- virtual IImage *createImageFromFile(io::IReadFile *file) = 0;
-
-
- virtual bool writeImageToFile(IImage *image, const io::path &filename, u32 param = 0) = 0;
-
-
- virtual bool writeImageToFile(IImage *image, io::IWriteFile *file, u32 param = 0) = 0;
-
-
- virtual IImage *createImageFromData(ECOLOR_FORMAT format,
- const core::dimension2d<u32> &size, void *data, bool ownForeignMemory = false,
- bool deleteMemory = true) = 0;
-
-
- virtual IImage *createImage(ECOLOR_FORMAT format, const core::dimension2d<u32> &size) = 0;
-
-
- virtual IImage *createImage(ITexture *texture,
- const core::position2d<s32> &pos,
- const core::dimension2d<u32> &size) = 0;
-
-
- virtual void OnResize(const core::dimension2d<u32> &size) = 0;
-
-
- virtual s32 addMaterialRenderer(IMaterialRenderer *renderer, const c8 *name = 0) = 0;
-
-
- virtual IMaterialRenderer *getMaterialRenderer(u32 idx) const = 0;
-
-
- virtual u32 getMaterialRendererCount() const = 0;
-
-
- virtual const c8 *getMaterialRendererName(u32 idx) const = 0;
-
-
- virtual void setMaterialRendererName(u32 idx, const c8 *name) = 0;
-
-
- virtual void swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames = true) = 0;
-
-
- virtual const SExposedVideoData &getExposedVideoData() = 0;
-
-
- virtual E_DRIVER_TYPE getDriverType() const = 0;
-
-
- virtual IGPUProgrammingServices *getGPUProgrammingServices() = 0;
-
- virtual scene::IMeshManipulator *getMeshManipulator() = 0;
-
- virtual void clearBuffers(u16 flag, SColor color = SColor(255, 0, 0, 0), f32 depth = 1.f, u8 stencil = 0) = 0;
-
-
- void clearZBuffer()
- {
- clearBuffers(ECBF_DEPTH, SColor(255, 0, 0, 0), 1.f, 0);
- }
-
-
- virtual IImage *createScreenShot(video::ECOLOR_FORMAT format = video::ECF_UNKNOWN, video::E_RENDER_TARGET target = video::ERT_FRAME_BUFFER) = 0;
-
-
- virtual video::ITexture *findTexture(const io::path &filename) = 0;
-
-
- virtual void setMinHardwareBufferVertexCount(u32 count) = 0;
-
-
- virtual SOverrideMaterial &getOverrideMaterial() = 0;
-
-
- virtual SMaterial &getMaterial2D() = 0;
-
-
- virtual void enableMaterial2D(bool enable = true) = 0;
-
- virtual core::stringc getVendorInfo() = 0;
-
-
- virtual void setAllowZWriteOnTransparent(bool flag) = 0;
-
- virtual core::dimension2du getMaxTextureSize() const = 0;
-
-
- virtual bool queryTextureFormat(ECOLOR_FORMAT format) const = 0;
-
- virtual bool needsTransparentRenderPass(const irr::video::SMaterial &material) const = 0;
- };
- }
- }
|