Hi, here’s the code that get called every frame to render a mesh.
The vertex buffer contains the vertices/texture coords/weights/colours etc. and the mesh segment contains the indices for the part of the mesh that is currently being rendered.
I had originally had two viewports being drawn - the main one which is the scene and then another one which contains another view into the current scene. This small one was in the top corner. I just removed the small viewport and gained only a minimal speedup.
I think it must be the way I’m rendering the meshes.
Thanks,
Luke A. Guest.
— Start —
void CDriver::Render(const V3DVertexBuffer &c_vbRender, const V3DIndexBuffer &c_ibIndices, const C3DMeshSegment &c_meshsegPortion)
{
Msg(“OpenGL”, “[CDriver::Render 2]”);
const C3DIndexBuffer &c_ibRealIndices = reinterpret_cast<const C3DIndexBuffer &>(c_ibIndices);
const C3DVertexBuffer &c_vbRealRender = reinterpret_cast<const C3DVertexBuffer &>(c_vbRender);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
if (c_vbRealRender.GetVertexFormat().GetTotalTextureCoords() > 0)
{
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, c_vbRealRender.GetTextures(c_meshsegPortion.m_dwVertexStart));
}
if (c_vbRealRender.GetVertexFormat().IsHomogeneous() == true)
{
glVertexPointer(4, GL_FLOAT, 0, c_vbRealRender.GetVertices(c_meshsegPortion.m_dwVertexStart));
}
else
{
// glVertexPointer(3, GL_FLOAT, 16, c_vbRealRender.GetVertices(c_meshsegPortion.m_dwVertexStart));
glVertexPointer(3, GL_FLOAT, 0, c_vbRealRender.GetVertices(c_meshsegPortion.m_dwVertexStart));
}
glNormalPointer(GL_FLOAT, 0, c_vbRealRender.GetNormals(c_meshsegPortion.m_dwVertexStart));
if (m_bHasCompiledVertexArrayExension == true)
{
glLockArraysEXT(c_meshsegPortion.m_dwVertexStart, c_meshsegPortion.m_dwVertexRange);
}
glDrawElements(m_ePrimitives[c_meshsegPortion.m_primType], c_meshsegPortion.m_dwIndexRange, GL_UNSIGNED_SHORT, c_ibRealIndices.GetData() + c_meshsegPortion.m_dwIndexStart);
if (m_bHasCompiledVertexArrayExension == true)
{
glUnlockArraysEXT();
}
if (c_vbRealRender.GetVertexFormat().GetTotalTextureCoords() > 0)
{
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
}
— End —