Commit d9abe1d9 authored by hybrid's avatar hybrid

Fixes to make VBOs actually work in OpenGL. Need more improvements, though....

Fixes to make VBOs actually work in OpenGL. Need more improvements, though. Minor fixes in other files.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1103 dfc29bdd-3216-0410-991c-e03cc46cb475
parent e240aeaf
...@@ -516,9 +516,9 @@ bool COpenGLDriver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer) ...@@ -516,9 +516,9 @@ bool COpenGLDriver::updateVertexHardwareBuffer(SHWBufferLink_opengl *HWBuffer)
const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer; const scene::IMeshBuffer* mb = HWBuffer->MeshBuffer;
const void* vertices=mb->getVertices(); const void* vertices=mb->getVertices();
u32 vertexCount=mb->getVertexCount(); const u32 vertexCount=mb->getVertexCount();
E_VERTEX_TYPE vType=mb->getVertexType(); const E_VERTEX_TYPE vType=mb->getVertexType();
u32 vertexSize = getVertexPitchFromType(vType); const u32 vertexSize = getVertexPitchFromType(vType);
//buffer vertex data, and convert colours... //buffer vertex data, and convert colours...
core::array<c8> buffer(vertexSize * vertexCount); core::array<c8> buffer(vertexSize * vertexCount);
...@@ -708,7 +708,6 @@ void COpenGLDriver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer) ...@@ -708,7 +708,6 @@ void COpenGLDriver::deleteHardwareBuffer(SHWBufferLink *_HWBuffer)
extGlDeleteBuffers(1, &HWBuffer->vbo_indicesID); extGlDeleteBuffers(1, &HWBuffer->vbo_indicesID);
HWBuffer->vbo_indicesID=0; HWBuffer->vbo_indicesID=0;
} }
} }
...@@ -811,60 +810,85 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun ...@@ -811,60 +810,85 @@ void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, u32 vertexCoun
{ {
case EVT_STANDARD: case EVT_STANDARD:
if (vertices) if (vertices)
{
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);
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 else
{
glNormalPointer(GL_FLOAT, sizeof(S3DVertex), (u8*)0 + 12);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertex), (u8*)0 + 24);
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), (u8*)0 + 28);
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex), 0); 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 (MultiTextureExtension && CurrentTexture[1]) if (MultiTextureExtension && CurrentTexture[1])
{ {
extGlClientActiveTexture(GL_TEXTURE1_ARB); extGlClientActiveTexture(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
if (vertices)
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);
else
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex), (u8*)0 + 28);
} }
break; break;
case EVT_2TCOORDS: case EVT_2TCOORDS:
if (vertices) if (vertices)
{
glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].Normal);
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords);
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 else
{
glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), (u8*)0 + 12);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertex2TCoords), (u8*)0 + 24);
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), (u8*)0 + 28);
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), 0); 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);
if (!vertices) glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].Color);
if (MultiTextureExtension) if (MultiTextureExtension)
{ {
extGlClientActiveTexture(GL_TEXTURE1_ARB); extGlClientActiveTexture(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
if (vertices)
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords2); glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &(reinterpret_cast<const S3DVertex2TCoords*>(vertices))[0].TCoords2);
else
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), (u8*)0 + 34);
} }
break; break;
case EVT_TANGENTS: case EVT_TANGENTS:
if (vertices) if (vertices)
{
glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Normal);
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].TCoords);
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 else
{
glNormalPointer(GL_FLOAT, sizeof(S3DVertexTangents), (u8*)0 + 12);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertexTangents), (u8*)0 + 24);
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertexTangents), (u8*)0 + 28);
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), 0); 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);
if (!vertices) glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Color);
if (MultiTextureExtension) if (MultiTextureExtension)
{ {
extGlClientActiveTexture(GL_TEXTURE1_ARB); extGlClientActiveTexture(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
if (vertices)
glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Tangent); glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Tangent);
else
glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), (u8*)0 + 34);
extGlClientActiveTexture(GL_TEXTURE2_ARB); extGlClientActiveTexture(GL_TEXTURE2_ARB);
glEnableClientState ( GL_TEXTURE_COORD_ARRAY ); glEnableClientState ( GL_TEXTURE_COORD_ARRAY );
if (vertices)
glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Binormal); glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), &(reinterpret_cast<const S3DVertexTangents*>(vertices))[0].Binormal);
else
glTexCoordPointer(3, GL_FLOAT, sizeof(S3DVertexTangents), (u8*)0 + 46);
} }
break; break;
} }
......
...@@ -24,7 +24,7 @@ namespace video ...@@ -24,7 +24,7 @@ namespace video
static bool checkFBOStatus(COpenGLDriver* Driver); static bool checkFBOStatus(COpenGLDriver* Driver);
//! constructor for usual textures //! constructor for usual textures
COpenGLTexture::COpenGLTexture(IImage* image, const char* name, COpenGLDriver* driver) COpenGLTexture::COpenGLTexture(IImage* origImage, const char* name, COpenGLDriver* driver)
: ITexture(name), Driver(driver), Image(0), : ITexture(name), Driver(driver), Image(0),
TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT), TextureName(0), InternalFormat(GL_RGBA), PixelFormat(GL_BGRA_EXT),
PixelType(GL_UNSIGNED_BYTE), HasMipMaps(true), IsRenderTarget(false), PixelType(GL_UNSIGNED_BYTE), HasMipMaps(true), IsRenderTarget(false),
...@@ -34,7 +34,7 @@ COpenGLTexture::COpenGLTexture(IImage* image, const char* name, COpenGLDriver* d ...@@ -34,7 +34,7 @@ COpenGLTexture::COpenGLTexture(IImage* image, const char* name, COpenGLDriver* d
setDebugName("COpenGLTexture"); setDebugName("COpenGLTexture");
#endif #endif
getImageData(image); getImageData(origImage);
HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS); HasMipMaps = Driver->getTextureCreationFlag(ETCF_CREATE_MIP_MAPS);
if (Image) if (Image)
......
...@@ -696,7 +696,7 @@ bool CSkinnedMesh::setHardwareSkinning(bool on) ...@@ -696,7 +696,7 @@ bool CSkinnedMesh::setHardwareSkinning(bool on)
HardwareSkinning=on; HardwareSkinning=on;
} }
return true; return HardwareSkinning;
} }
void CSkinnedMesh::CalculateGlobalMatrixes(SJoint *Joint,SJoint *ParentJoint) void CSkinnedMesh::CalculateGlobalMatrixes(SJoint *Joint,SJoint *ParentJoint)
......
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