]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/COpenGLDriver.h
Fix various GCC warnings
[irrlicht.git] / source / Irrlicht / COpenGLDriver.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in Irrlicht.h\r
4 \r
5 #ifndef __C_VIDEO_OPEN_GL_H_INCLUDED__\r
6 #define __C_VIDEO_OPEN_GL_H_INCLUDED__\r
7 \r
8 #include "IrrCompileConfig.h"\r
9 \r
10 #include "SIrrCreationParameters.h"\r
11 \r
12 namespace irr\r
13 {\r
14         class CIrrDeviceWin32;\r
15         class CIrrDeviceLinux;\r
16         class CIrrDeviceSDL;\r
17         class CIrrDeviceMacOSX;\r
18 }\r
19 \r
20 #ifdef _IRR_COMPILE_WITH_OPENGL_\r
21 \r
22 #include "IMaterialRendererServices.h"\r
23 #include "CNullDriver.h"\r
24 \r
25 #include "COpenGLExtensionHandler.h"\r
26 #include "IContextManager.h"\r
27 \r
28 namespace irr\r
29 {\r
30 \r
31 namespace video\r
32 {\r
33         class IContextManager;\r
34 \r
35         class COpenGLDriver : public CNullDriver, public IMaterialRendererServices, public COpenGLExtensionHandler\r
36         {\r
37         public:\r
38                 // Information about state of fixed pipeline activity.\r
39                 enum E_OPENGL_FIXED_PIPELINE_STATE\r
40                 {\r
41                         EOFPS_ENABLE = 0, // fixed pipeline.\r
42                         EOFPS_DISABLE, // programmable pipeline.\r
43                         EOFPS_ENABLE_TO_DISABLE, // switch from fixed to programmable pipeline.\r
44                         EOFPS_DISABLE_TO_ENABLE // switch from programmable to fixed pipeline.\r
45                 };\r
46 \r
47 #if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) || defined(_IRR_COMPILE_WITH_X11_DEVICE_) || defined(_IRR_COMPILE_WITH_OSX_DEVICE_)\r
48                 COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager);\r
49 #endif\r
50 \r
51 #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_\r
52                 COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device);\r
53 #endif\r
54 \r
55                 bool initDriver();\r
56 \r
57                 //! destructor\r
58                 virtual ~COpenGLDriver();\r
59 \r
60                 virtual bool beginScene(u16 clearFlag, SColor clearColor = SColor(255,0,0,0), f32 clearDepth = 1.f, u8 clearStencil = 0,\r
61                         const SExposedVideoData& videoData = SExposedVideoData(), core::rect<s32>* sourceRect = 0) _IRR_OVERRIDE_;\r
62 \r
63                 virtual bool endScene() _IRR_OVERRIDE_;\r
64 \r
65                 //! sets transformation\r
66                 virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) _IRR_OVERRIDE_;\r
67 \r
68 \r
69                 struct SHWBufferLink_opengl : public SHWBufferLink\r
70                 {\r
71                         SHWBufferLink_opengl(const scene::IMeshBuffer *_MeshBuffer): SHWBufferLink(_MeshBuffer), vbo_verticesID(0),vbo_indicesID(0){}\r
72 \r
73                         GLuint vbo_verticesID; //tmp\r
74                         GLuint vbo_indicesID; //tmp\r
75 \r
76                         GLuint vbo_verticesSize; //tmp\r
77                         GLuint vbo_indicesSize; //tmp\r
78                 };\r
79 \r
80                 //! updates hardware buffer if needed\r
81                 virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer) _IRR_OVERRIDE_;\r
82 \r
83                 //! Create hardware buffer from mesh\r
84                 virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb) _IRR_OVERRIDE_;\r
85 \r
86                 //! Delete hardware buffer (only some drivers can)\r
87                 virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer) _IRR_OVERRIDE_;\r
88 \r
89                 //! Draw hardware buffer\r
90                 virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer) _IRR_OVERRIDE_;\r
91 \r
92                 //! Create occlusion query.\r
93                 /** Use node for identification and mesh for occlusion test. */\r
94                 virtual void addOcclusionQuery(scene::ISceneNode* node,\r
95                                 const scene::IMesh* mesh=0) _IRR_OVERRIDE_;\r
96 \r
97                 //! Remove occlusion query.\r
98                 virtual void removeOcclusionQuery(scene::ISceneNode* node) _IRR_OVERRIDE_;\r
99 \r
100                 //! Run occlusion query. Draws mesh stored in query.\r
101                 /** If the mesh shall not be rendered visible, use\r
102                 overrideMaterial to disable the color and depth buffer. */\r
103                 virtual void runOcclusionQuery(scene::ISceneNode* node, bool visible=false) _IRR_OVERRIDE_;\r
104 \r
105                 //! Update occlusion query. Retrieves results from GPU.\r
106                 /** If the query shall not block, set the flag to false.\r
107                 Update might not occur in this case, though */\r
108                 virtual void updateOcclusionQuery(scene::ISceneNode* node, bool block=true) _IRR_OVERRIDE_;\r
109 \r
110                 //! Return query result.\r
111                 /** Return value is the number of visible pixels/fragments.\r
112                 The value is a safe approximation, i.e. can be larger then the\r
113                 actual value of pixels. */\r
114                 virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const _IRR_OVERRIDE_;\r
115 \r
116                 //! Create render target.\r
117                 virtual IRenderTarget* addRenderTarget() _IRR_OVERRIDE_;\r
118 \r
119                 //! draws a vertex primitive list\r
120                 virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,\r
121                                 const void* indexList, u32 primitiveCount,\r
122                                 E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) _IRR_OVERRIDE_;\r
123 \r
124                 //! draws a vertex primitive list in 2d\r
125                 virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,\r
126                                 const void* indexList, u32 primitiveCount,\r
127                                 E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType) _IRR_OVERRIDE_;\r
128 \r
129                 //! queries the features of the driver, returns true if feature is available\r
130                 virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const _IRR_OVERRIDE_\r
131                 {\r
132                         return FeatureEnabled[feature] && COpenGLExtensionHandler::queryFeature(feature);\r
133                 }\r
134 \r
135                 //! Disable a feature of the driver.\r
136                 virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) _IRR_OVERRIDE_;\r
137 \r
138                 //! Sets a material. All 3d drawing functions draw geometry now\r
139                 //! using this material.\r
140                 //! \param material: Material to be used from now on.\r
141                 virtual void setMaterial(const SMaterial& material) _IRR_OVERRIDE_;\r
142 \r
143                 virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,\r
144                         const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,\r
145                         SColor color = SColor(255, 255, 255, 255), bool useAlphaChannelOfTexture = false) _IRR_OVERRIDE_;\r
146 \r
147                 virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,\r
148                         const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,\r
149                         const video::SColor* const colors = 0, bool useAlphaChannelOfTexture = false) _IRR_OVERRIDE_;\r
150 \r
151                 // Explicitly bring in base class methods, otherwise\r
152                 // this overload would hide them.\r
153                 using CNullDriver::draw2DImage;\r
154                 virtual void draw2DImage(const video::ITexture* texture, u32 layer, bool flip);\r
155 \r
156                 //! draws a set of 2d images, using a color and the alpha channel of the\r
157                 //! texture if desired.\r
158                 void draw2DImageBatch(const video::ITexture* texture,\r
159                                 const core::array<core::position2d<s32> >& positions,\r
160                                 const core::array<core::rect<s32> >& sourceRects,\r
161                                 const core::rect<s32>* clipRect,\r
162                                 SColor color,\r
163                                 bool useAlphaChannelOfTexture) _IRR_OVERRIDE_;\r
164 \r
165                 //! draws a set of 2d images, using a color and the alpha\r
166                 /** channel of the texture if desired. The images are drawn\r
167                 beginning at pos and concatenated in one line. All drawings\r
168                 are clipped against clipRect (if != 0).\r
169                 The subtextures are defined by the array of sourceRects\r
170                 and are chosen by the indices given.\r
171                 \param texture: Texture to be drawn.\r
172                 \param pos: Upper left 2d destination position where the image will be drawn.\r
173                 \param sourceRects: Source rectangles of the image.\r
174                 \param indices: List of indices which choose the actual rectangle used each time.\r
175                 \param clipRect: Pointer to rectangle on the screen where the image is clipped to.\r
176                 This pointer can be 0. Then the image is not clipped.\r
177                 \param color: Color with which the image is colored.\r
178                 Note that the alpha component is used: If alpha is other than 255, the image will be transparent.\r
179                 \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is\r
180                 used to draw the image. */\r
181                 virtual void draw2DImageBatch(const video::ITexture* texture,\r
182                                 const core::position2d<s32>& pos,\r
183                                 const core::array<core::rect<s32> >& sourceRects,\r
184                                 const core::array<s32>& indices,\r
185                                 s32 kerningWidth=0,\r
186                                 const core::rect<s32>* clipRect=0,\r
187                                 SColor color=SColor(255,255,255,255),\r
188                                 bool useAlphaChannelOfTexture=false) _IRR_OVERRIDE_;\r
189 \r
190                 //! draw an 2d rectangle\r
191                 virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,\r
192                         const core::rect<s32>* clip = 0) _IRR_OVERRIDE_;\r
193 \r
194                 //!Draws an 2d rectangle with a gradient.\r
195                 virtual void draw2DRectangle(const core::rect<s32>& pos,\r
196                         SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,\r
197                         const core::rect<s32>* clip = 0) _IRR_OVERRIDE_;\r
198 \r
199                 //! Draws a 2d line.\r
200                 virtual void draw2DLine(const core::position2d<s32>& start,\r
201                                         const core::position2d<s32>& end,\r
202                                         SColor color=SColor(255,255,255,255)) _IRR_OVERRIDE_;\r
203 \r
204                 //! Draws a single pixel\r
205                 virtual void drawPixel(u32 x, u32 y, const SColor & color) _IRR_OVERRIDE_;\r
206 \r
207                 //! Draws a 3d box\r
208                 virtual void draw3DBox( const core::aabbox3d<f32>& box, SColor color = SColor(255,255,255,255 ) ) _IRR_OVERRIDE_;\r
209 \r
210                 //! Draws a 3d line.\r
211                 virtual void draw3DLine(const core::vector3df& start,\r
212                                         const core::vector3df& end,\r
213                                         SColor color = SColor(255,255,255,255)) _IRR_OVERRIDE_;\r
214 \r
215                 //! \return Returns the name of the video driver. Example: In case of the Direct3D8\r
216                 //! driver, it would return "Direct3D8.1".\r
217                 virtual const wchar_t* getName() const _IRR_OVERRIDE_;\r
218 \r
219                 //! deletes all dynamic lights there are\r
220                 virtual void deleteAllDynamicLights() _IRR_OVERRIDE_;\r
221 \r
222                 //! adds a dynamic light, returning an index to the light\r
223                 //! \param light: the light data to use to create the light\r
224                 //! \return An index to the light, or -1 if an error occurs\r
225                 virtual s32 addDynamicLight(const SLight& light) _IRR_OVERRIDE_;\r
226 \r
227                 //! Turns a dynamic light on or off\r
228                 //! \param lightIndex: the index returned by addDynamicLight\r
229                 //! \param turnOn: true to turn the light on, false to turn it off\r
230                 virtual void turnLightOn(s32 lightIndex, bool turnOn) _IRR_OVERRIDE_;\r
231 \r
232                 //! returns the maximal amount of dynamic lights the device can handle\r
233                 virtual u32 getMaximalDynamicLightAmount() const _IRR_OVERRIDE_;\r
234 \r
235                 //! Sets the dynamic ambient light color. The default color is\r
236                 //! (0,0,0,0) which means it is dark.\r
237                 //! \param color: New color of the ambient light.\r
238                 virtual void setAmbientLight(const SColorf& color) _IRR_OVERRIDE_;\r
239 \r
240                 //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do\r
241                 //! this: First, draw all geometry. Then use this method, to draw the shadow\r
242                 //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.\r
243                 virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible=0) _IRR_OVERRIDE_;\r
244 \r
245                 //! Fills the stencil shadow with color. After the shadow volume has been drawn\r
246                 //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this\r
247                 //! to draw the color of the shadow.\r
248                 virtual void drawStencilShadow(bool clearStencilBuffer=false,\r
249                         video::SColor leftUpEdge = video::SColor(0,0,0,0),\r
250                         video::SColor rightUpEdge = video::SColor(0,0,0,0),\r
251                         video::SColor leftDownEdge = video::SColor(0,0,0,0),\r
252                         video::SColor rightDownEdge = video::SColor(0,0,0,0)) _IRR_OVERRIDE_;\r
253 \r
254                 //! sets a viewport\r
255                 virtual void setViewPort(const core::rect<s32>& area) _IRR_OVERRIDE_;\r
256 \r
257                 //! Sets the fog mode.\r
258                 virtual void setFog(SColor color, E_FOG_TYPE fogType, f32 start,\r
259                         f32 end, f32 density, bool pixelFog, bool rangeFog) _IRR_OVERRIDE_;\r
260 \r
261                 //! Only used by the internal engine. Used to notify the driver that\r
262                 //! the window was resized.\r
263                 virtual void OnResize(const core::dimension2d<u32>& size) _IRR_OVERRIDE_;\r
264 \r
265                 //! Returns type of video driver\r
266                 virtual E_DRIVER_TYPE getDriverType() const _IRR_OVERRIDE_;\r
267 \r
268                 //! get color format of the current color buffer\r
269                 virtual ECOLOR_FORMAT getColorFormat() const _IRR_OVERRIDE_;\r
270 \r
271                 //! Returns the transformation set by setTransform\r
272                 virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const _IRR_OVERRIDE_;\r
273 \r
274                 //! Can be called by an IMaterialRenderer to make its work easier.\r
275                 virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,\r
276                         bool resetAllRenderstates) _IRR_OVERRIDE_;\r
277 \r
278                 //! Compare in SMaterial doesn't check texture parameters, so we should call this on each OnRender call.\r
279                 virtual void setTextureRenderStates(const SMaterial& material, bool resetAllRenderstates);\r
280 \r
281                 //! Get a vertex shader constant index.\r
282                 virtual s32 getVertexShaderConstantID(const c8* name) _IRR_OVERRIDE_;\r
283 \r
284                 //! Get a pixel shader constant index.\r
285                 virtual s32 getPixelShaderConstantID(const c8* name) _IRR_OVERRIDE_;\r
286 \r
287                 //! Sets a vertex shader constant.\r
288                 virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) _IRR_OVERRIDE_;\r
289 \r
290                 //! Sets a pixel shader constant.\r
291                 virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) _IRR_OVERRIDE_;\r
292 \r
293                 //! Sets a constant for the vertex shader based on an index.\r
294                 virtual bool setVertexShaderConstant(s32 index, const f32* floats, int count) _IRR_OVERRIDE_;\r
295 \r
296                 //! Int interface for the above.\r
297                 virtual bool setVertexShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;\r
298 \r
299                 //! Uint interface for the above.\r
300                 virtual bool setVertexShaderConstant(s32 index, const u32* ints, int count) _IRR_OVERRIDE_;\r
301 \r
302                 //! Sets a constant for the pixel shader based on an index.\r
303                 virtual bool setPixelShaderConstant(s32 index, const f32* floats, int count) _IRR_OVERRIDE_;\r
304 \r
305                 //! Int interface for the above.\r
306                 virtual bool setPixelShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;\r
307 \r
308                 //! Uint interface for the above.\r
309                 virtual bool setPixelShaderConstant(s32 index, const u32* ints, int count) _IRR_OVERRIDE_;\r
310 \r
311                 //! disables all textures beginning with the optional fromStage parameter. Otherwise all texture stages are disabled.\r
312                 //! Returns whether disabling was successful or not.\r
313                 bool disableTextures(u32 fromStage=0);\r
314 \r
315                 //! Adds a new material renderer to the VideoDriver, using\r
316                 //! extGLGetObjectParameteriv(shaderHandle, GL_OBJECT_COMPILE_STATUS_ARB, &status)\r
317                 //! pixel and/or vertex shaders to render geometry.\r
318                 virtual s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,\r
319                         IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData) _IRR_OVERRIDE_;\r
320 \r
321                 //! Adds a new material renderer to the VideoDriver, using GLSL to render geometry.\r
322                 virtual s32 addHighLevelShaderMaterial(\r
323                                 const c8* vertexShaderProgram,\r
324                                 const c8* vertexShaderEntryPointName,\r
325                                 E_VERTEX_SHADER_TYPE vsCompileTarget,\r
326                                 const c8* pixelShaderProgram,\r
327                                 const c8* pixelShaderEntryPointName,\r
328                                 E_PIXEL_SHADER_TYPE psCompileTarget,\r
329                                 const c8* geometryShaderProgram,\r
330                                 const c8* geometryShaderEntryPointName = "main",\r
331                                 E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,\r
332                                 scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,\r
333                                 scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,\r
334                                 u32 verticesOut = 0,\r
335                                 IShaderConstantSetCallBack* callback = 0,\r
336                                 E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,\r
337                                 s32 userData = 0) _IRR_OVERRIDE_;\r
338 \r
339                 //! Returns a pointer to the IVideoDriver interface. (Implementation for\r
340                 //! IMaterialRendererServices)\r
341                 virtual IVideoDriver* getVideoDriver() _IRR_OVERRIDE_;\r
342 \r
343                 //! Returns the maximum amount of primitives (mostly vertices) which\r
344                 //! the device is able to render with one drawIndexedTriangleList\r
345                 //! call.\r
346                 virtual u32 getMaximalPrimitiveCount() const _IRR_OVERRIDE_;\r
347 \r
348                 virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,\r
349                                 const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN) _IRR_OVERRIDE_;\r
350 \r
351                 //! Creates a render target texture for a cubemap\r
352                 ITexture* addRenderTargetTextureCubemap(const irr::u32 sideLen,\r
353                                 const io::path& name, const ECOLOR_FORMAT format) _IRR_OVERRIDE_;\r
354 \r
355                 virtual bool setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SColor clearColor = SColor(255,0,0,0),\r
356                         f32 clearDepth = 1.f, u8 clearStencil = 0) _IRR_OVERRIDE_;\r
357 \r
358                 virtual void clearBuffers(u16 flag, SColor color = SColor(255,0,0,0), f32 depth = 1.f, u8 stencil = 0) _IRR_OVERRIDE_;\r
359 \r
360                 //! Returns an image created from the last rendered frame.\r
361                 virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER) _IRR_OVERRIDE_;\r
362 \r
363                 //! checks if an OpenGL error has happened and prints it (+ some internal code which is usually the line number)\r
364                 //! for performance reasons only available in debug mode\r
365                 bool testGLError(int code=0);\r
366 \r
367                 //! Set/unset a clipping plane.\r
368                 //! There are at least 6 clipping planes available for the user to set at will.\r
369                 //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.\r
370                 //! \param plane: The plane itself.\r
371                 //! \param enable: If true, enable the clipping plane else disable it.\r
372                 virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false) _IRR_OVERRIDE_;\r
373 \r
374                 //! Enable/disable a clipping plane.\r
375                 //! There are at least 6 clipping planes available for the user to set at will.\r
376                 //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.\r
377                 //! \param enable: If true, enable the clipping plane else disable it.\r
378                 virtual void enableClipPlane(u32 index, bool enable) _IRR_OVERRIDE_;\r
379 \r
380                 //! Enable the 2d override material\r
381                 virtual void enableMaterial2D(bool enable=true) _IRR_OVERRIDE_;\r
382 \r
383                 //! Returns the graphics card vendor name.\r
384                 virtual core::stringc getVendorInfo() _IRR_OVERRIDE_ {return VendorName;}\r
385 \r
386                 //! Returns the maximum texture size supported.\r
387                 virtual core::dimension2du getMaxTextureSize() const _IRR_OVERRIDE_;\r
388 \r
389                 //! Removes a texture from the texture cache and deletes it, freeing lot of memory.\r
390                 virtual void removeTexture(ITexture* texture) _IRR_OVERRIDE_;\r
391 \r
392                 //! Check if the driver supports creating textures with the given color format\r
393                 virtual bool queryTextureFormat(ECOLOR_FORMAT format) const _IRR_OVERRIDE_;\r
394 \r
395                 //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass\r
396                 virtual bool needsTransparentRenderPass(const irr::video::SMaterial& material) const _IRR_OVERRIDE_;\r
397 \r
398                 //! Convert E_PRIMITIVE_TYPE to OpenGL equivalent\r
399                 GLenum primitiveTypeToGL(scene::E_PRIMITIVE_TYPE type) const;\r
400 \r
401                 //! Convert E_BLEND_FACTOR to OpenGL equivalent\r
402                 GLenum getGLBlend(E_BLEND_FACTOR factor) const;\r
403 \r
404                 //! Get ZBuffer bits.\r
405                 GLenum getZBufferBits() const;\r
406 \r
407                 bool getColorFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLenum& pixelFormat,\r
408                         GLenum& pixelType, void(**converter)(const void*, s32, void*)) const;\r
409 \r
410                 //! Return info about fixed pipeline state.\r
411                 E_OPENGL_FIXED_PIPELINE_STATE getFixedPipelineState() const;\r
412 \r
413                 //! Set info about fixed pipeline state.\r
414                 void setFixedPipelineState(E_OPENGL_FIXED_PIPELINE_STATE state);\r
415 \r
416                 //! Get current material.\r
417                 const SMaterial& getCurrentMaterial() const;\r
418 \r
419                 COpenGLCacheHandler* getCacheHandler() const;\r
420 \r
421         private:\r
422 \r
423                 bool updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer);\r
424                 bool updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer);\r
425 \r
426                 void uploadClipPlane(u32 index);\r
427 \r
428                 //! inits the parts of the open gl driver used on all platforms\r
429                 bool genericDriverInit();\r
430 \r
431                 virtual ITexture* createDeviceDependentTexture(const io::path& name, IImage* image) _IRR_OVERRIDE_;\r
432 \r
433                 virtual ITexture* createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image) _IRR_OVERRIDE_;\r
434 \r
435                 //! creates a transposed matrix in supplied GLfloat array to pass to OpenGL\r
436                 inline void getGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m);\r
437                 inline void getGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m);\r
438 \r
439                 //! get native wrap mode value\r
440                 GLint getTextureWrapMode(const u8 clamp);\r
441 \r
442                 //! sets the needed renderstates\r
443                 void setRenderStates3DMode();\r
444 \r
445                 //! sets the needed renderstates\r
446                 void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel);\r
447 \r
448                 void createMaterialRenderers();\r
449 \r
450                 //! Assign a hardware light to the specified requested light, if any\r
451                 //! free hardware lights exist.\r
452                 //! \param[in] lightIndex: the index of the requesting light\r
453                 void assignHardwareLight(u32 lightIndex);\r
454 \r
455                 //! helper function for render setup.\r
456                 void getColorBuffer(const void* vertices, u32 vertexCount, E_VERTEX_TYPE vType);\r
457 \r
458                 //! helper function doing the actual rendering.\r
459                 void renderArray(const void* indexList, u32 primitiveCount,\r
460                                 scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType);\r
461 \r
462                 //! Same as `CacheHandler->setViewport`, but also sets `ViewPort`\r
463                 virtual void setViewPortRaw(u32 width, u32 height);\r
464 \r
465                 COpenGLCacheHandler* CacheHandler;\r
466 \r
467                 core::stringw Name;\r
468                 core::matrix4 Matrices[ETS_COUNT];\r
469                 core::array<u8> ColorBuffer;\r
470 \r
471                 //! enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates.\r
472                 enum E_RENDER_MODE\r
473                 {\r
474                         ERM_NONE = 0,   // no render state has been set yet.\r
475                         ERM_2D,         // 2d drawing rendermode\r
476                         ERM_3D          // 3d rendering mode\r
477                 };\r
478 \r
479                 E_RENDER_MODE CurrentRenderMode;\r
480                 //! bool to make all renderstates reset if set to true.\r
481                 bool ResetRenderStates;\r
482                 bool Transformation3DChanged;\r
483                 u8 AntiAlias;\r
484 \r
485                 SMaterial Material, LastMaterial;\r
486 \r
487                 struct SUserClipPlane\r
488                 {\r
489                         SUserClipPlane() : Enabled(false) {}\r
490                         core::plane3df Plane;\r
491                         bool Enabled;\r
492                 };\r
493                 core::array<SUserClipPlane> UserClipPlanes;\r
494 \r
495                 core::stringc VendorName;\r
496 \r
497                 core::matrix4 TextureFlipMatrix;\r
498 \r
499                 //! Color buffer format\r
500                 ECOLOR_FORMAT ColorFormat;\r
501 \r
502                 E_OPENGL_FIXED_PIPELINE_STATE FixedPipelineState;\r
503 \r
504                 SIrrlichtCreationParameters Params;\r
505 \r
506                 //! All the lights that have been requested; a hardware limited\r
507                 //! number of them will be used at once.\r
508                 struct RequestedLight\r
509                 {\r
510                         RequestedLight(SLight const & lightData)\r
511                                 : LightData(lightData), HardwareLightIndex(-1), DesireToBeOn(true) { }\r
512 \r
513                         SLight  LightData;\r
514                         s32     HardwareLightIndex; // GL_LIGHT0 - GL_LIGHT7\r
515                         bool    DesireToBeOn;\r
516                 };\r
517                 core::array<RequestedLight> RequestedLights;\r
518 \r
519                 //! Built-in 2D quad for 2D rendering.\r
520                 S3DVertex Quad2DVertices[4];\r
521                 static const u16 Quad2DIndices[4];\r
522 \r
523                 #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_\r
524                         CIrrDeviceSDL *SDLDevice;\r
525                 #endif\r
526 \r
527                 IContextManager* ContextManager;\r
528         };\r
529 \r
530 } // end namespace video\r
531 } // end namespace irr\r
532 \r
533 \r
534 #endif // _IRR_COMPILE_WITH_OPENGL_\r
535 #endif\r
536 \r