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()
lmr->drop();
// add remaining material renderer
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_DETAIL_MAP( this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SPHERE_MAP( this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_REFLECTION_2_LAYER( this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR( this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL( this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF( this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA( this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER( this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_DETAIL_MAP(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SPHERE_MAP(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_REFLECTION_2_LAYER(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ADD_COLOR(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_VERTEX_ALPHA(this));
addAndDropMaterialRenderer(new COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(this));
// add normal map renderers
s32 tmp = 0;
......@@ -511,7 +511,7 @@ bool COpenGLDriver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
if (!HWBuffer)
return false;
if (!VertexBufferObjectExtension)
if (!FeatureAvailable[IRR_ARB_vertex_buffer_object])
return false;
const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer;
......@@ -591,13 +591,12 @@ bool COpenGLDriver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
}
bool COpenGLDriver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
{
if (!HWBuffer)
return false;
if(!VertexBufferObjectExtension)
if(!FeatureAvailable[IRR_ARB_vertex_buffer_object])
return false;
const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer;
......@@ -605,7 +604,6 @@ bool COpenGLDriver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
u32 indexCount= mb->getIndexCount();
u32 indexSize = 2;
//get or create buffer
bool newBuffer=false;
if (!HWBuffer->vbo_indicesID)
......@@ -634,8 +632,6 @@ bool COpenGLDriver::updateIndexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
}
//! updates hardware buffer if needed
bool COpenGLDriver::updateHardwareBuffer(SHWBufferLink *HWBuffer)
{
......@@ -656,15 +652,15 @@ bool COpenGLDriver::updateHardwareBuffer(SHWBufferLink *HWBuffer)
return true;
}
//! Create hardware buffer from mesh
//! Create hardware buffer from meshbuffer
COpenGLDriver::SHWBufferLink *COpenGLDriver::createHardwareBuffer(const scene::IMeshBuffer* mb)
{
if (!mb) return 0;
if (mb->getHardwareMappingHint()==scene::EHM_NEVER) return 0;
if (!mb || (mb->getHardwareMappingHint()==scene::EHM_NEVER))
return 0;
SHWBufferLink_opengl *HWBuffer=new SHWBufferLink_opengl(mb);
//add to list, in order of their meshbuffer pointer
u32 n;
for (n=0;n<HWBufferLinks.size();++n)
......@@ -692,6 +688,7 @@ COpenGLDriver::SHWBufferLink *COpenGLDriver::createHardwareBuffer(const scene::I
return HWBuffer;
}
void COpenGLDriver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer)
{
SHWBufferLink_opengl *HWBuffer=(SHWBufferLink_opengl*)_HWBuffer;
......@@ -709,10 +706,12 @@ void COpenGLDriver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer)
}
//! Draw hardware buffer
void COpenGLDriver::drawHardwareBuffer(SHWBufferLink *_HWBuffer)
{
if (!_HWBuffer) return;
if (!_HWBuffer)
return;
SHWBufferLink_opengl *HWBuffer=(SHWBufferLink_opengl*)_HWBuffer;
const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer;
......@@ -797,16 +796,21 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
if ((pType!=scene::EPT_POINTS) && (pType!=scene::EPT_POINT_SPRITES))
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)
{
case EVT_STANDARD:
if (vertices)
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);
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])
{
......@@ -816,7 +820,10 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
}
break;
case EVT_2TCOORDS:
if (vertices)
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);
// texture coordinates
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
}
break;
case EVT_TANGENTS:
if (vertices)
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);
// texture coordinates
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
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
//! 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).
//! Only the subtexture defined by sourceRect is used.
......@@ -2405,6 +2413,8 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff
ResetRenderStates=true;
if (RenderTargetTexture!=0)
{
glReadPixels(0, 0, RenderTargetTexture->getSize().Width, RenderTargetTexture->getSize().Height, GL_RGBA, GL_UNSIGNED_BYTE, RenderTargetTexture->lock());
RenderTargetTexture->unlock();
if (RenderTargetTexture->isFrameBufferObject())
{
RenderTargetTexture->unbindFrameBufferObject();
......@@ -2468,6 +2478,7 @@ const core::dimension2d<s32>& COpenGLDriver::getCurrentRenderTargetSize() const
return CurrentRendertargetSize;
}
//! Clears the ZBuffer.
void COpenGLDriver::clearZBuffer()
{
......@@ -2480,6 +2491,7 @@ void COpenGLDriver::clearZBuffer()
glDepthMask(enabled);
}
//! Returns an image created from the last rendered frame.
IImage* COpenGLDriver::createScreenShot()
{
......
......@@ -15,9 +15,7 @@ namespace video
COpenGLExtensionHandler::COpenGLExtensionHandler() :
StencilBuffer(false),
MultiTextureExtension(false), MultiSamplingExtension(false), AnisotropyExtension(false),
SeparateStencilExtension(false),
TextureCompressionExtension(false),
VertexBufferObjectExtension(false),
MaxTextureUnits(1), MaxLights(1), MaxIndices(65535),
MaxAnisotropy(1.0f), MaxUserClipPlanes(0),
Version(0), ShaderLanguageVersion(0)
......@@ -102,9 +100,7 @@ void COpenGLExtensionHandler::initExtensions(bool stencilBuffer)
MultiTextureExtension = FeatureAvailable[IRR_ARB_multitexture];
MultiSamplingExtension = FeatureAvailable[IRR_ARB_multisample];
AnisotropyExtension = FeatureAvailable[IRR_EXT_texture_filter_anisotropic];
SeparateStencilExtension = FeatureAvailable[IRR_ATI_separate_stencil];
TextureCompressionExtension = FeatureAvailable[IRR_ARB_texture_compression];
VertexBufferObjectExtension = FeatureAvailable[IRR_ARB_vertex_buffer_object];
StencilBuffer=stencilBuffer;
#ifdef _IRR_WINDOWS_API_
......
......@@ -663,9 +663,7 @@ class COpenGLExtensionHandler
bool MultiTextureExtension;
bool MultiSamplingExtension;
bool AnisotropyExtension;
bool SeparateStencilExtension;
bool TextureCompressionExtension;
bool VertexBufferObjectExtension;
// Some non-boolean properties
//! Maxmimum texture layers supported by the fixed pipeline
......
......@@ -61,13 +61,13 @@ public:
//! unlock function
virtual void unlock();
//! Returns original size of the texture.
//! Returns original size of the texture (image).
virtual const core::dimension2d<s32>& getOriginalSize() const;
//! Returns size of the texture.
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;
//! returns color format of texture
......@@ -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.
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;
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