1
\$\begingroup\$

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.

\$\endgroup\$
8
  • \$\begingroup\$ Are you looking for glClientActiveTexture? \$\endgroup\$
    – DMGregory
    Feb 17, 2022 at 13:44
  • \$\begingroup\$ @DMGregory Not shure, at least the examples I saw were using glClientActiveTexture for for normal, bump and some other textures usine the same UV map as difuse texture. \$\endgroup\$
    – convert
    Feb 17, 2022 at 14:12
  • \$\begingroup\$ @DMGregory Would stackoverflow posibly be a beter place to ask this question? \$\endgroup\$
    – convert
    Feb 20, 2022 at 14:13
  • \$\begingroup\$ StackOverflow gets more traffic, but less game-specific expertise, so it's a trade-off. If you choose to post there instead, be sure to delete the copy here so the question isn't closed as a cross-post. \$\endgroup\$
    – DMGregory
    Feb 20, 2022 at 14:45
  • \$\begingroup\$ @DMGregory Would not post the same question. While that glClientActiveTexture seems to be the only posible solution, I have no idea how to use it in my code. \$\endgroup\$
    – convert
    Feb 20, 2022 at 14:53

0

You must log in to answer this question.

Browse other questions tagged .