No, it's not downloadable yet. I was hoping for this weekend but OpenGL is really messed up. I have fixed a HUGE bug with openGL rendering, the way irrlicht setup the rendering in the drawIndexed* functions was completely wrong and out of order.
Take this function for example, in Irrlicht-0.12 :
Code: Select all
//! draws an indexed triangle list
void COpenGLDriver::drawIndexedTriangleList(const S3DVertex2TCoords* vertices, s32 vertexCount,
const u16* indexList, s32 triangleCount)
{
if (!checkPrimitiveCount(triangleCount))
return;
CNullDriver::drawIndexedTriangleList(vertices, vertexCount, indexList, triangleCount);
setRenderStates3DMode();
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY );
glEnableClientState(GL_NORMAL_ARRAY );
// convert colors to gl color format.
const S3DVertex2TCoords* p = vertices;
ColorBuffer.set_used(vertexCount);
for (s32 i=0; i<vertexCount; ++i)
{
ColorBuffer[i] = p->Color.toOpenGLColor();
++p;
}
// draw everything
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(video::SColor), &ColorBuffer[0]);
glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &vertices[0].Normal);
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), &vertices[0].Pos);
// texture coordiantes
if (MultiTextureExtension)
{
extGlClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState ( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &vertices[0].TCoords);
extGlClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState ( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &vertices[0].TCoords2);
}
else
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &vertices[0].TCoords);
glDrawElements(GL_TRIANGLES, triangleCount * 3, GL_UNSIGNED_SHORT, indexList);
glFlush();
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
if (MultiTextureExtension)
{
extGlClientActiveTextureARB(GL_TEXTURE0_ARB);
glDisableClientState ( GL_TEXTURE_COORD_ARRAY );
extGlClientActiveTextureARB(GL_TEXTURE1_ARB);
glDisableClientState ( GL_TEXTURE_COORD_ARRAY );
}
else
glDisableClientState(GL_TEXTURE_COORD_ARRAY );
glDisableClientState(GL_NORMAL_ARRAY );
}
It should be :
Code: Select all
//! draws an indexed triangle list
void COpenGLDriver::drawIndexedTriangleList(const S3DVertex2TCoords* vertices, s32 vertexCount,
const u16* indexList, s32 triangleCount)
{
if (!checkPrimitiveCount(triangleCount))
return;
CNullDriver::drawIndexedTriangleList(vertices, vertexCount, indexList, triangleCount);
setRenderStates3DMode();
// convert colors to gl color format.
const S3DVertex2TCoords* p = vertices;
ColorBuffer.set_used(vertexCount);
for (s32 i=0; i<vertexCount; ++i)
{
ColorBuffer[i] = p->Color.toOpenGLColor();
++p;
}
// draw everything
extGlClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(video::SColor), &ColorBuffer[0]);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(S3DVertex2TCoords), &vertices[0].Pos);
glEnableClientState(GL_NORMAL_ARRAY );
glNormalPointer(GL_FLOAT, sizeof(S3DVertex2TCoords), &vertices[0].Normal);
glEnableClientState ( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &vertices[0].TCoords);
// texture coordiantes
if (MultiTextureExtension)
{
extGlClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState ( GL_TEXTURE_COORD_ARRAY );
glTexCoordPointer(2, GL_FLOAT, sizeof(S3DVertex2TCoords), &vertices[0].TCoords2);
}
glDrawElements(GL_TRIANGLES, triangleCount * 3, GL_UNSIGNED_SHORT, indexList);
glFlush();
extGlClientActiveTextureARB(GL_TEXTURE0_ARB);
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
if (MultiTextureExtension)
{
extGlClientActiveTextureARB( GL_TEXTURE1_ARB );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
}
}
To explain this further, ( I'm just learning OpenGL so it's all new to me ), but when you are setting up client states, you need to set them up for each texture unit. So calling -
Code: Select all
glDisableClientState( GL_VERTEX_ARRAY );
glDisableClientState( GL_NORMAL_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_TEXTURE_COORD_ARRAY );
without specifying
Code: Select all
extGlClientActiveTextureARB(GL_TEXTURE0_ARB);
Will disable those client states for whichever texture unit happens to be left active, which, in the original code for this function, was GL_TEXTURE_ARB1, so it was disabling the 2nd texture stage, not the first. Also, as a point, for the more than 8 texture support, you have to enable the client state for each texture unit.
Also, the major difference between DirectX and OpenGL texture stage setup, is that in DirectX, if I do this -
Code: Select all
pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_DISABLE );
pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE );
That will disable the 2nd texture stage and any texture stage after it. In OpenGL, you need to disable each texture unit. Disabling the 2nd texture unit, does not disable the 3rd texture unit and beyond. So, with 8 textures, for the EMT_SOLID material, you need to do -
Code: Select all
if (Driver->hasMultiTextureExtension())
{
Driver->setTexture( 1, 0 );
Driver->setTexture( 2, 0 );
Driver->setTexture( 3, 0 );
Driver->setTexture( 4, 0 );
Driver->setTexture( 5, 0 );
Driver->setTexture( 6, 0 );
Driver->setTexture( 7, 0 );
}
Phew, anyways, there are still more OpenGL bugs to workout, like transparency issues, which I am determined to figure out!
As far as the vertices being a lot bigger in size, I'm going to try and add a setup, where you can specify the number of texture coords per vertex, so if you're only using 2 texture coords, only 2 will be enabled in the vertex format.
The new release of IrrSpintz is gonna be delayed prolly till sometime next week or next weekend, while I work these issues out. Sorry.