diff options
author | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
commit | 959831f4ef5a3e797f576c3de08cd65032c997ad (patch) | |
tree | e7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/COpenGLDriver.h | |
parent | Add info about changes to Irrlicht. (diff) | |
download | SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2 SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz |
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/COpenGLDriver.h | 1226 |
1 files changed, 613 insertions, 613 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/COpenGLDriver.h b/libraries/irrlicht-1.8/source/Irrlicht/COpenGLDriver.h index 693052c..09da709 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/COpenGLDriver.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/COpenGLDriver.h | |||
@@ -1,613 +1,613 @@ | |||
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_OPEN_GL_H_INCLUDED__ | 5 | #ifndef __C_VIDEO_OPEN_GL_H_INCLUDED__ |
6 | #define __C_VIDEO_OPEN_GL_H_INCLUDED__ | 6 | #define __C_VIDEO_OPEN_GL_H_INCLUDED__ |
7 | 7 | ||
8 | #include "IrrCompileConfig.h" | 8 | #include "IrrCompileConfig.h" |
9 | 9 | ||
10 | #include "SIrrCreationParameters.h" | 10 | #include "SIrrCreationParameters.h" |
11 | 11 | ||
12 | namespace irr | 12 | namespace irr |
13 | { | 13 | { |
14 | class CIrrDeviceWin32; | 14 | class CIrrDeviceWin32; |
15 | class CIrrDeviceLinux; | 15 | class CIrrDeviceLinux; |
16 | class CIrrDeviceSDL; | 16 | class CIrrDeviceSDL; |
17 | class CIrrDeviceMacOSX; | 17 | class CIrrDeviceMacOSX; |
18 | } | 18 | } |
19 | 19 | ||
20 | #ifdef _IRR_COMPILE_WITH_OPENGL_ | 20 | #ifdef _IRR_COMPILE_WITH_OPENGL_ |
21 | 21 | ||
22 | #include "CNullDriver.h" | 22 | #include "CNullDriver.h" |
23 | #include "IMaterialRendererServices.h" | 23 | #include "IMaterialRendererServices.h" |
24 | // also includes the OpenGL stuff | 24 | // also includes the OpenGL stuff |
25 | #include "COpenGLExtensionHandler.h" | 25 | #include "COpenGLExtensionHandler.h" |
26 | 26 | ||
27 | #ifdef _IRR_COMPILE_WITH_CG_ | 27 | #ifdef _IRR_COMPILE_WITH_CG_ |
28 | #include "Cg/cg.h" | 28 | #include "Cg/cg.h" |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | namespace irr | 31 | namespace irr |
32 | { | 32 | { |
33 | 33 | ||
34 | namespace video | 34 | namespace video |
35 | { | 35 | { |
36 | class COpenGLTexture; | 36 | class COpenGLTexture; |
37 | 37 | ||
38 | class COpenGLDriver : public CNullDriver, public IMaterialRendererServices, public COpenGLExtensionHandler | 38 | class COpenGLDriver : public CNullDriver, public IMaterialRendererServices, public COpenGLExtensionHandler |
39 | { | 39 | { |
40 | friend class COpenGLTexture; | 40 | friend class COpenGLTexture; |
41 | public: | 41 | public: |
42 | 42 | ||
43 | #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ | 43 | #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ |
44 | COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceWin32* device); | 44 | COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceWin32* device); |
45 | //! inits the windows specific parts of the open gl driver | 45 | //! inits the windows specific parts of the open gl driver |
46 | bool initDriver(CIrrDeviceWin32* device); | 46 | bool initDriver(CIrrDeviceWin32* device); |
47 | bool changeRenderContext(const SExposedVideoData& videoData, CIrrDeviceWin32* device); | 47 | bool changeRenderContext(const SExposedVideoData& videoData, CIrrDeviceWin32* device); |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | #ifdef _IRR_COMPILE_WITH_X11_DEVICE_ | 50 | #ifdef _IRR_COMPILE_WITH_X11_DEVICE_ |
51 | COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceLinux* device); | 51 | COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceLinux* device); |
52 | //! inits the GLX specific parts of the open gl driver | 52 | //! inits the GLX specific parts of the open gl driver |
53 | bool initDriver(CIrrDeviceLinux* device); | 53 | bool initDriver(CIrrDeviceLinux* device); |
54 | bool changeRenderContext(const SExposedVideoData& videoData, CIrrDeviceLinux* device); | 54 | bool changeRenderContext(const SExposedVideoData& videoData, CIrrDeviceLinux* device); |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ | 57 | #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ |
58 | COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device); | 58 | COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device); |
59 | #endif | 59 | #endif |
60 | 60 | ||
61 | #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ | 61 | #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ |
62 | COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceMacOSX *device); | 62 | COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceMacOSX *device); |
63 | #endif | 63 | #endif |
64 | 64 | ||
65 | //! generic version which overloads the unimplemented versions | 65 | //! generic version which overloads the unimplemented versions |
66 | bool changeRenderContext(const SExposedVideoData& videoData, void* device) {return false;} | 66 | bool changeRenderContext(const SExposedVideoData& videoData, void* device) {return false;} |
67 | 67 | ||
68 | //! destructor | 68 | //! destructor |
69 | virtual ~COpenGLDriver(); | 69 | virtual ~COpenGLDriver(); |
70 | 70 | ||
71 | //! clears the zbuffer | 71 | //! clears the zbuffer |
72 | virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, | 72 | virtual bool beginScene(bool backBuffer=true, bool zBuffer=true, |
73 | SColor color=SColor(255,0,0,0), | 73 | SColor color=SColor(255,0,0,0), |
74 | const SExposedVideoData& videoData=SExposedVideoData(), | 74 | const SExposedVideoData& videoData=SExposedVideoData(), |
75 | core::rect<s32>* sourceRect=0); | 75 | core::rect<s32>* sourceRect=0); |
76 | 76 | ||
77 | //! presents the rendered scene on the screen, returns false if failed | 77 | //! presents the rendered scene on the screen, returns false if failed |
78 | virtual bool endScene(); | 78 | virtual bool endScene(); |
79 | 79 | ||
80 | //! sets transformation | 80 | //! sets transformation |
81 | virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); | 81 | virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat); |
82 | 82 | ||
83 | 83 | ||
84 | struct SHWBufferLink_opengl : public SHWBufferLink | 84 | struct SHWBufferLink_opengl : public SHWBufferLink |
85 | { | 85 | { |
86 | SHWBufferLink_opengl(const scene::IMeshBuffer *_MeshBuffer): SHWBufferLink(_MeshBuffer), vbo_verticesID(0),vbo_indicesID(0){} | 86 | SHWBufferLink_opengl(const scene::IMeshBuffer *_MeshBuffer): SHWBufferLink(_MeshBuffer), vbo_verticesID(0),vbo_indicesID(0){} |
87 | 87 | ||
88 | GLuint vbo_verticesID; //tmp | 88 | GLuint vbo_verticesID; //tmp |
89 | GLuint vbo_indicesID; //tmp | 89 | GLuint vbo_indicesID; //tmp |
90 | 90 | ||
91 | GLuint vbo_verticesSize; //tmp | 91 | GLuint vbo_verticesSize; //tmp |
92 | GLuint vbo_indicesSize; //tmp | 92 | GLuint vbo_indicesSize; //tmp |
93 | }; | 93 | }; |
94 | 94 | ||
95 | //! updates hardware buffer if needed | 95 | //! updates hardware buffer if needed |
96 | virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer); | 96 | virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer); |
97 | 97 | ||
98 | //! Create hardware buffer from mesh | 98 | //! Create hardware buffer from mesh |
99 | virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb); | 99 | virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb); |
100 | 100 | ||
101 | //! Delete hardware buffer (only some drivers can) | 101 | //! Delete hardware buffer (only some drivers can) |
102 | virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer); | 102 | virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer); |
103 | 103 | ||
104 | //! Draw hardware buffer | 104 | //! Draw hardware buffer |
105 | virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer); | 105 | virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer); |
106 | 106 | ||
107 | //! Create occlusion query. | 107 | //! Create occlusion query. |
108 | /** Use node for identification and mesh for occlusion test. */ | 108 | /** Use node for identification and mesh for occlusion test. */ |
109 | virtual void addOcclusionQuery(scene::ISceneNode* node, | 109 | virtual void addOcclusionQuery(scene::ISceneNode* node, |
110 | const scene::IMesh* mesh=0); | 110 | const scene::IMesh* mesh=0); |
111 | 111 | ||
112 | //! Remove occlusion query. | 112 | //! Remove occlusion query. |
113 | virtual void removeOcclusionQuery(scene::ISceneNode* node); | 113 | virtual void removeOcclusionQuery(scene::ISceneNode* node); |
114 | 114 | ||
115 | //! Run occlusion query. Draws mesh stored in query. | 115 | //! Run occlusion query. Draws mesh stored in query. |
116 | /** If the mesh shall not be rendered visible, use | 116 | /** If the mesh shall not be rendered visible, use |
117 | overrideMaterial to disable the color and depth buffer. */ | 117 | overrideMaterial to disable the color and depth buffer. */ |
118 | virtual void runOcclusionQuery(scene::ISceneNode* node, bool visible=false); | 118 | virtual void runOcclusionQuery(scene::ISceneNode* node, bool visible=false); |
119 | 119 | ||
120 | //! Update occlusion query. Retrieves results from GPU. | 120 | //! Update occlusion query. Retrieves results from GPU. |
121 | /** If the query shall not block, set the flag to false. | 121 | /** If the query shall not block, set the flag to false. |
122 | Update might not occur in this case, though */ | 122 | Update might not occur in this case, though */ |
123 | virtual void updateOcclusionQuery(scene::ISceneNode* node, bool block=true); | 123 | virtual void updateOcclusionQuery(scene::ISceneNode* node, bool block=true); |
124 | 124 | ||
125 | //! Return query result. | 125 | //! Return query result. |
126 | /** Return value is the number of visible pixels/fragments. | 126 | /** Return value is the number of visible pixels/fragments. |
127 | The value is a safe approximation, i.e. can be larger then the | 127 | The value is a safe approximation, i.e. can be larger then the |
128 | actual value of pixels. */ | 128 | actual value of pixels. */ |
129 | virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const; | 129 | virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const; |
130 | 130 | ||
131 | //! draws a vertex primitive list | 131 | //! draws a vertex primitive list |
132 | virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, | 132 | virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount, |
133 | const void* indexList, u32 primitiveCount, | 133 | const void* indexList, u32 primitiveCount, |
134 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); | 134 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); |
135 | 135 | ||
136 | //! draws a vertex primitive list in 2d | 136 | //! draws a vertex primitive list in 2d |
137 | virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, | 137 | virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount, |
138 | const void* indexList, u32 primitiveCount, | 138 | const void* indexList, u32 primitiveCount, |
139 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); | 139 | E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); |
140 | 140 | ||
141 | //! queries the features of the driver, returns true if feature is available | 141 | //! queries the features of the driver, returns true if feature is available |
142 | virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const | 142 | virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const |
143 | { | 143 | { |
144 | return FeatureEnabled[feature] && COpenGLExtensionHandler::queryFeature(feature); | 144 | return FeatureEnabled[feature] && COpenGLExtensionHandler::queryFeature(feature); |
145 | } | 145 | } |
146 | 146 | ||
147 | //! Sets a material. All 3d drawing functions draw geometry now | 147 | //! Sets a material. All 3d drawing functions draw geometry now |
148 | //! using this material. | 148 | //! using this material. |
149 | //! \param material: Material to be used from now on. | 149 | //! \param material: Material to be used from now on. |
150 | virtual void setMaterial(const SMaterial& material); | 150 | virtual void setMaterial(const SMaterial& material); |
151 | 151 | ||
152 | //! draws a set of 2d images, using a color and the alpha channel of the | 152 | //! draws a set of 2d images, using a color and the alpha channel of the |
153 | //! texture if desired. | 153 | //! texture if desired. |
154 | void draw2DImageBatch(const video::ITexture* texture, | 154 | void draw2DImageBatch(const video::ITexture* texture, |
155 | const core::array<core::position2d<s32> >& positions, | 155 | const core::array<core::position2d<s32> >& positions, |
156 | const core::array<core::rect<s32> >& sourceRects, | 156 | const core::array<core::rect<s32> >& sourceRects, |
157 | const core::rect<s32>* clipRect, | 157 | const core::rect<s32>* clipRect, |
158 | SColor color, | 158 | SColor color, |
159 | bool useAlphaChannelOfTexture); | 159 | bool useAlphaChannelOfTexture); |
160 | 160 | ||
161 | //! 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. | 161 | //! 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. |
162 | virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, | 162 | virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, |
163 | const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, | 163 | const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, |
164 | SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); | 164 | SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false); |
165 | 165 | ||
166 | //! draws a set of 2d images, using a color and the alpha | 166 | //! draws a set of 2d images, using a color and the alpha |
167 | /** channel of the texture if desired. The images are drawn | 167 | /** channel of the texture if desired. The images are drawn |
168 | beginning at pos and concatenated in one line. All drawings | 168 | beginning at pos and concatenated in one line. All drawings |
169 | are clipped against clipRect (if != 0). | 169 | are clipped against clipRect (if != 0). |
170 | The subtextures are defined by the array of sourceRects | 170 | The subtextures are defined by the array of sourceRects |
171 | and are chosen by the indices given. | 171 | and are chosen by the indices given. |
172 | \param texture: Texture to be drawn. | 172 | \param texture: Texture to be drawn. |
173 | \param pos: Upper left 2d destination position where the image will be drawn. | 173 | \param pos: Upper left 2d destination position where the image will be drawn. |
174 | \param sourceRects: Source rectangles of the image. | 174 | \param sourceRects: Source rectangles of the image. |
175 | \param indices: List of indices which choose the actual rectangle used each time. | 175 | \param indices: List of indices which choose the actual rectangle used each time. |
176 | \param clipRect: Pointer to rectangle on the screen where the image is clipped to. | 176 | \param clipRect: Pointer to rectangle on the screen where the image is clipped to. |
177 | This pointer can be 0. Then the image is not clipped. | 177 | This pointer can be 0. Then the image is not clipped. |
178 | \param color: Color with which the image is colored. | 178 | \param color: Color with which the image is colored. |
179 | Note that the alpha component is used: If alpha is other than 255, the image will be transparent. | 179 | Note that the alpha component is used: If alpha is other than 255, the image will be transparent. |
180 | \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is | 180 | \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is |
181 | used to draw the image. */ | 181 | used to draw the image. */ |
182 | virtual void draw2DImage(const video::ITexture* texture, | 182 | virtual void draw2DImage(const video::ITexture* texture, |
183 | const core::position2d<s32>& pos, | 183 | const core::position2d<s32>& pos, |
184 | const core::array<core::rect<s32> >& sourceRects, | 184 | const core::array<core::rect<s32> >& sourceRects, |
185 | const core::array<s32>& indices, | 185 | const core::array<s32>& indices, |
186 | const core::rect<s32>* clipRect=0, | 186 | const core::rect<s32>* clipRect=0, |
187 | SColor color=SColor(255,255,255,255), | 187 | SColor color=SColor(255,255,255,255), |
188 | bool useAlphaChannelOfTexture=false); | 188 | bool useAlphaChannelOfTexture=false); |
189 | 189 | ||
190 | //! Draws a part of the texture into the rectangle. | 190 | //! Draws a part of the texture into the rectangle. |
191 | virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, | 191 | virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect, |
192 | const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, | 192 | const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0, |
193 | const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); | 193 | const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false); |
194 | 194 | ||
195 | //! draw an 2d rectangle | 195 | //! draw an 2d rectangle |
196 | virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, | 196 | virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, |
197 | const core::rect<s32>* clip = 0); | 197 | const core::rect<s32>* clip = 0); |
198 | 198 | ||
199 | //!Draws an 2d rectangle with a gradient. | 199 | //!Draws an 2d rectangle with a gradient. |
200 | virtual void draw2DRectangle(const core::rect<s32>& pos, | 200 | virtual void draw2DRectangle(const core::rect<s32>& pos, |
201 | SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, | 201 | SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown, |
202 | const core::rect<s32>* clip = 0); | 202 | const core::rect<s32>* clip = 0); |
203 | 203 | ||
204 | //! Draws a 2d line. | 204 | //! Draws a 2d line. |
205 | virtual void draw2DLine(const core::position2d<s32>& start, | 205 | virtual void draw2DLine(const core::position2d<s32>& start, |
206 | const core::position2d<s32>& end, | 206 | const core::position2d<s32>& end, |
207 | SColor color=SColor(255,255,255,255)); | 207 | SColor color=SColor(255,255,255,255)); |
208 | 208 | ||
209 | //! Draws a single pixel | 209 | //! Draws a single pixel |
210 | virtual void drawPixel(u32 x, u32 y, const SColor & color); | 210 | virtual void drawPixel(u32 x, u32 y, const SColor & color); |
211 | 211 | ||
212 | //! Draws a 3d line. | 212 | //! Draws a 3d line. |
213 | virtual void draw3DLine(const core::vector3df& start, | 213 | virtual void draw3DLine(const core::vector3df& start, |
214 | const core::vector3df& end, | 214 | const core::vector3df& end, |
215 | SColor color = SColor(255,255,255,255)); | 215 | SColor color = SColor(255,255,255,255)); |
216 | 216 | ||
217 | //! \return Returns the name of the video driver. Example: In case of the Direct3D8 | 217 | //! \return Returns the name of the video driver. Example: In case of the Direct3D8 |
218 | //! driver, it would return "Direct3D8.1". | 218 | //! driver, it would return "Direct3D8.1". |
219 | virtual const wchar_t* getName() const; | 219 | virtual const wchar_t* getName() const; |
220 | 220 | ||
221 | //! deletes all dynamic lights there are | 221 | //! deletes all dynamic lights there are |
222 | virtual void deleteAllDynamicLights(); | 222 | virtual void deleteAllDynamicLights(); |
223 | 223 | ||
224 | //! adds a dynamic light, returning an index to the light | 224 | //! adds a dynamic light, returning an index to the light |
225 | //! \param light: the light data to use to create the light | 225 | //! \param light: the light data to use to create the light |
226 | //! \return An index to the light, or -1 if an error occurs | 226 | //! \return An index to the light, or -1 if an error occurs |
227 | virtual s32 addDynamicLight(const SLight& light); | 227 | virtual s32 addDynamicLight(const SLight& light); |
228 | 228 | ||
229 | //! Turns a dynamic light on or off | 229 | //! Turns a dynamic light on or off |
230 | //! \param lightIndex: the index returned by addDynamicLight | 230 | //! \param lightIndex: the index returned by addDynamicLight |
231 | //! \param turnOn: true to turn the light on, false to turn it off | 231 | //! \param turnOn: true to turn the light on, false to turn it off |
232 | virtual void turnLightOn(s32 lightIndex, bool turnOn); | 232 | virtual void turnLightOn(s32 lightIndex, bool turnOn); |
233 | 233 | ||
234 | //! returns the maximal amount of dynamic lights the device can handle | 234 | //! returns the maximal amount of dynamic lights the device can handle |
235 | virtual u32 getMaximalDynamicLightAmount() const; | 235 | virtual u32 getMaximalDynamicLightAmount() const; |
236 | 236 | ||
237 | //! Sets the dynamic ambient light color. The default color is | 237 | //! Sets the dynamic ambient light color. The default color is |
238 | //! (0,0,0,0) which means it is dark. | 238 | //! (0,0,0,0) which means it is dark. |
239 | //! \param color: New color of the ambient light. | 239 | //! \param color: New color of the ambient light. |
240 | virtual void setAmbientLight(const SColorf& color); | 240 | virtual void setAmbientLight(const SColorf& color); |
241 | 241 | ||
242 | //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do | 242 | //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do |
243 | //! this: First, draw all geometry. Then use this method, to draw the shadow | 243 | //! this: First, draw all geometry. Then use this method, to draw the shadow |
244 | //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. | 244 | //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow. |
245 | virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible=0); | 245 | virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible=0); |
246 | 246 | ||
247 | //! Fills the stencil shadow with color. After the shadow volume has been drawn | 247 | //! Fills the stencil shadow with color. After the shadow volume has been drawn |
248 | //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this | 248 | //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this |
249 | //! to draw the color of the shadow. | 249 | //! to draw the color of the shadow. |
250 | virtual void drawStencilShadow(bool clearStencilBuffer=false, | 250 | virtual void drawStencilShadow(bool clearStencilBuffer=false, |
251 | video::SColor leftUpEdge = video::SColor(0,0,0,0), | 251 | video::SColor leftUpEdge = video::SColor(0,0,0,0), |
252 | video::SColor rightUpEdge = video::SColor(0,0,0,0), | 252 | video::SColor rightUpEdge = video::SColor(0,0,0,0), |
253 | video::SColor leftDownEdge = video::SColor(0,0,0,0), | 253 | video::SColor leftDownEdge = video::SColor(0,0,0,0), |
254 | video::SColor rightDownEdge = video::SColor(0,0,0,0)); | 254 | video::SColor rightDownEdge = video::SColor(0,0,0,0)); |
255 | 255 | ||
256 | //! sets a viewport | 256 | //! sets a viewport |
257 | virtual void setViewPort(const core::rect<s32>& area); | 257 | virtual void setViewPort(const core::rect<s32>& area); |
258 | 258 | ||
259 | //! Sets the fog mode. | 259 | //! Sets the fog mode. |
260 | virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start, | 260 | virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start, |
261 | f32 end, f32 density, bool pixelFog, bool rangeFog); | 261 | f32 end, f32 density, bool pixelFog, bool rangeFog); |
262 | 262 | ||
263 | //! Only used by the internal engine. Used to notify the driver that | 263 | //! Only used by the internal engine. Used to notify the driver that |
264 | //! the window was resized. | 264 | //! the window was resized. |
265 | virtual void OnResize(const core::dimension2d<u32>& size); | 265 | virtual void OnResize(const core::dimension2d<u32>& size); |
266 | 266 | ||
267 | //! Returns type of video driver | 267 | //! Returns type of video driver |
268 | virtual E_DRIVER_TYPE getDriverType() const; | 268 | virtual E_DRIVER_TYPE getDriverType() const; |
269 | 269 | ||
270 | //! get color format of the current color buffer | 270 | //! get color format of the current color buffer |
271 | virtual ECOLOR_FORMAT getColorFormat() const; | 271 | virtual ECOLOR_FORMAT getColorFormat() const; |
272 | 272 | ||
273 | //! Returns the transformation set by setTransform | 273 | //! Returns the transformation set by setTransform |
274 | virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; | 274 | virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const; |
275 | 275 | ||
276 | //! Can be called by an IMaterialRenderer to make its work easier. | 276 | //! Can be called by an IMaterialRenderer to make its work easier. |
277 | virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, | 277 | virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial, |
278 | bool resetAllRenderstates); | 278 | bool resetAllRenderstates); |
279 | 279 | ||
280 | //! Sets a vertex shader constant. | 280 | //! Sets a vertex shader constant. |
281 | virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); | 281 | virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); |
282 | 282 | ||
283 | //! Sets a pixel shader constant. | 283 | //! Sets a pixel shader constant. |
284 | virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); | 284 | virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); |
285 | 285 | ||
286 | //! Sets a constant for the vertex shader based on a name. | 286 | //! Sets a constant for the vertex shader based on a name. |
287 | virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); | 287 | virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); |
288 | 288 | ||
289 | //! Bool interface for the above. | 289 | //! Bool interface for the above. |
290 | virtual bool setVertexShaderConstant(const c8* name, const bool* bools, int count); | 290 | virtual bool setVertexShaderConstant(const c8* name, const bool* bools, int count); |
291 | 291 | ||
292 | //! Int interface for the above. | 292 | //! Int interface for the above. |
293 | virtual bool setVertexShaderConstant(const c8* name, const s32* ints, int count); | 293 | virtual bool setVertexShaderConstant(const c8* name, const s32* ints, int count); |
294 | 294 | ||
295 | //! Sets a constant for the pixel shader based on a name. | 295 | //! Sets a constant for the pixel shader based on a name. |
296 | virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); | 296 | virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); |
297 | 297 | ||
298 | //! Bool interface for the above. | 298 | //! Bool interface for the above. |
299 | virtual bool setPixelShaderConstant(const c8* name, const bool* bools, int count); | 299 | virtual bool setPixelShaderConstant(const c8* name, const bool* bools, int count); |
300 | 300 | ||
301 | //! Int interface for the above. | 301 | //! Int interface for the above. |
302 | virtual bool setPixelShaderConstant(const c8* name, const s32* ints, int count); | 302 | virtual bool setPixelShaderConstant(const c8* name, const s32* ints, int count); |
303 | 303 | ||
304 | //! sets the current Texture | 304 | //! sets the current Texture |
305 | //! Returns whether setting was a success or not. | 305 | //! Returns whether setting was a success or not. |
306 | bool setActiveTexture(u32 stage, const video::ITexture* texture); | 306 | bool setActiveTexture(u32 stage, const video::ITexture* texture); |
307 | 307 | ||
308 | //! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. | 308 | //! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled. |
309 | //! Returns whether disabling was successful or not. | 309 | //! Returns whether disabling was successful or not. |
310 | bool disableTextures(u32 fromStage=0); | 310 | bool disableTextures(u32 fromStage=0); |
311 | 311 | ||
312 | //! Adds a new material renderer to the VideoDriver, using | 312 | //! Adds a new material renderer to the VideoDriver, using |
313 | //! extGLGetObjectParameteriv(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status) | 313 | //! extGLGetObjectParameteriv(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status) |
314 | //! pixel and/or vertex shaders to render geometry. | 314 | //! pixel and/or vertex shaders to render geometry. |
315 | virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, | 315 | virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram, |
316 | IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData); | 316 | IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData); |
317 | 317 | ||
318 | //! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. | 318 | //! Adds a new material renderer to the VideoDriver, using GLSL to render geometry. |
319 | virtual s32 addHighLevelShaderMaterial( | 319 | virtual s32 addHighLevelShaderMaterial( |
320 | const c8* vertexShaderProgram, | 320 | const c8* vertexShaderProgram, |
321 | const c8* vertexShaderEntryPointName, | 321 | const c8* vertexShaderEntryPointName, |
322 | E_VERTEX_SHADER_TYPE vsCompileTarget, | 322 | E_VERTEX_SHADER_TYPE vsCompileTarget, |
323 | const c8* pixelShaderProgram, | 323 | const c8* pixelShaderProgram, |
324 | const c8* pixelShaderEntryPointName, | 324 | const c8* pixelShaderEntryPointName, |
325 | E_PIXEL_SHADER_TYPE psCompileTarget, | 325 | E_PIXEL_SHADER_TYPE psCompileTarget, |
326 | const c8* geometryShaderProgram, | 326 | const c8* geometryShaderProgram, |
327 | const c8* geometryShaderEntryPointName = "main", | 327 | const c8* geometryShaderEntryPointName = "main", |
328 | E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, | 328 | E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, |
329 | scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, | 329 | scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, |
330 | scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, | 330 | scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, |
331 | u32 verticesOut = 0, | 331 | u32 verticesOut = 0, |
332 | IShaderConstantSetCallBack* callback = 0, | 332 | IShaderConstantSetCallBack* callback = 0, |
333 | E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, | 333 | E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID, |
334 | s32 userData = 0, | 334 | s32 userData = 0, |
335 | E_GPU_SHADING_LANGUAGE shadingLang = EGSL_DEFAULT); | 335 | E_GPU_SHADING_LANGUAGE shadingLang = EGSL_DEFAULT); |
336 | 336 | ||
337 | //! Returns a pointer to the IVideoDriver interface. (Implementation for | 337 | //! Returns a pointer to the IVideoDriver interface. (Implementation for |
338 | //! IMaterialRendererServices) | 338 | //! IMaterialRendererServices) |
339 | virtual IVideoDriver* getVideoDriver(); | 339 | virtual IVideoDriver* getVideoDriver(); |
340 | 340 | ||
341 | //! Returns the maximum amount of primitives (mostly vertices) which | 341 | //! Returns the maximum amount of primitives (mostly vertices) which |
342 | //! the device is able to render with one drawIndexedTriangleList | 342 | //! the device is able to render with one drawIndexedTriangleList |
343 | //! call. | 343 | //! call. |
344 | virtual u32 getMaximalPrimitiveCount() const; | 344 | virtual u32 getMaximalPrimitiveCount() const; |
345 | 345 | ||
346 | virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, | 346 | virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size, |
347 | const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); | 347 | const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN); |
348 | 348 | ||
349 | //! set or reset render target | 349 | //! set or reset render target |
350 | virtual bool setRenderTarget(video::E_RENDER_TARGET target, bool clearTarget, | 350 | virtual bool setRenderTarget(video::E_RENDER_TARGET target, bool clearTarget, |
351 | bool clearZBuffer, SColor color); | 351 | bool clearZBuffer, SColor color); |
352 | 352 | ||
353 | //! set or reset render target texture | 353 | //! set or reset render target texture |
354 | virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, | 354 | virtual bool setRenderTarget(video::ITexture* texture, bool clearBackBuffer, |
355 | bool clearZBuffer, SColor color); | 355 | bool clearZBuffer, SColor color); |
356 | 356 | ||
357 | //! Sets multiple render targets | 357 | //! Sets multiple render targets |
358 | virtual bool setRenderTarget(const core::array<video::IRenderTarget>& texture, | 358 | virtual bool setRenderTarget(const core::array<video::IRenderTarget>& texture, |
359 | bool clearBackBuffer=true, bool clearZBuffer=true, SColor color=SColor(0,0,0,0)); | 359 | bool clearBackBuffer=true, bool clearZBuffer=true, SColor color=SColor(0,0,0,0)); |
360 | 360 | ||
361 | //! Clears the ZBuffer. | 361 | //! Clears the ZBuffer. |
362 | virtual void clearZBuffer(); | 362 | virtual void clearZBuffer(); |
363 | 363 | ||
364 | //! Returns an image created from the last rendered frame. | 364 | //! Returns an image created from the last rendered frame. |
365 | virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER); | 365 | virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER); |
366 | 366 | ||
367 | //! checks if an OpenGL error has happend and prints it | 367 | //! checks if an OpenGL error has happend and prints it |
368 | //! for performance reasons only available in debug mode | 368 | //! for performance reasons only available in debug mode |
369 | bool testGLError(); | 369 | bool testGLError(); |
370 | 370 | ||
371 | //! Set/unset a clipping plane. | 371 | //! Set/unset a clipping plane. |
372 | //! There are at least 6 clipping planes available for the user to set at will. | 372 | //! There are at least 6 clipping planes available for the user to set at will. |
373 | //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. | 373 | //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. |
374 | //! \param plane: The plane itself. | 374 | //! \param plane: The plane itself. |
375 | //! \param enable: If true, enable the clipping plane else disable it. | 375 | //! \param enable: If true, enable the clipping plane else disable it. |
376 | virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false); | 376 | virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false); |
377 | 377 | ||
378 | //! Enable/disable a clipping plane. | 378 | //! Enable/disable a clipping plane. |
379 | //! There are at least 6 clipping planes available for the user to set at will. | 379 | //! There are at least 6 clipping planes available for the user to set at will. |
380 | //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. | 380 | //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes. |
381 | //! \param enable: If true, enable the clipping plane else disable it. | 381 | //! \param enable: If true, enable the clipping plane else disable it. |
382 | virtual void enableClipPlane(u32 index, bool enable); | 382 | virtual void enableClipPlane(u32 index, bool enable); |
383 | 383 | ||
384 | //! Enable the 2d override material | 384 | //! Enable the 2d override material |
385 | virtual void enableMaterial2D(bool enable=true); | 385 | virtual void enableMaterial2D(bool enable=true); |
386 | 386 | ||
387 | //! Returns the graphics card vendor name. | 387 | //! Returns the graphics card vendor name. |
388 | virtual core::stringc getVendorInfo() {return VendorName;} | 388 | virtual core::stringc getVendorInfo() {return VendorName;} |
389 | 389 | ||
390 | //! Returns the maximum texture size supported. | 390 | //! Returns the maximum texture size supported. |
391 | virtual core::dimension2du getMaxTextureSize() const; | 391 | virtual core::dimension2du getMaxTextureSize() const; |
392 | 392 | ||
393 | ITexture* createDepthTexture(ITexture* texture, bool shared=true); | 393 | ITexture* createDepthTexture(ITexture* texture, bool shared=true); |
394 | void removeDepthTexture(ITexture* texture); | 394 | void removeDepthTexture(ITexture* texture); |
395 | 395 | ||
396 | //! Removes a texture from the texture cache and deletes it, freeing lot of memory. | 396 | //! Removes a texture from the texture cache and deletes it, freeing lot of memory. |
397 | void removeTexture(ITexture* texture); | 397 | void removeTexture(ITexture* texture); |
398 | 398 | ||
399 | //! Convert E_PRIMITIVE_TYPE to OpenGL equivalent | 399 | //! Convert E_PRIMITIVE_TYPE to OpenGL equivalent |
400 | GLenum primitiveTypeToGL(scene::E_PRIMITIVE_TYPE type) const; | 400 | GLenum primitiveTypeToGL(scene::E_PRIMITIVE_TYPE type) const; |
401 | 401 | ||
402 | //! Convert E_BLEND_FACTOR to OpenGL equivalent | 402 | //! Convert E_BLEND_FACTOR to OpenGL equivalent |
403 | GLenum getGLBlend(E_BLEND_FACTOR factor) const; | 403 | GLenum getGLBlend(E_BLEND_FACTOR factor) const; |
404 | 404 | ||
405 | //! Get ZBuffer bits. | 405 | //! Get ZBuffer bits. |
406 | GLenum getZBufferBits() const; | 406 | GLenum getZBufferBits() const; |
407 | 407 | ||
408 | //! Get Cg context | 408 | //! Get Cg context |
409 | #ifdef _IRR_COMPILE_WITH_CG_ | 409 | #ifdef _IRR_COMPILE_WITH_CG_ |
410 | const CGcontext& getCgContext(); | 410 | const CGcontext& getCgContext(); |
411 | #endif | 411 | #endif |
412 | 412 | ||
413 | private: | 413 | private: |
414 | 414 | ||
415 | //! clears the zbuffer and color buffer | 415 | //! clears the zbuffer and color buffer |
416 | void clearBuffers(bool backBuffer, bool zBuffer, bool stencilBuffer, SColor color); | 416 | void clearBuffers(bool backBuffer, bool zBuffer, bool stencilBuffer, SColor color); |
417 | 417 | ||
418 | bool updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); | 418 | bool updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); |
419 | bool updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); | 419 | bool updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer); |
420 | 420 | ||
421 | void uploadClipPlane(u32 index); | 421 | void uploadClipPlane(u32 index); |
422 | 422 | ||
423 | //! inits the parts of the open gl driver used on all platforms | 423 | //! inits the parts of the open gl driver used on all platforms |
424 | bool genericDriverInit(); | 424 | bool genericDriverInit(); |
425 | //! returns a device dependent texture from a software surface (IImage) | 425 | //! returns a device dependent texture from a software surface (IImage) |
426 | virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name, void* mipmapData); | 426 | virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const io::path& name, void* mipmapData); |
427 | 427 | ||
428 | //! creates a transposed matrix in supplied GLfloat array to pass to OpenGL | 428 | //! creates a transposed matrix in supplied GLfloat array to pass to OpenGL |
429 | inline void getGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m); | 429 | inline void getGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m); |
430 | inline void getGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m); | 430 | inline void getGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m); |
431 | 431 | ||
432 | //! Set GL pipeline to desired texture wrap modes of the material | 432 | //! Set GL pipeline to desired texture wrap modes of the material |
433 | void setWrapMode(const SMaterial& material); | 433 | void setWrapMode(const SMaterial& material); |
434 | 434 | ||
435 | //! get native wrap mode value | 435 | //! get native wrap mode value |
436 | GLint getTextureWrapMode(const u8 clamp); | 436 | GLint getTextureWrapMode(const u8 clamp); |
437 | 437 | ||
438 | //! sets the needed renderstates | 438 | //! sets the needed renderstates |
439 | void setRenderStates3DMode(); | 439 | void setRenderStates3DMode(); |
440 | 440 | ||
441 | //! sets the needed renderstates | 441 | //! sets the needed renderstates |
442 | void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); | 442 | void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel); |
443 | 443 | ||
444 | // returns the current size of the screen or rendertarget | 444 | // returns the current size of the screen or rendertarget |
445 | virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; | 445 | virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const; |
446 | 446 | ||
447 | void createMaterialRenderers(); | 447 | void createMaterialRenderers(); |
448 | 448 | ||
449 | //! Assign a hardware light to the specified requested light, if any | 449 | //! Assign a hardware light to the specified requested light, if any |
450 | //! free hardware lights exist. | 450 | //! free hardware lights exist. |
451 | //! \param[in] lightIndex: the index of the requesting light | 451 | //! \param[in] lightIndex: the index of the requesting light |
452 | void assignHardwareLight(u32 lightIndex); | 452 | void assignHardwareLight(u32 lightIndex); |
453 | 453 | ||
454 | //! helper function for render setup. | 454 | //! helper function for render setup. |
455 | void getColorBuffer(const void* vertices, u32 vertexCount, E_VERTEX_TYPE vType); | 455 | void getColorBuffer(const void* vertices, u32 vertexCount, E_VERTEX_TYPE vType); |
456 | 456 | ||
457 | //! helper function doing the actual rendering. | 457 | //! helper function doing the actual rendering. |
458 | void renderArray(const void* indexList, u32 primitiveCount, | 458 | void renderArray(const void* indexList, u32 primitiveCount, |
459 | scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); | 459 | scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); |
460 | 460 | ||
461 | core::stringw Name; | 461 | core::stringw Name; |
462 | core::matrix4 Matrices[ETS_COUNT]; | 462 | core::matrix4 Matrices[ETS_COUNT]; |
463 | core::array<u8> ColorBuffer; | 463 | core::array<u8> ColorBuffer; |
464 | 464 | ||
465 | //! enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. | 465 | //! enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates. |
466 | enum E_RENDER_MODE | 466 | enum E_RENDER_MODE |
467 | { | 467 | { |
468 | ERM_NONE = 0, // no render state has been set yet. | 468 | ERM_NONE = 0, // no render state has been set yet. |
469 | ERM_2D, // 2d drawing rendermode | 469 | ERM_2D, // 2d drawing rendermode |
470 | ERM_3D // 3d rendering mode | 470 | ERM_3D // 3d rendering mode |
471 | }; | 471 | }; |
472 | 472 | ||
473 | E_RENDER_MODE CurrentRenderMode; | 473 | E_RENDER_MODE CurrentRenderMode; |
474 | //! bool to make all renderstates reset if set to true. | 474 | //! bool to make all renderstates reset if set to true. |
475 | bool ResetRenderStates; | 475 | bool ResetRenderStates; |
476 | bool Transformation3DChanged; | 476 | bool Transformation3DChanged; |
477 | u8 AntiAlias; | 477 | u8 AntiAlias; |
478 | 478 | ||
479 | SMaterial Material, LastMaterial; | 479 | SMaterial Material, LastMaterial; |
480 | COpenGLTexture* RenderTargetTexture; | 480 | COpenGLTexture* RenderTargetTexture; |
481 | core::array<video::IRenderTarget> MRTargets; | 481 | core::array<video::IRenderTarget> MRTargets; |
482 | class STextureStageCache | 482 | class STextureStageCache |
483 | { | 483 | { |
484 | const ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; | 484 | const ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES]; |
485 | public: | 485 | public: |
486 | STextureStageCache() | 486 | STextureStageCache() |
487 | { | 487 | { |
488 | for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) | 488 | for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) |
489 | { | 489 | { |
490 | CurrentTexture[i] = 0; | 490 | CurrentTexture[i] = 0; |
491 | } | 491 | } |
492 | } | 492 | } |
493 | 493 | ||
494 | ~STextureStageCache() | 494 | ~STextureStageCache() |
495 | { | 495 | { |
496 | clear(); | 496 | clear(); |
497 | } | 497 | } |
498 | 498 | ||
499 | void set(u32 stage, const ITexture* tex) | 499 | void set(u32 stage, const ITexture* tex) |
500 | { | 500 | { |
501 | if (stage<MATERIAL_MAX_TEXTURES) | 501 | if (stage<MATERIAL_MAX_TEXTURES) |
502 | { | 502 | { |
503 | const ITexture* oldTexture=CurrentTexture[stage]; | 503 | const ITexture* oldTexture=CurrentTexture[stage]; |
504 | if (tex) | 504 | if (tex) |
505 | tex->grab(); | 505 | tex->grab(); |
506 | CurrentTexture[stage]=tex; | 506 | CurrentTexture[stage]=tex; |
507 | if (oldTexture) | 507 | if (oldTexture) |
508 | oldTexture->drop(); | 508 | oldTexture->drop(); |
509 | } | 509 | } |
510 | } | 510 | } |
511 | 511 | ||
512 | const ITexture* operator[](int stage) const | 512 | const ITexture* operator[](int stage) const |
513 | { | 513 | { |
514 | if ((u32)stage<MATERIAL_MAX_TEXTURES) | 514 | if ((u32)stage<MATERIAL_MAX_TEXTURES) |
515 | return CurrentTexture[stage]; | 515 | return CurrentTexture[stage]; |
516 | else | 516 | else |
517 | return 0; | 517 | return 0; |
518 | } | 518 | } |
519 | 519 | ||
520 | void remove(const ITexture* tex) | 520 | void remove(const ITexture* tex) |
521 | { | 521 | { |
522 | for (s32 i = MATERIAL_MAX_TEXTURES-1; i>= 0; --i) | 522 | for (s32 i = MATERIAL_MAX_TEXTURES-1; i>= 0; --i) |
523 | { | 523 | { |
524 | if (CurrentTexture[i] == tex) | 524 | if (CurrentTexture[i] == tex) |
525 | { | 525 | { |
526 | tex->drop(); | 526 | tex->drop(); |
527 | CurrentTexture[i] = 0; | 527 | CurrentTexture[i] = 0; |
528 | } | 528 | } |
529 | } | 529 | } |
530 | } | 530 | } |
531 | 531 | ||
532 | void clear() | 532 | void clear() |
533 | { | 533 | { |
534 | // Drop all the CurrentTexture handles | 534 | // Drop all the CurrentTexture handles |
535 | for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) | 535 | for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i) |
536 | { | 536 | { |
537 | if (CurrentTexture[i]) | 537 | if (CurrentTexture[i]) |
538 | { | 538 | { |
539 | CurrentTexture[i]->drop(); | 539 | CurrentTexture[i]->drop(); |
540 | CurrentTexture[i] = 0; | 540 | CurrentTexture[i] = 0; |
541 | } | 541 | } |
542 | } | 542 | } |
543 | } | 543 | } |
544 | }; | 544 | }; |
545 | STextureStageCache CurrentTexture; | 545 | STextureStageCache CurrentTexture; |
546 | core::array<ITexture*> DepthTextures; | 546 | core::array<ITexture*> DepthTextures; |
547 | struct SUserClipPlane | 547 | struct SUserClipPlane |
548 | { | 548 | { |
549 | SUserClipPlane() : Enabled(false) {} | 549 | SUserClipPlane() : Enabled(false) {} |
550 | core::plane3df Plane; | 550 | core::plane3df Plane; |
551 | bool Enabled; | 551 | bool Enabled; |
552 | }; | 552 | }; |
553 | core::array<SUserClipPlane> UserClipPlanes; | 553 | core::array<SUserClipPlane> UserClipPlanes; |
554 | 554 | ||
555 | core::dimension2d<u32> CurrentRendertargetSize; | 555 | core::dimension2d<u32> CurrentRendertargetSize; |
556 | 556 | ||
557 | core::stringc VendorName; | 557 | core::stringc VendorName; |
558 | 558 | ||
559 | core::matrix4 TextureFlipMatrix; | 559 | core::matrix4 TextureFlipMatrix; |
560 | 560 | ||
561 | //! Color buffer format | 561 | //! Color buffer format |
562 | ECOLOR_FORMAT ColorFormat; | 562 | ECOLOR_FORMAT ColorFormat; |
563 | 563 | ||
564 | //! Render target type for render operations | 564 | //! Render target type for render operations |
565 | E_RENDER_TARGET CurrentTarget; | 565 | E_RENDER_TARGET CurrentTarget; |
566 | 566 | ||
567 | SIrrlichtCreationParameters Params; | 567 | SIrrlichtCreationParameters Params; |
568 | 568 | ||
569 | //! All the lights that have been requested; a hardware limited | 569 | //! All the lights that have been requested; a hardware limited |
570 | //! number of them will be used at once. | 570 | //! number of them will be used at once. |
571 | struct RequestedLight | 571 | struct RequestedLight |
572 | { | 572 | { |
573 | RequestedLight(SLight const & lightData) | 573 | RequestedLight(SLight const & lightData) |
574 | : LightData(lightData), HardwareLightIndex(-1), DesireToBeOn(true) { } | 574 | : LightData(lightData), HardwareLightIndex(-1), DesireToBeOn(true) { } |
575 | 575 | ||
576 | SLight LightData; | 576 | SLight LightData; |
577 | s32 HardwareLightIndex; // GL_LIGHT0 - GL_LIGHT7 | 577 | s32 HardwareLightIndex; // GL_LIGHT0 - GL_LIGHT7 |
578 | bool DesireToBeOn; | 578 | bool DesireToBeOn; |
579 | }; | 579 | }; |
580 | core::array<RequestedLight> RequestedLights; | 580 | core::array<RequestedLight> RequestedLights; |
581 | 581 | ||
582 | #ifdef _IRR_WINDOWS_API_ | 582 | #ifdef _IRR_WINDOWS_API_ |
583 | HDC HDc; // Private GDI Device Context | 583 | HDC HDc; // Private GDI Device Context |
584 | HWND Window; | 584 | HWND Window; |
585 | #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ | 585 | #ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_ |
586 | CIrrDeviceWin32 *Win32Device; | 586 | CIrrDeviceWin32 *Win32Device; |
587 | #endif | 587 | #endif |
588 | #endif | 588 | #endif |
589 | #ifdef _IRR_COMPILE_WITH_X11_DEVICE_ | 589 | #ifdef _IRR_COMPILE_WITH_X11_DEVICE_ |
590 | GLXDrawable Drawable; | 590 | GLXDrawable Drawable; |
591 | Display* X11Display; | 591 | Display* X11Display; |
592 | CIrrDeviceLinux *X11Device; | 592 | CIrrDeviceLinux *X11Device; |
593 | #endif | 593 | #endif |
594 | #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ | 594 | #ifdef _IRR_COMPILE_WITH_OSX_DEVICE_ |
595 | CIrrDeviceMacOSX *OSXDevice; | 595 | CIrrDeviceMacOSX *OSXDevice; |
596 | #endif | 596 | #endif |
597 | #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ | 597 | #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_ |
598 | CIrrDeviceSDL *SDLDevice; | 598 | CIrrDeviceSDL *SDLDevice; |
599 | #endif | 599 | #endif |
600 | #ifdef _IRR_COMPILE_WITH_CG_ | 600 | #ifdef _IRR_COMPILE_WITH_CG_ |
601 | CGcontext CgContext; | 601 | CGcontext CgContext; |
602 | #endif | 602 | #endif |
603 | 603 | ||
604 | E_DEVICE_TYPE DeviceType; | 604 | E_DEVICE_TYPE DeviceType; |
605 | }; | 605 | }; |
606 | 606 | ||
607 | } // end namespace video | 607 | } // end namespace video |
608 | } // end namespace irr | 608 | } // end namespace irr |
609 | 609 | ||
610 | 610 | ||
611 | #endif // _IRR_COMPILE_WITH_OPENGL_ | 611 | #endif // _IRR_COMPILE_WITH_OPENGL_ |
612 | #endif | 612 | #endif |
613 | 613 | ||