I am triing to write some kind of 3D viewer for some models from diferent 3d games. For visualisation I am using good old OpenGL. To represent parts of 3D geometry I´ve writen some generic Mesh class which looks like this:
//Vector3F is float[3], Vector2F is float[2] and Triangle is unsigned short[3]
class Mesh{
Vector3F* positions;
Vector3F* normals;
Vector2F* uvMap1;
Vector2F* uvMap2;
GLuint tex1; //texture for uvMap1
GLuint tex2; //texture for uvMap2
Triangle* trangles;
unsigned int numTriangles;
public:
void draw();
};
void Mesh::draw()
{
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, positions);
if(normals) glNormalPointer(3, GL_FLOAT, 0, normals);
if(uvMap1)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tex1);
glTexCoordPointer(2, GL_FLOAT, 0, uvMap1);
/*
if(uvMap2)
{
here should be code for uvMap2
}
*/
glDisable(GL_TEXTURE_2D);
}
glDrawElements(GL_TRIANGLES, numTriangles*3, GL_UNSIGNED_SHORT, triangles);
glDisableClientState(GL_VERTEX_ARRAY);
}
This is not complete code, just the most important part for my question. As can be seen in the code would like tu use uvMap2 with the coresponding texture if it´s present. Need a solution with standard OpenGL, no wired external APIs.