diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CD3D9Driver.h')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CD3D9Driver.h | 992 |
1 files changed, 496 insertions, 496 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CD3D9Driver.h b/libraries/irrlicht-1.8/source/Irrlicht/CD3D9Driver.h index 095ae9d..a4aca91 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CD3D9Driver.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/CD3D9Driver.h | |||
@@ -1,496 +1,496 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #ifndef __C_VIDEO_DIRECTX_9_H_INCLUDED__ | 5 | #ifndef __C_VIDEO_DIRECTX_9_H_INCLUDED__ |
6 | #define __C_VIDEO_DIRECTX_9_H_INCLUDED__ | 6 | #define __C_VIDEO_DIRECTX_9_H_INCLUDED__ |
7 | 7 | ||
8 | #include "IrrCompileConfig.h" | 8 | #include "IrrCompileConfig.h" |
9 | 9 | ||
10 | #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ | 10 | #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ |
11 | 11 | ||
12 | #ifdef _IRR_WINDOWS_ | 12 | #ifdef _IRR_WINDOWS_ |
13 | #define WIN32_LEAN_AND_MEAN | 13 | #define WIN32_LEAN_AND_MEAN |
14 | #include <windows.h> | 14 | #include <windows.h> |
15 | #endif | 15 | #endif |
16 | 16 | ||
17 | #include "CNullDriver.h" | 17 | #include "CNullDriver.h" |
18 | #include "SIrrCreationParameters.h" | 18 | #include "SIrrCreationParameters.h" |
19 | #include "IMaterialRendererServices.h" | 19 | #include "IMaterialRendererServices.h" |
20 | #if defined(__BORLANDC__) || defined (__BCPLUSPLUS__) | 20 | #if defined(__BORLANDC__) || defined (__BCPLUSPLUS__) |
21 | #include "irrMath.h" // needed by borland for sqrtf define | 21 | #include "irrMath.h" // needed by borland for sqrtf define |
22 | #endif | 22 | #endif |
23 | #include <d3d9.h> | 23 | #include <d3d9.h> |
24 | 24 | ||
25 | #ifdef _IRR_COMPILE_WITH_CG_ | 25 | #ifdef _IRR_COMPILE_WITH_CG_ |
26 | #include "Cg/cg.h" | 26 | #include "Cg/cg.h" |
27 | #include "Cg/cgD3D9.h" | 27 | #include "Cg/cgD3D9.h" |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | namespace irr | 30 | namespace irr |
31 | { | 31 | { |
32 | namespace video | 32 | namespace video |
33 | { | 33 | { |
34 | struct SDepthSurface : public IReferenceCounted | 34 | struct SDepthSurface : public IReferenceCounted |
35 | { | 35 | { |
36 | SDepthSurface() : Surface(0) | 36 | SDepthSurface() : Surface(0) |
37 | { | 37 | { |
38 | #ifdef _DEBUG | 38 | #ifdef _DEBUG |
39 | setDebugName("SDepthSurface"); | 39 | setDebugName("SDepthSurface"); |
40 | #endif | 40 | #endif |
41 | } | 41 | } |
42 | virtual ~SDepthSurface() | 42 | virtual ~SDepthSurface() |
43 | { | 43 | { |
44 | if (Surface) | 44 | if (Surface) |
45 | Surface->Release(); | 45 | Surface->Release(); |
46 | } | 46 | } |
47 | 47 | ||
48 | IDirect3DSurface9* Surface; | 48 | IDirect3DSurface9* Surface; |
49 | core::dimension2du Size; | 49 | core::dimension2du Size; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | class CD3D9Driver : public CNullDriver, IMaterialRendererServices | 52 | class CD3D9Driver : public CNullDriver, IMaterialRendererServices |
53 | { | 53 | { |
54 | public: | 54 | public: |
55 | 55 | ||
56 | friend class CD3D9Texture; | 56 | friend class CD3D9Texture; |
57 | 57 | ||
58 | //! constructor | 58 | //! constructor |
59 | CD3D9Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io); | 59 | CD3D9Driver(const SIrrlichtCreationParameters& params, io::IFileSystem* io); |
60 | 60 | ||
61 | //! destructor | 61 | //! destructor |
62 | virtual ~CD3D9Driver(); | 62 | virtual ~CD3D9Driver(); |
63 | 63 | ||
64 | //! applications must call this method before performing any rendering. returns false if failed. | 64 | //! applications must call this method before performing any rendering. returns false if failed. |
65 | virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, | 65 | virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, |
66 | SColor color=SColor(255,0,0,0), | 66 | SColor color=SColor(255,0,0,0), |
67 | const SExposedVideoData& videoData=SExposedVideoData(), | 67 | const SExposedVideoData& videoData=SExposedVideoData(), |
68 | core::rect<s32>* sourceRect=0); | 68 | core::rect<s32>* sourceRect=0); |
69 | 69 | ||
70 | //! applications must call this method after performing any rendering. returns false if failed. | 70 | //! applications must call this method after performing any rendering. returns false if failed. |
71 | virtual bool endScene(); | 71 | virtual bool endScene(); |
72 | 72 | ||
73 | //! queries the features of the driver, returns true if feature is available | 73 | //! queries the features of the driver, returns true if feature is available |
74 | virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; | 74 | virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; |
75 | 75 | ||
76 | //! sets transformation | 76 | //! sets transformation |
77 | virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); | 77 | virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); |
78 | 78 | ||
79 | //! sets a material | 79 | //! sets a material |
80 | virtual void setMaterial(const SMaterial& material); | 80 | virtual void setMaterial(const SMaterial& material); |
81 | 81 | ||
82 | //! sets a render target | 82 | //! sets a render target |
83 | virtual bool setRenderTarget(video::ITexture* texture, | 83 | virtual bool setRenderTarget(video::ITexture* texture, |
84 | bool clearBackBuffer=true, bool clearZBuffer=true, | 84 | bool clearBackBuffer=true, bool clearZBuffer=true, |
85 | SColor color=video::SColor(0,0,0,0)); | 85 | SColor color=video::SColor(0,0,0,0)); |
86 | 86 | ||
87 | //! Sets multiple render targets | 87 | //! Sets multiple render targets |
88 | virtual bool setRenderTarget(const core::array<video::IRenderTarget>& texture, | 88 | virtual bool setRenderTarget(const core::array<video::IRenderTarget>& texture, |
89 | bool clearBackBuffer=true, bool clearZBuffer=true, | 89 | bool clearBackBuffer=true, bool clearZBuffer=true, |
90 | SColor color=video::SColor(0,0,0,0)); | 90 | SColor color=video::SColor(0,0,0,0)); |
91 | 91 | ||
92 | //! sets a viewport | 92 | //! sets a viewport |
93 | virtual void setViewPort(const core::rect<s32>& area); | 93 | virtual void setViewPort(const core::rect<s32>& area); |
94 | 94 | ||
95 | //! gets the area of the current viewport | 95 | //! gets the area of the current viewport |
96 | virtual const core::rect<s32>& getViewPort() const; | 96 | virtual const core::rect<s32>& getViewPort() const; |
97 | 97 | ||
98 | struct SHWBufferLink_d3d9 : public SHWBufferLink | 98 | struct SHWBufferLink_d3d9 : public SHWBufferLink |
99 | { | 99 | { |
100 | SHWBufferLink_d3d9(const scene::IMeshBuffer *_MeshBuffer): | 100 | SHWBufferLink_d3d9(const scene::IMeshBuffer *_MeshBuffer): |
101 | SHWBufferLink(_MeshBuffer), | 101 | SHWBufferLink(_MeshBuffer), |
102 | vertexBuffer(0), indexBuffer(0), | 102 | vertexBuffer(0), indexBuffer(0), |
103 | vertexBufferSize(0), indexBufferSize(0) {} | 103 | vertexBufferSize(0), indexBufferSize(0) {} |
104 | 104 | ||
105 | IDirect3DVertexBuffer9* vertexBuffer; | 105 | IDirect3DVertexBuffer9* vertexBuffer; |
106 | IDirect3DIndexBuffer9* indexBuffer; | 106 | IDirect3DIndexBuffer9* indexBuffer; |
107 | 107 | ||
108 | u32 vertexBufferSize; | 108 | u32 vertexBufferSize; |
109 | u32 indexBufferSize; | 109 | u32 indexBufferSize; |
110 | }; | 110 | }; |
111 | 111 | ||
112 | bool updateVertexHardwareBuffer(SHWBufferLink_d3d9 *HWBuffer); | 112 | bool updateVertexHardwareBuffer(SHWBufferLink_d3d9 *HWBuffer); |
113 | bool updateIndexHardwareBuffer(SHWBufferLink_d3d9 *HWBuffer); | 113 | bool updateIndexHardwareBuffer(SHWBufferLink_d3d9 *HWBuffer); |
114 | 114 | ||
115 | //! updates hardware buffer if needed | 115 | //! updates hardware buffer if needed |
116 | virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer); | 116 | virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer); |
117 | 117 | ||
118 | //! Create hardware buffer from mesh | 118 | //! Create hardware buffer from mesh |
119 | virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb); | 119 | virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb); |
120 | 120 | ||
121 | //! Delete hardware buffer (only some drivers can) | 121 | //! Delete hardware buffer (only some drivers can) |
122 | virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer); | 122 | virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer); |
123 | 123 | ||
124 | //! Draw hardware buffer | 124 | //! Draw hardware buffer |
125 | virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer); | 125 | virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer); |
126 | 126 | ||
127 | //! Create occlusion query. | 127 | //! Create occlusion query. |
128 | /** Use node for identification and mesh for occlusion test. */ | 128 | /** Use node for identification and mesh for occlusion test. */ |
129 | virtual void addOcclusionQuery(scene::ISceneNode* node, | 129 | virtual void addOcclusionQuery(scene::ISceneNode* node, |
130 | const scene::IMesh* mesh=0); | 130 | const scene::IMesh* mesh=0); |
131 | 131 | ||
132 | //! Remove occlusion query. | 132 | //! Remove occlusion query. |
133 | virtual void removeOcclusionQuery(scene::ISceneNode* node); | 133 | virtual void removeOcclusionQuery(scene::ISceneNode* node); |
134 | 134 | ||
135 | //! Run occlusion query. Draws mesh stored in query. | 135 | //! Run occlusion query. Draws mesh stored in query. |
136 | /** If the mesh shall not be rendered visible, use | 136 | /** If the mesh shall not be rendered visible, use |
137 | overrideMaterial to disable the color and depth buffer. */ | 137 | overrideMaterial to disable the color and depth buffer. */ |
138 | virtual void runOcclusionQuery(scene::ISceneNode* node, bool visible=false); | 138 | virtual void runOcclusionQuery(scene::ISceneNode* node, bool visible=false); |
139 | 139 | ||
140 | //! Update occlusion query. Retrieves results from GPU. | 140 | //! Update occlusion query. Retrieves results from GPU. |
141 | /** If the query shall not block, set the flag to false. | 141 | /** If the query shall not block, set the flag to false. |
142 | Update might not occur in this case, though */ | 142 | Update might not occur in this case, though */ |
143 | virtual void updateOcclusionQuery(scene::ISceneNode* node, bool block=true); | 143 | virtual void updateOcclusionQuery(scene::ISceneNode* node, bool block=true); |
144 | 144 | ||
145 | //! Return query result. | 145 | //! Return query result. |
146 | /** Return value is the number of visible pixels/fragments. | 146 | /** Return value is the number of visible pixels/fragments. |
147 | The value is a safe approximation, i.e. can be larger then the | 147 | The value is a safe approximation, i.e. can be larger then the |
148 | actual value of pixels. */ | 148 | actual value of pixels. */ |
149 | virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const; | 149 | virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const; |
150 | 150 | ||
151 | //! draws a vertex primitive list | 151 | //! draws a vertex primitive list |
152 | virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, | 152 | virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, |
153 | const void* indexList, u32 primitiveCount, | 153 | const void* indexList, u32 primitiveCount, |
154 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, | 154 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, |
155 | E_INDEX_TYPE iType); | 155 | E_INDEX_TYPE iType); |
156 | 156 | ||
157 | //! draws a vertex primitive list in 2d | 157 | //! draws a vertex primitive list in 2d |
158 | virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, | 158 | virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, |
159 | const void* indexList, u32 primitiveCount, | 159 | const void* indexList, u32 primitiveCount, |
160 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, | 160 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, |
161 | E_INDEX_TYPE iType); | 161 | E_INDEX_TYPE iType); |
162 | 162 | ||
163 | //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. | 163 | //! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted. |
164 | virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, | 164 | virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, |
165 | const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, | 165 | const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, |
166 | SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); | 166 | SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); |
167 | 167 | ||
168 | //! Draws a part of the texture into the rectangle. | 168 | //! Draws a part of the texture into the rectangle. |
169 | virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, | 169 | virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, |
170 | const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, | 170 | const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, |
171 | const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); | 171 | const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); |
172 | 172 | ||
173 | //! Draws a set of 2d images, using a color and the alpha channel of the texture. | 173 | //! Draws a set of 2d images, using a color and the alpha channel of the texture. |
174 | virtual void draw2DImageBatch(const video::ITexture* texture, | 174 | virtual void draw2DImageBatch(const video::ITexture* texture, |
175 | const core::array<core::position2d<s32> >& positions, | 175 | const core::array<core::position2d<s32> >& positions, |
176 | const core::array<core::rect<s32> >& sourceRects, | 176 | const core::array<core::rect<s32> >& sourceRects, |
177 | const core::rect<s32>* clipRect=0, | 177 | const core::rect<s32>* clipRect=0, |
178 | SColor color=SColor(255,255,255,255), | 178 | SColor color=SColor(255,255,255,255), |
179 | bool useAlphaChannelOfTexture=false); | 179 | bool useAlphaChannelOfTexture=false); |
180 | 180 | ||
181 | //!Draws an 2d rectangle with a gradient. | 181 | //!Draws an 2d rectangle with a gradient. |
182 | virtual void draw2DRectangle(const core::rect<s32>& pos, | 182 | virtual void draw2DRectangle(const core::rect<s32>& pos, |
183 | SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, | 183 | SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, |
184 | const core::rect<s32>* clip); | 184 | const core::rect<s32>* clip); |
185 | 185 | ||
186 | //! Draws a 2d line. | 186 | //! Draws a 2d line. |
187 | virtual void draw2DLine(const core::position2d<s32>& start, | 187 | virtual void draw2DLine(const core::position2d<s32>& start, |
188 | const core::position2d<s32>& end, | 188 | const core::position2d<s32>& end, |
189 | SColor color=SColor(255,255,255,255)); | 189 | SColor color=SColor(255,255,255,255)); |
190 | 190 | ||
191 | //! Draws a pixel. | 191 | //! Draws a pixel. |
192 | virtual void drawPixel(u32 x, u32 y, const SColor & color); | 192 | virtual void drawPixel(u32 x, u32 y, const SColor & color); |
193 | 193 | ||
194 | //! Draws a 3d line. | 194 | //! Draws a 3d line. |
195 | virtual void draw3DLine(const core::vector3df& start, | 195 | virtual void draw3DLine(const core::vector3df& start, |
196 | const core::vector3df& end, SColor color = SColor(255,255,255,255)); | 196 | const core::vector3df& end, SColor color = SColor(255,255,255,255)); |
197 | 197 | ||
198 | //! initialises the Direct3D API | 198 | //! initialises the Direct3D API |
199 | bool initDriver(HWND hwnd, bool pureSoftware); | 199 | bool initDriver(HWND hwnd, bool pureSoftware); |
200 | 200 | ||
201 | //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 | 201 | //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8 |
202 | //! driver, it would return "Direct3D8.1". | 202 | //! driver, it would return "Direct3D8.1". |
203 | virtual const wchar_t* getName() const; | 203 | virtual const wchar_t* getName() const; |
204 | 204 | ||
205 | //! deletes all dynamic lights there are | 205 | //! deletes all dynamic lights there are |
206 | virtual void deleteAllDynamicLights(); | 206 | virtual void deleteAllDynamicLights(); |
207 | 207 | ||
208 | //! adds a dynamic light, returning an index to the light | 208 | //! adds a dynamic light, returning an index to the light |
209 | //! \param light: the light data to use to create the light | 209 | //! \param light: the light data to use to create the light |
210 | //! \return An index to the light, or -1 if an error occurs | 210 | //! \return An index to the light, or -1 if an error occurs |
211 | virtual s32 addDynamicLight(const SLight& light); | 211 | virtual s32 addDynamicLight(const SLight& light); |
212 | 212 | ||
213 | //! Turns a dynamic light on or off | 213 | //! Turns a dynamic light on or off |
214 | //! \param lightIndex: the index returned by addDynamicLight | 214 | //! \param lightIndex: the index returned by addDynamicLight |
215 | //! \param turnOn: true to turn the light on, false to turn it off | 215 | //! \param turnOn: true to turn the light on, false to turn it off |
216 | virtual void turnLightOn(s32 lightIndex, bool turnOn); | 216 | virtual void turnLightOn(s32 lightIndex, bool turnOn); |
217 | 217 | ||
218 | //! returns the maximal amount of dynamic lights the device can handle | 218 | //! returns the maximal amount of dynamic lights the device can handle |
219 | virtual u32 getMaximalDynamicLightAmount() const; | 219 | virtual u32 getMaximalDynamicLightAmount() const; |
220 | 220 | ||
221 | //! Sets the dynamic ambient light color. The default color is | 221 | //! Sets the dynamic ambient light color. The default color is |
222 | //! (0,0,0,0) which means it is dark. | 222 | //! (0,0,0,0) which means it is dark. |
223 | //! \param color: New color of the ambient light. | 223 | //! \param color: New color of the ambient light. |
224 | virtual void setAmbientLight(const SColorf& color); | 224 | virtual void setAmbientLight(const SColorf& color); |
225 | 225 | ||
226 | //! Draws a shadow volume into the stencil buffer. | 226 | //! Draws a shadow volume into the stencil buffer. |
227 | virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail=true, u32 debugDataVisible=0); | 227 | virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail=true, u32 debugDataVisible=0); |
228 | 228 | ||
229 | //! Fills the stencil shadow with color. | 229 | //! Fills the stencil shadow with color. |
230 | virtual void drawStencilShadow(bool clearStencilBuffer=false, | 230 | virtual void drawStencilShadow(bool clearStencilBuffer=false, |
231 | video::SColor leftUpEdge = video::SColor(0,0,0,0), | 231 | video::SColor leftUpEdge = video::SColor(0,0,0,0), |
232 | video::SColor rightUpEdge = video::SColor(0,0,0,0), | 232 | video::SColor rightUpEdge = video::SColor(0,0,0,0), |
233 | video::SColor leftDownEdge = video::SColor(0,0,0,0), | 233 | video::SColor leftDownEdge = video::SColor(0,0,0,0), |
234 | video::SColor rightDownEdge = video::SColor(0,0,0,0)); | 234 | video::SColor rightDownEdge = video::SColor(0,0,0,0)); |
235 | 235 | ||
236 | //! Returns the maximum amount of primitives (mostly vertices) which | 236 | //! Returns the maximum amount of primitives (mostly vertices) which |
237 | //! the device is able to render with one drawIndexedTriangleList | 237 | //! the device is able to render with one drawIndexedTriangleList |
238 | //! call. | 238 | //! call. |
239 | virtual u32 getMaximalPrimitiveCount() const; | 239 | virtual u32 getMaximalPrimitiveCount() const; |
240 | 240 | ||
241 | //! Enables or disables a texture creation flag. | 241 | //! Enables or disables a texture creation flag. |
242 | virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); | 242 | virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled); |
243 | 243 | ||
244 | //! Sets the fog mode. | 244 | //! Sets the fog mode. |
245 | virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start, | 245 | virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start, |
246 | f32 end, f32 density, bool pixelFog, bool rangeFog); | 246 | f32 end, f32 density, bool pixelFog, bool rangeFog); |
247 | 247 | ||
248 | //! Only used by the internal engine. Used to notify the driver that | 248 | //! Only used by the internal engine. Used to notify the driver that |
249 | //! the window was resized. | 249 | //! the window was resized. |
250 | virtual void OnResize(const core::dimension2d<u32>& size); | 250 | virtual void OnResize(const core::dimension2d<u32>& size); |
251 | 251 | ||
252 | //! Can be called by an IMaterialRenderer to make its work easier. | 252 | //! Can be called by an IMaterialRenderer to make its work easier. |
253 | virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, | 253 | virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, |
254 | bool resetAllRenderstates); | 254 | bool resetAllRenderstates); |
255 | 255 | ||
256 | //! Returns type of video driver | 256 | //! Returns type of video driver |
257 | virtual E_DRIVER_TYPE getDriverType() const; | 257 | virtual E_DRIVER_TYPE getDriverType() const; |
258 | 258 | ||
259 | //! Returns the transformation set by setTransform | 259 | //! Returns the transformation set by setTransform |
260 | virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; | 260 | virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; |
261 | 261 | ||
262 | //! Sets a vertex shader constant. | 262 | //! Sets a vertex shader constant. |
263 | virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); | 263 | virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); |
264 | 264 | ||
265 | //! Sets a pixel shader constant. | 265 | //! Sets a pixel shader constant. |
266 | virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); | 266 | virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); |
267 | 267 | ||
268 | //! Sets a constant for the vertex shader based on a name. | 268 | //! Sets a constant for the vertex shader based on a name. |
269 | virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); | 269 | virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); |
270 | 270 | ||
271 | //! Bool interface for the above. | 271 | //! Bool interface for the above. |
272 | virtual bool setVertexShaderConstant(const c8* name, const bool* bools, int count); | 272 | virtual bool setVertexShaderConstant(const c8* name, const bool* bools, int count); |
273 | 273 | ||
274 | //! Int interface for the above. | 274 | //! Int interface for the above. |
275 | virtual bool setVertexShaderConstant(const c8* name, const s32* ints, int count); | 275 | virtual bool setVertexShaderConstant(const c8* name, const s32* ints, int count); |
276 | 276 | ||
277 | //! Sets a constant for the pixel shader based on a name. | 277 | //! Sets a constant for the pixel shader based on a name. |
278 | virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); | 278 | virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); |
279 | 279 | ||
280 | //! Bool interface for the above. | 280 | //! Bool interface for the above. |
281 | virtual bool setPixelShaderConstant(const c8* name, const bool* bools, int count); | 281 | virtual bool setPixelShaderConstant(const c8* name, const bool* bools, int count); |
282 | 282 | ||
283 | //! Int interface for the above. | 283 | //! Int interface for the above. |
284 | virtual bool setPixelShaderConstant(const c8* name, const s32* ints, int count); | 284 | virtual bool setPixelShaderConstant(const c8* name, const s32* ints, int count); |
285 | 285 | ||
286 | //! Returns a pointer to the IVideoDriver interface. (Implementation for | 286 | //! Returns a pointer to the IVideoDriver interface. (Implementation for |
287 | //! IMaterialRendererServices) | 287 | //! IMaterialRendererServices) |
288 | virtual IVideoDriver* getVideoDriver(); | 288 | virtual IVideoDriver* getVideoDriver(); |
289 | 289 | ||
290 | //! Creates a render target texture. | 290 | //! Creates a render target texture. |
291 | virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, | 291 | virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, |
292 | const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); | 292 | const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); |
293 | 293 | ||
294 | //! Clears the ZBuffer. | 294 | //! Clears the ZBuffer. |
295 | virtual void clearZBuffer(); | 295 | virtual void clearZBuffer(); |
296 | 296 | ||
297 | //! Returns an image created from the last rendered frame. | 297 | //! Returns an image created from the last rendered frame. |
298 | virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER); | 298 | virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER); |
299 | 299 | ||
300 | //! Set/unset a clipping plane. | 300 | //! Set/unset a clipping plane. |
301 | virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false); | 301 | virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false); |
302 | 302 | ||
303 | //! Enable/disable a clipping plane. | 303 | //! Enable/disable a clipping plane. |
304 | virtual void enableClipPlane(u32 index, bool enable); | 304 | virtual void enableClipPlane(u32 index, bool enable); |
305 | 305 | ||
306 | //! Returns the graphics card vendor name. | 306 | //! Returns the graphics card vendor name. |
307 | virtual core::stringc getVendorInfo() {return VendorName;} | 307 | virtual core::stringc getVendorInfo() {return VendorName;} |
308 | 308 | ||
309 | //! Enable the 2d override material | 309 | //! Enable the 2d override material |
310 | virtual void enableMaterial2D(bool enable=true); | 310 | virtual void enableMaterial2D(bool enable=true); |
311 | 311 | ||
312 | //! Check if the driver was recently reset. | 312 | //! Check if the driver was recently reset. |
313 | virtual bool checkDriverReset() {return DriverWasReset;} | 313 | virtual bool checkDriverReset() {return DriverWasReset;} |
314 | 314 | ||
315 | // removes the depth struct from the DepthSurface array | 315 | // removes the depth struct from the DepthSurface array |
316 | void removeDepthSurface(SDepthSurface* depth); | 316 | void removeDepthSurface(SDepthSurface* depth); |
317 | 317 | ||
318 | //! Get the current color format of the color buffer | 318 | //! Get the current color format of the color buffer |
319 | /** \return Color format of the color buffer. */ | 319 | /** \return Color format of the color buffer. */ |
320 | virtual ECOLOR_FORMAT getColorFormat() const; | 320 | virtual ECOLOR_FORMAT getColorFormat() const; |
321 | 321 | ||
322 | //! Returns the maximum texture size supported. | 322 | //! Returns the maximum texture size supported. |
323 | virtual core::dimension2du getMaxTextureSize() const; | 323 | virtual core::dimension2du getMaxTextureSize() const; |
324 | 324 | ||
325 | //! Get the current color format of the color buffer | 325 | //! Get the current color format of the color buffer |
326 | /** \return Color format of the color buffer as D3D color value. */ | 326 | /** \return Color format of the color buffer as D3D color value. */ |
327 | D3DFORMAT getD3DColorFormat() const; | 327 | D3DFORMAT getD3DColorFormat() const; |
328 | 328 | ||
329 | //! Get D3D color format from Irrlicht color format. | 329 | //! Get D3D color format from Irrlicht color format. |
330 | D3DFORMAT getD3DFormatFromColorFormat(ECOLOR_FORMAT format) const; | 330 | D3DFORMAT getD3DFormatFromColorFormat(ECOLOR_FORMAT format) const; |
331 | 331 | ||
332 | //! Get Irrlicht color format from D3D color format. | 332 | //! Get Irrlicht color format from D3D color format. |
333 | ECOLOR_FORMAT getColorFormatFromD3DFormat(D3DFORMAT format) const; | 333 | ECOLOR_FORMAT getColorFormatFromD3DFormat(D3DFORMAT format) const; |
334 | 334 | ||
335 | //! Get Cg context | 335 | //! Get Cg context |
336 | #ifdef _IRR_COMPILE_WITH_CG_ | 336 | #ifdef _IRR_COMPILE_WITH_CG_ |
337 | const CGcontext& getCgContext(); | 337 | const CGcontext& getCgContext(); |
338 | #endif | 338 | #endif |
339 | 339 | ||
340 | private: | 340 | private: |
341 | 341 | ||
342 | //! enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. | 342 | //! enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. |
343 | enum E_RENDER_MODE | 343 | enum E_RENDER_MODE |
344 | { | 344 | { |
345 | ERM_NONE = 0, // no render state has been set yet. | 345 | ERM_NONE = 0, // no render state has been set yet. |
346 | ERM_2D, // 2d drawing rendermode | 346 | ERM_2D, // 2d drawing rendermode |
347 | ERM_3D, // 3d rendering mode | 347 | ERM_3D, // 3d rendering mode |
348 | ERM_STENCIL_FILL, // stencil fill mode | 348 | ERM_STENCIL_FILL, // stencil fill mode |
349 | ERM_SHADOW_VOLUME_ZFAIL, // stencil volume draw mode | 349 | ERM_SHADOW_VOLUME_ZFAIL, // stencil volume draw mode |
350 | ERM_SHADOW_VOLUME_ZPASS // stencil volume draw mode | 350 | ERM_SHADOW_VOLUME_ZPASS // stencil volume draw mode |
351 | }; | 351 | }; |
352 | 352 | ||
353 | //! sets right vertex shader | 353 | //! sets right vertex shader |
354 | void setVertexShader(video::E_VERTEX_TYPE newType); | 354 | void setVertexShader(video::E_VERTEX_TYPE newType); |
355 | 355 | ||
356 | //! sets the needed renderstates | 356 | //! sets the needed renderstates |
357 | bool setRenderStates3DMode(); | 357 | bool setRenderStates3DMode(); |
358 | 358 | ||
359 | //! sets the needed renderstates | 359 | //! sets the needed renderstates |
360 | void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); | 360 | void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); |
361 | 361 | ||
362 | //! sets the needed renderstates | 362 | //! sets the needed renderstates |
363 | void setRenderStatesStencilFillMode(bool alpha); | 363 | void setRenderStatesStencilFillMode(bool alpha); |
364 | 364 | ||
365 | //! sets the needed renderstates | 365 | //! sets the needed renderstates |
366 | void setRenderStatesStencilShadowMode(bool zfail, u32 debugDataVisible); | 366 | void setRenderStatesStencilShadowMode(bool zfail, u32 debugDataVisible); |
367 | 367 | ||
368 | //! sets the current Texture | 368 | //! sets the current Texture |
369 | bool setActiveTexture(u32 stage, const video::ITexture* texture); | 369 | bool setActiveTexture(u32 stage, const video::ITexture* texture); |
370 | 370 | ||
371 | //! resets the device | 371 | //! resets the device |
372 | bool reset(); | 372 | bool reset(); |
373 | 373 | ||
374 | //! returns a device dependent texture from a software surface (IImage) | 374 | //! returns a device dependent texture from a software surface (IImage) |
375 | //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES | 375 | //! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES |
376 | virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name, void* mipmapData=0); | 376 | virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name, void* mipmapData=0); |
377 | 377 | ||
378 | //! returns the current size of the screen or rendertarget | 378 | //! returns the current size of the screen or rendertarget |
379 | virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; | 379 | virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; |
380 | 380 | ||
381 | //! Check if a proper depth buffer for the RTT is available, otherwise create it. | 381 | //! Check if a proper depth buffer for the RTT is available, otherwise create it. |
382 | void checkDepthBuffer(ITexture* tex); | 382 | void checkDepthBuffer(ITexture* tex); |
383 | 383 | ||
384 | //! Adds a new material renderer to the VideoDriver, using pixel and/or | 384 | //! Adds a new material renderer to the VideoDriver, using pixel and/or |
385 | //! vertex shaders to render geometry. | 385 | //! vertex shaders to render geometry. |
386 | s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, | 386 | s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, |
387 | IShaderConstantSetCallBack* callback, | 387 | IShaderConstantSetCallBack* callback, |
388 | E_MATERIAL_TYPE baseMaterial, s32 userData); | 388 | E_MATERIAL_TYPE baseMaterial, s32 userData); |
389 | 389 | ||
390 | //! Adds a new material renderer to the VideoDriver, based on a high level shading | 390 | //! Adds a new material renderer to the VideoDriver, based on a high level shading |
391 | //! language. | 391 | //! language. |
392 | virtual s32 addHighLevelShaderMaterial( | 392 | virtual s32 addHighLevelShaderMaterial( |
393 | const c8* vertexShaderProgram, | 393 | const c8* vertexShaderProgram, |
394 | const c8* vertexShaderEntryPointName, | 394 | const c8* vertexShaderEntryPointName, |
395 | E_VERTEX_SHADER_TYPE vsCompileTarget, | 395 | E_VERTEX_SHADER_TYPE vsCompileTarget, |
396 | const c8* pixelShaderProgram, | 396 | const c8* pixelShaderProgram, |
397 | const c8* pixelShaderEntryPointName, | 397 | const c8* pixelShaderEntryPointName, |
398 | E_PIXEL_SHADER_TYPE psCompileTarget, | 398 | E_PIXEL_SHADER_TYPE psCompileTarget, |
399 | const c8* geometryShaderProgram, | 399 | const c8* geometryShaderProgram, |
400 | const c8* geometryShaderEntryPointName = "main", | 400 | const c8* geometryShaderEntryPointName = "main", |
401 | E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, | 401 | E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, |
402 | scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, | 402 | scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, |
403 | scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, | 403 | scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, |
404 | u32 verticesOut = 0, | 404 | u32 verticesOut = 0, |
405 | IShaderConstantSetCallBack* callback = 0, | 405 | IShaderConstantSetCallBack* callback = 0, |
406 | E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, | 406 | E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, |
407 | s32 userData = 0, | 407 | s32 userData = 0, |
408 | E_GPU_SHADING_LANGUAGE shadingLang = EGSL_DEFAULT); | 408 | E_GPU_SHADING_LANGUAGE shadingLang = EGSL_DEFAULT); |
409 | 409 | ||
410 | void createMaterialRenderers(); | 410 | void createMaterialRenderers(); |
411 | 411 | ||
412 | void draw2D3DVertexPrimitiveList(const void* vertices, | 412 | void draw2D3DVertexPrimitiveList(const void* vertices, |
413 | u32 vertexCount, const void* indexList, u32 primitiveCount, | 413 | u32 vertexCount, const void* indexList, u32 primitiveCount, |
414 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, | 414 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, |
415 | E_INDEX_TYPE iType, bool is3D); | 415 | E_INDEX_TYPE iType, bool is3D); |
416 | 416 | ||
417 | D3DTEXTUREADDRESS getTextureWrapMode(const u8 clamp); | 417 | D3DTEXTUREADDRESS getTextureWrapMode(const u8 clamp); |
418 | 418 | ||
419 | inline D3DCOLORVALUE colorToD3D(const SColor& col) | 419 | inline D3DCOLORVALUE colorToD3D(const SColor& col) |
420 | { | 420 | { |
421 | const f32 f = 1.0f / 255.0f; | 421 | const f32 f = 1.0f / 255.0f; |
422 | D3DCOLORVALUE v; | 422 | D3DCOLORVALUE v; |
423 | v.r = col.getRed() * f; | 423 | v.r = col.getRed() * f; |
424 | v.g = col.getGreen() * f; | 424 | v.g = col.getGreen() * f; |
425 | v.b = col.getBlue() * f; | 425 | v.b = col.getBlue() * f; |
426 | v.a = col.getAlpha() * f; | 426 | v.a = col.getAlpha() * f; |
427 | return v; | 427 | return v; |
428 | } | 428 | } |
429 | 429 | ||
430 | E_RENDER_MODE CurrentRenderMode; | 430 | E_RENDER_MODE CurrentRenderMode; |
431 | D3DPRESENT_PARAMETERS present; | 431 | D3DPRESENT_PARAMETERS present; |
432 | 432 | ||
433 | SMaterial Material, LastMaterial; | 433 | SMaterial Material, LastMaterial; |
434 | bool ResetRenderStates; // bool to make all renderstates be reseted if set. | 434 | bool ResetRenderStates; // bool to make all renderstates be reseted if set. |
435 | bool Transformation3DChanged; | 435 | bool Transformation3DChanged; |
436 | const ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; | 436 | const ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; |
437 | bool LastTextureMipMapsAvailable[MATERIAL_MAX_TEXTURES]; | 437 | bool LastTextureMipMapsAvailable[MATERIAL_MAX_TEXTURES]; |
438 | core::matrix4 Matrices[ETS_COUNT]; // matrizes of the 3d mode we need to restore when we switch back from the 2d mode. | 438 | core::matrix4 Matrices[ETS_COUNT]; // matrizes of the 3d mode we need to restore when we switch back from the 2d mode. |
439 | 439 | ||
440 | HINSTANCE D3DLibrary; | 440 | HINSTANCE D3DLibrary; |
441 | IDirect3D9* pID3D; | 441 | IDirect3D9* pID3D; |
442 | IDirect3DDevice9* pID3DDevice; | 442 | IDirect3DDevice9* pID3DDevice; |
443 | 443 | ||
444 | IDirect3DSurface9* PrevRenderTarget; | 444 | IDirect3DSurface9* PrevRenderTarget; |
445 | core::dimension2d<u32> CurrentRendertargetSize; | 445 | core::dimension2d<u32> CurrentRendertargetSize; |
446 | 446 | ||
447 | HWND WindowId; | 447 | HWND WindowId; |
448 | core::rect<s32>* SceneSourceRect; | 448 | core::rect<s32>* SceneSourceRect; |
449 | 449 | ||
450 | D3DCAPS9 Caps; | 450 | D3DCAPS9 Caps; |
451 | 451 | ||
452 | SIrrlichtCreationParameters Params; | 452 | SIrrlichtCreationParameters Params; |
453 | 453 | ||
454 | E_VERTEX_TYPE LastVertexType; | 454 | E_VERTEX_TYPE LastVertexType; |
455 | 455 | ||
456 | SColorf AmbientLight; | 456 | SColorf AmbientLight; |
457 | 457 | ||
458 | core::stringc VendorName; | 458 | core::stringc VendorName; |
459 | u16 VendorID; | 459 | u16 VendorID; |
460 | 460 | ||
461 | core::array<SDepthSurface*> DepthBuffers; | 461 | core::array<SDepthSurface*> DepthBuffers; |
462 | 462 | ||
463 | u32 MaxTextureUnits; | 463 | u32 MaxTextureUnits; |
464 | u32 MaxUserClipPlanes; | 464 | u32 MaxUserClipPlanes; |
465 | u32 MaxMRTs; | 465 | u32 MaxMRTs; |
466 | u32 NumSetMRTs; | 466 | u32 NumSetMRTs; |
467 | f32 MaxLightDistance; | 467 | f32 MaxLightDistance; |
468 | s32 LastSetLight; | 468 | s32 LastSetLight; |
469 | 469 | ||
470 | enum E_CACHE_2D_ATTRIBUTES | 470 | enum E_CACHE_2D_ATTRIBUTES |
471 | { | 471 | { |
472 | EC2D_ALPHA = 0x1, | 472 | EC2D_ALPHA = 0x1, |
473 | EC2D_TEXTURE = 0x2, | 473 | EC2D_TEXTURE = 0x2, |
474 | EC2D_ALPHA_CHANNEL = 0x4 | 474 | EC2D_ALPHA_CHANNEL = 0x4 |
475 | }; | 475 | }; |
476 | 476 | ||
477 | ECOLOR_FORMAT ColorFormat; | 477 | ECOLOR_FORMAT ColorFormat; |
478 | D3DFORMAT D3DColorFormat; | 478 | D3DFORMAT D3DColorFormat; |
479 | bool DeviceLost; | 479 | bool DeviceLost; |
480 | bool DriverWasReset; | 480 | bool DriverWasReset; |
481 | bool OcclusionQuerySupport; | 481 | bool OcclusionQuerySupport; |
482 | bool AlphaToCoverageSupport; | 482 | bool AlphaToCoverageSupport; |
483 | 483 | ||
484 | #ifdef _IRR_COMPILE_WITH_CG_ | 484 | #ifdef _IRR_COMPILE_WITH_CG_ |
485 | CGcontext CgContext; | 485 | CGcontext CgContext; |
486 | #endif | 486 | #endif |
487 | }; | 487 | }; |
488 | 488 | ||
489 | 489 | ||
490 | } // end namespace video | 490 | } // end namespace video |
491 | } // end namespace irr | 491 | } // end namespace irr |
492 | 492 | ||
493 | 493 | ||
494 | #endif // _IRR_COMPILE_WITH_DIRECT3D_9_ | 494 | #endif // _IRR_COMPILE_WITH_DIRECT3D_9_ |
495 | #endif // __C_VIDEO_DIRECTX_9_H_INCLUDED__ | 495 | #endif // __C_VIDEO_DIRECTX_9_H_INCLUDED__ |
496 | 496 | ||