You need to sign in or sign up before continuing.
Commit f6f335af authored by hybrid's avatar hybrid

Some reindentation, minor bugfixes, removed unused members from ExtensionHandler.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1100 dfc29bdd-3216-0410-991c-e03cc46cb475
parent b2f55c36
...@@ -356,14 +356,14 @@ void COpenGLDriver::createMaterialRenderers() ...@@ -356,14 +356,14 @@ void COpenGLDriver::createMaterialRenderers()
lmr->drop(); lmr->drop();
// add remaining material renderer // add remaining material renderer
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_DETAIL_MAP( this)); addAndDropMaterialRenderer(new COpenGLMaterialRenderer_DETAIL_MAP(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SPHERE_MAP( this)); addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SPHERE_MAP(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_REFLECTION_2_LAYER( this)); addAndDropMaterialRenderer(new COpenGLMaterialRenderer_REFLECTION_2_LAYER(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR( this)); addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL( this)); addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF( this)); addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA( this)); addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER( this)); addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(this));
// add normal map renderers // add normal map renderers
s32 tmp = 0; s32 tmp = 0;
...@@ -511,7 +511,7 @@ bool COpenGLDriver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) ...@@ -511,7 +511,7 @@ bool COpenGLDriver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
if (!HWBuffer) if (!HWBuffer)
return false; return false;
if (!VertexBufferObjectExtension) if (!FeatureAvailable[IRR_ARB_vertex_buffer_object])
return false; return false;
const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer; const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer;
...@@ -591,13 +591,12 @@ bool COpenGLDriver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) ...@@ -591,13 +591,12 @@ bool COpenGLDriver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
} }
bool COpenGLDriver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) bool COpenGLDriver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
{ {
if (!HWBuffer) if (!HWBuffer)
return false; return false;
if(!VertexBufferObjectExtension) if(!FeatureAvailable[IRR_ARB_vertex_buffer_object])
return false; return false;
const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer; const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer;
...@@ -605,7 +604,6 @@ bool COpenGLDriver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) ...@@ -605,7 +604,6 @@ bool COpenGLDriver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
u32 indexCount= mb->getIndexCount(); u32 indexCount= mb->getIndexCount();
u32 indexSize = 2; u32 indexSize = 2;
//get or create buffer //get or create buffer
bool newBuffer=false; bool newBuffer=false;
if (!HWBuffer->vbo_indicesID) if (!HWBuffer->vbo_indicesID)
...@@ -634,8 +632,6 @@ bool COpenGLDriver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) ...@@ -634,8 +632,6 @@ bool COpenGLDriver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
} }
//! updates hardware buffer if needed //! updates hardware buffer if needed
bool COpenGLDriver::updateHardwareBuffer(SHWBufferLink *HWBuffer) bool COpenGLDriver::updateHardwareBuffer(SHWBufferLink *HWBuffer)
{ {
...@@ -656,15 +652,15 @@ bool COpenGLDriver::updateHardwareBuffer(SHWBufferLink *HWBuffer) ...@@ -656,15 +652,15 @@ bool COpenGLDriver::updateHardwareBuffer(SHWBufferLink *HWBuffer)
return true; return true;
} }
//! Create hardware buffer from mesh
//! Create hardware buffer from meshbuffer
COpenGLDriver::SHWBufferLink *COpenGLDriver::createHardwareBuffer(const scene::IMeshBuffer* mb) COpenGLDriver::SHWBufferLink *COpenGLDriver::createHardwareBuffer(const scene::IMeshBuffer* mb)
{ {
if (!mb) return 0; if (!mb || (mb->getHardwareMappingHint()==scene::EHM_NEVER))
if (mb->getHardwareMappingHint()==scene::EHM_NEVER) return 0; return 0;
SHWBufferLink_opengl *HWBuffer=new SHWBufferLink_opengl(mb); SHWBufferLink_opengl *HWBuffer=new SHWBufferLink_opengl(mb);
//add to list, in order of their meshbuffer pointer //add to list, in order of their meshbuffer pointer
u32 n; u32 n;
for (n=0;n<HWBufferLinks.size();++n) for (n=0;n<HWBufferLinks.size();++n)
...@@ -692,6 +688,7 @@ COpenGLDriver::SHWBufferLink *COpenGLDriver::createHardwareBuffer(const scene::I ...@@ -692,6 +688,7 @@ COpenGLDriver::SHWBufferLink *COpenGLDriver::createHardwareBuffer(const scene::I
return HWBuffer; return HWBuffer;
} }
void COpenGLDriver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer) void COpenGLDriver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer)
{ {
SHWBufferLink_opengl *HWBuffer=(SHWBufferLink_opengl*)_HWBuffer; SHWBufferLink_opengl *HWBuffer=(SHWBufferLink_opengl*)_HWBuffer;
...@@ -709,10 +706,12 @@ void COpenGLDriver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer) ...@@ -709,10 +706,12 @@ void COpenGLDriver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer)
} }
//! Draw hardware buffer //! Draw hardware buffer
void COpenGLDriver::drawHardwareBuffer(SHWBufferLink *_HWBuffer) void COpenGLDriver::drawHardwareBuffer(SHWBufferLink *_HWBuffer)
{ {
if (!_HWBuffer) return; if (!_HWBuffer)
return;
SHWBufferLink_opengl *HWBuffer=(SHWBufferLink_opengl*)_HWBuffer; SHWBufferLink_opengl *HWBuffer=(SHWBufferLink_opengl*)_HWBuffer;
const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer; const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer;
...@@ -797,16 +796,21 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun ...@@ -797,16 +796,21 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
if ((pType!=scene::EPT_POINTS) && (pType!=scene::EPT_POINT_SPRITES)) if ((pType!=scene::EPT_POINTS) && (pType!=scene::EPT_POINT_SPRITES))
glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_NORMAL_ARRAY);
if (vertices) glColorPointer(4, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]); if (vertices)
glColorPointer(4, GL_UNSIGNED_BYTE, 0, &ColorBuffer[0]);
switch (vType) switch (vType)
{ {
case EVT_STANDARD: case EVT_STANDARD:
if (vertices)
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &(reinterpret_cast<const S3DVertex*>(vertices))[0].Pos); glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), &(reinterpret_cast<const S3DVertex*>(vertices))[0].Pos);
else
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), 0);
glNormalPointer(GL_FLOAT, sizeof(S3DVertex), &(reinterpret_cast<const S3DVertex*>(vertices))[0].Normal); glNormalPointer(GL_FLOAT, sizeof(S3DVertex), &(reinterpret_cast<const S3DVertex*>(vertices))[0].Normal);
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(reinterpret_cast<const S3DVertex*>(vertices))[0].TCoords); glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), &(reinterpret_cast<const S3DVertex*>(vertices))[0].TCoords);
if (!vertices) glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(reinterpret_cast<const S3DVertex*>(vertices))[0].Color); if (!vertices)
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertex), &(reinterpret_cast<const S3DVertex*>(vertices))[0].Color);
if (MultiTextureExtension && CurrentTexture[1]) if (MultiTextureExtension && CurrentTexture[1])
{ {
...@@ -816,7 +820,10 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun ...@@ -816,7 +820,10 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
} }
break; break;
case EVT_2TCOORDS: case EVT_2TCOORDS:
if (vertices)
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].Pos); glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].Pos);
else
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), 0);
glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].Normal); glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].Normal);
// texture coordinates // texture coordinates
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords); glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords);
...@@ -831,7 +838,10 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun ...@@ -831,7 +838,10 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
} }
break; break;
case EVT_TANGENTS: case EVT_TANGENTS:
if (vertices)
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Pos); glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Pos);
else
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), 0);
glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Normal); glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Normal);
// texture coordinates // texture coordinates
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].TCoords); glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].TCoords);
...@@ -930,11 +940,9 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun ...@@ -930,11 +940,9 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
} }
//! draws a 2d image, using a color and the alpha channel of the texture if //! draws a 2d image, using a color and the alpha channel of the texture if
//! desired. The image is drawn at pos, clipped against clipRect (if != 0). //! desired. The image is drawn at pos, clipped against clipRect (if != 0).
//! Only the subtexture defined by sourceRect is used. //! Only the subtexture defined by sourceRect is used.
...@@ -2405,6 +2413,8 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff ...@@ -2405,6 +2413,8 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff
ResetRenderStates=true; ResetRenderStates=true;
if (RenderTargetTexture!=0) if (RenderTargetTexture!=0)
{ {
glReadPixels(0, 0, RenderTargetTexture->getSize().Width, RenderTargetTexture->getSize().Height, GL_RGBA, GL_UNSIGNED_BYTE, RenderTargetTexture->lock());
RenderTargetTexture->unlock();
if (RenderTargetTexture->isFrameBufferObject()) if (RenderTargetTexture->isFrameBufferObject())
{ {
RenderTargetTexture->unbindFrameBufferObject(); RenderTargetTexture->unbindFrameBufferObject();
...@@ -2468,6 +2478,7 @@ const core::dimension2d<s32>& COpenGLDriver::getCurrentRenderTargetSize() const ...@@ -2468,6 +2478,7 @@ const core::dimension2d<s32>& COpenGLDriver::getCurrentRenderTargetSize() const
return CurrentRendertargetSize; return CurrentRendertargetSize;
} }
//! Clears the ZBuffer. //! Clears the ZBuffer.
void COpenGLDriver::clearZBuffer() void COpenGLDriver::clearZBuffer()
{ {
...@@ -2480,6 +2491,7 @@ void COpenGLDriver::clearZBuffer() ...@@ -2480,6 +2491,7 @@ void COpenGLDriver::clearZBuffer()
glDepthMask(enabled); glDepthMask(enabled);
} }
//! Returns an image created from the last rendered frame. //! Returns an image created from the last rendered frame.
IImage* COpenGLDriver::createScreenShot() IImage* COpenGLDriver::createScreenShot()
{ {
......
...@@ -15,9 +15,7 @@ namespace video ...@@ -15,9 +15,7 @@ namespace video
COpenGLExtensionHandler::COpenGLExtensionHandler() : COpenGLExtensionHandler::COpenGLExtensionHandler() :
StencilBuffer(false), StencilBuffer(false),
MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false), MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false),
SeparateStencilExtension(false),
TextureCompressionExtension(false), TextureCompressionExtension(false),
VertexBufferObjectExtension(false),
MaxTextureUnits(1), MaxLights(1), MaxIndices(65535), MaxTextureUnits(1), MaxLights(1), MaxIndices(65535),
MaxAnisotropy(1.0f), MaxUserClipPlanes(0), MaxAnisotropy(1.0f), MaxUserClipPlanes(0),
Version(0), ShaderLanguageVersion(0) Version(0), ShaderLanguageVersion(0)
...@@ -102,9 +100,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer) ...@@ -102,9 +100,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
MultiTextureExtension = FeatureAvailable[IRR_ARB_multitexture]; MultiTextureExtension = FeatureAvailable[IRR_ARB_multitexture];
MultiSamplingExtension = FeatureAvailable[IRR_ARB_multisample]; MultiSamplingExtension = FeatureAvailable[IRR_ARB_multisample];
AnisotropyExtension = FeatureAvailable[IRR_EXT_texture_filter_anisotropic]; AnisotropyExtension = FeatureAvailable[IRR_EXT_texture_filter_anisotropic];
SeparateStencilExtension = FeatureAvailable[IRR_ATI_separate_stencil];
TextureCompressionExtension = FeatureAvailable[IRR_ARB_texture_compression]; TextureCompressionExtension = FeatureAvailable[IRR_ARB_texture_compression];
VertexBufferObjectExtension = FeatureAvailable[IRR_ARB_vertex_buffer_object];
StencilBuffer=stencilBuffer; StencilBuffer=stencilBuffer;
#ifdef _IRR_WINDOWS_API_ #ifdef _IRR_WINDOWS_API_
......
...@@ -663,9 +663,7 @@ class COpenGLExtensionHandler ...@@ -663,9 +663,7 @@ class COpenGLExtensionHandler
bool MultiTextureExtension; bool MultiTextureExtension;
bool MultiSamplingExtension; bool MultiSamplingExtension;
bool AnisotropyExtension; bool AnisotropyExtension;
bool SeparateStencilExtension;
bool TextureCompressionExtension; bool TextureCompressionExtension;
bool VertexBufferObjectExtension;
// Some non-boolean properties // Some non-boolean properties
//! Maxmimum texture layers supported by the fixed pipeline //! Maxmimum texture layers supported by the fixed pipeline
......
...@@ -61,13 +61,13 @@ public: ...@@ -61,13 +61,13 @@ public:
//! unlock function //! unlock function
virtual void unlock(); virtual void unlock();
//! Returns original size of the texture. //! Returns original size of the texture (image).
virtual const core::dimension2d<s32>& getOriginalSize() const; virtual const core::dimension2d<s32>& getOriginalSize() const;
//! Returns size of the texture. //! Returns size of the texture.
virtual const core::dimension2d<s32>& getSize() const; virtual const core::dimension2d<s32>& getSize() const;
//! returns driver type of texture (=the driver, who created the texture) //! returns driver type of texture (=the driver, that created it)
virtual E_DRIVER_TYPE getDriverType() const; virtual E_DRIVER_TYPE getDriverType() const;
//! returns color format of texture //! returns color format of texture
...@@ -113,7 +113,7 @@ private: ...@@ -113,7 +113,7 @@ private:
//! \param: newTexture is true if method is called from a newly created texture for the first time. Otherwise call with false to improve memory handling. //! \param: newTexture is true if method is called from a newly created texture for the first time. Otherwise call with false to improve memory handling.
void copyTexture(bool newTexture=true); void copyTexture(bool newTexture=true);
//! returns the size of a texture which would be the optimize size for rendering it //! returns the size of a texture which would be optimal for rendering
inline s32 getTextureSizeFromSurfaceSize(s32 size) const; inline s32 getTextureSizeFromSurfaceSize(s32 size) const;
core::dimension2d<s32> ImageSize; core::dimension2d<s32> ImageSize;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment