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
5 #ifndef __C_VIDEO_OPEN_GL_H_INCLUDED__
\r
6 #define __C_VIDEO_OPEN_GL_H_INCLUDED__
\r
8 #include "IrrCompileConfig.h"
\r
10 #include "SIrrCreationParameters.h"
\r
14 class CIrrDeviceWin32;
\r
15 class CIrrDeviceLinux;
\r
16 class CIrrDeviceSDL;
\r
17 class CIrrDeviceMacOSX;
\r
20 #ifdef _IRR_COMPILE_WITH_OPENGL_
\r
22 #include "IMaterialRendererServices.h"
\r
23 #include "CNullDriver.h"
\r
25 #include "COpenGLExtensionHandler.h"
\r
26 #include "IContextManager.h"
\r
33 class IContextManager;
\r
35 class COpenGLDriver : public CNullDriver, public IMaterialRendererServices, public COpenGLExtensionHandler
\r
38 // Information about state of fixed pipeline activity.
\r
39 enum E_OPENGL_FIXED_PIPELINE_STATE
\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
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
51 #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
\r
52 COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, CIrrDeviceSDL* device);
\r
58 virtual ~COpenGLDriver();
\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
63 virtual bool endScene() _IRR_OVERRIDE_;
\r
65 //! sets transformation
\r
66 virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) _IRR_OVERRIDE_;
\r
69 struct SHWBufferLink_opengl : public SHWBufferLink
\r
71 SHWBufferLink_opengl(const scene::IMeshBuffer *_MeshBuffer): SHWBufferLink(_MeshBuffer), vbo_verticesID(0),vbo_indicesID(0){}
\r
73 GLuint vbo_verticesID; //tmp
\r
74 GLuint vbo_indicesID; //tmp
\r
76 GLuint vbo_verticesSize; //tmp
\r
77 GLuint vbo_indicesSize; //tmp
\r
80 //! updates hardware buffer if needed
\r
81 virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer) _IRR_OVERRIDE_;
\r
83 //! Create hardware buffer from mesh
\r
84 virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb) _IRR_OVERRIDE_;
\r
86 //! Delete hardware buffer (only some drivers can)
\r
87 virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer) _IRR_OVERRIDE_;
\r
89 //! Draw hardware buffer
\r
90 virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer) _IRR_OVERRIDE_;
\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
97 //! Remove occlusion query.
\r
98 virtual void removeOcclusionQuery(scene::ISceneNode* node) _IRR_OVERRIDE_;
\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
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
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
116 //! Create render target.
\r
117 virtual IRenderTarget* addRenderTarget() _IRR_OVERRIDE_;
\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
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
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
132 return FeatureEnabled[feature] && COpenGLExtensionHandler::queryFeature(feature);
\r
135 //! Disable a feature of the driver.
\r
136 virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) _IRR_OVERRIDE_;
\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
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
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
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
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
163 bool useAlphaChannelOfTexture) _IRR_OVERRIDE_;
\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
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
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
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
204 //! Draws a single pixel
\r
205 virtual void drawPixel(u32 x, u32 y, const SColor & color) _IRR_OVERRIDE_;
\r
208 virtual void draw3DBox( const core::aabbox3d<f32>& box, SColor color = SColor(255,255,255,255 ) ) _IRR_OVERRIDE_;
\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
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
219 //! deletes all dynamic lights there are
\r
220 virtual void deleteAllDynamicLights() _IRR_OVERRIDE_;
\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
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
232 //! returns the maximal amount of dynamic lights the device can handle
\r
233 virtual u32 getMaximalDynamicLightAmount() const _IRR_OVERRIDE_;
\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
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
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
254 //! sets a viewport
\r
255 virtual void setViewPort(const core::rect<s32>& area) _IRR_OVERRIDE_;
\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
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
265 //! Returns type of video driver
\r
266 virtual E_DRIVER_TYPE getDriverType() const _IRR_OVERRIDE_;
\r
268 //! get color format of the current color buffer
\r
269 virtual ECOLOR_FORMAT getColorFormat() const _IRR_OVERRIDE_;
\r
271 //! Returns the transformation set by setTransform
\r
272 virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const _IRR_OVERRIDE_;
\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
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
281 //! Get a vertex shader constant index.
\r
282 virtual s32 getVertexShaderConstantID(const c8* name) _IRR_OVERRIDE_;
\r
284 //! Get a pixel shader constant index.
\r
285 virtual s32 getPixelShaderConstantID(const c8* name) _IRR_OVERRIDE_;
\r
287 //! Sets a vertex shader constant.
\r
288 virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) _IRR_OVERRIDE_;
\r
290 //! Sets a pixel shader constant.
\r
291 virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) _IRR_OVERRIDE_;
\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
296 //! Int interface for the above.
\r
297 virtual bool setVertexShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;
\r
299 //! Uint interface for the above.
\r
300 virtual bool setVertexShaderConstant(s32 index, const u32* ints, int count) _IRR_OVERRIDE_;
\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
305 //! Int interface for the above.
\r
306 virtual bool setPixelShaderConstant(s32 index, const s32* ints, int count) _IRR_OVERRIDE_;
\r
308 //! Uint interface for the above.
\r
309 virtual bool setPixelShaderConstant(s32 index, const u32* ints, int count) _IRR_OVERRIDE_;
\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
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
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
339 //! Returns a pointer to the IVideoDriver interface. (Implementation for
\r
340 //! IMaterialRendererServices)
\r
341 virtual IVideoDriver* getVideoDriver() _IRR_OVERRIDE_;
\r
343 //! Returns the maximum amount of primitives (mostly vertices) which
\r
344 //! the device is able to render with one drawIndexedTriangleList
\r
346 virtual u32 getMaximalPrimitiveCount() const _IRR_OVERRIDE_;
\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
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
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
358 virtual void clearBuffers(u16 flag, SColor color = SColor(255,0,0,0), f32 depth = 1.f, u8 stencil = 0) _IRR_OVERRIDE_;
\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
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
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
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
380 //! Enable the 2d override material
\r
381 virtual void enableMaterial2D(bool enable=true) _IRR_OVERRIDE_;
\r
383 //! Returns the graphics card vendor name.
\r
384 virtual core::stringc getVendorInfo() _IRR_OVERRIDE_ {return VendorName;}
\r
386 //! Returns the maximum texture size supported.
\r
387 virtual core::dimension2du getMaxTextureSize() const _IRR_OVERRIDE_;
\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
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
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
398 //! Convert E_PRIMITIVE_TYPE to OpenGL equivalent
\r
399 GLenum primitiveTypeToGL(scene::E_PRIMITIVE_TYPE type) const;
\r
401 //! Convert E_BLEND_FACTOR to OpenGL equivalent
\r
402 GLenum getGLBlend(E_BLEND_FACTOR factor) const;
\r
404 //! Get ZBuffer bits.
\r
405 GLenum getZBufferBits() const;
\r
407 bool getColorFormatParameters(ECOLOR_FORMAT format, GLint& internalFormat, GLenum& pixelFormat,
\r
408 GLenum& pixelType, void(**converter)(const void*, s32, void*)) const;
\r
410 //! Return info about fixed pipeline state.
\r
411 E_OPENGL_FIXED_PIPELINE_STATE getFixedPipelineState() const;
\r
413 //! Set info about fixed pipeline state.
\r
414 void setFixedPipelineState(E_OPENGL_FIXED_PIPELINE_STATE state);
\r
416 //! Get current material.
\r
417 const SMaterial& getCurrentMaterial() const;
\r
419 COpenGLCacheHandler* getCacheHandler() const;
\r
423 bool updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer);
\r
424 bool updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer);
\r
426 void uploadClipPlane(u32 index);
\r
428 //! inits the parts of the open gl driver used on all platforms
\r
429 bool genericDriverInit();
\r
431 virtual ITexture* createDeviceDependentTexture(const io::path& name, IImage* image) _IRR_OVERRIDE_;
\r
433 virtual ITexture* createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image) _IRR_OVERRIDE_;
\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
439 //! get native wrap mode value
\r
440 GLint getTextureWrapMode(const u8 clamp);
\r
442 //! sets the needed renderstates
\r
443 void setRenderStates3DMode();
\r
445 //! sets the needed renderstates
\r
446 void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel);
\r
448 void createMaterialRenderers();
\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
455 //! helper function for render setup.
\r
456 void getColorBuffer(const void* vertices, u32 vertexCount, E_VERTEX_TYPE vType);
\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
462 //! Same as `CacheHandler->setViewport`, but also sets `ViewPort`
\r
463 virtual void setViewPortRaw(u32 width, u32 height);
\r
465 COpenGLCacheHandler* CacheHandler;
\r
467 core::stringw Name;
\r
468 core::matrix4 Matrices[ETS_COUNT];
\r
469 core::array<u8> ColorBuffer;
\r
471 //! enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates.
\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
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
485 SMaterial Material, LastMaterial;
\r
487 struct SUserClipPlane
\r
489 SUserClipPlane() : Enabled(false) {}
\r
490 core::plane3df Plane;
\r
493 core::array<SUserClipPlane> UserClipPlanes;
\r
495 core::stringc VendorName;
\r
497 core::matrix4 TextureFlipMatrix;
\r
499 //! Color buffer format
\r
500 ECOLOR_FORMAT ColorFormat;
\r
502 E_OPENGL_FIXED_PIPELINE_STATE FixedPipelineState;
\r
504 SIrrlichtCreationParameters Params;
\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
510 RequestedLight(SLight const & lightData)
\r
511 : LightData(lightData), HardwareLightIndex(-1), DesireToBeOn(true) { }
\r
514 s32 HardwareLightIndex; // GL_LIGHT0 - GL_LIGHT7
\r
517 core::array<RequestedLight> RequestedLights;
\r
519 //! Built-in 2D quad for 2D rendering.
\r
520 S3DVertex Quad2DVertices[4];
\r
521 static const u16 Quad2DIndices[4];
\r
523 #ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
\r
524 CIrrDeviceSDL *SDLDevice;
\r
527 IContextManager* ContextManager;
\r
530 } // end namespace video
\r
531 } // end namespace irr
\r
534 #endif // _IRR_COMPILE_WITH_OPENGL_
\r