GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: No Line Numbers


3ds loader (Drawing Function) by c69m
1
 
    //double oneOver255 = 1.0/255.0;

    int texIndex = 0;            

    for(int i=0;i<numberOfFaces;i+=3,texIndex+=4)
    {
        glColor3f(1.0,0.0,0.0);
        if(texvertices != NULL && texfaces[texIndex] != -1)
        {
            glEnable(GL_TEXTURE_2D);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
            glBindTexture(GL_TEXTURE_2D, texfaces[texIndex+3]);
        }
        else
        {
            glDisable(GL_TEXTURE_2D);
        }

        glBegin(GL_TRIANGLES);

        glNormal3f(faceNormals[i],faceNormals[i+1],faceNormals[i+2]);

        //glBindTexture(GL_TEXTURE_2D, Textures[0]);
        if(texvertices != NULL && texfaces[texIndex] != -1)
        {
            glTexCoord2f(texvertices[texfaces[texIndex]], texvertices[texfaces[texIndex]+1]); glVertex3f(vertices[faces[i]],vertices[faces[i]+1],vertices[faces[i]+2]);                
            glTexCoord2f(texvertices[texfaces[texIndex+1]], texvertices[texfaces[texIndex+1]+1]); glVertex3f(vertices[faces[i+1]],vertices[faces[i+1]+1],vertices[faces[i+1]+2]);                
            glTexCoord2f(texvertices[texfaces[texIndex+2]], texvertices[texfaces[texIndex+2]+1]); glVertex3f(vertices[faces[i+2]],vertices[faces[i+2]+1],vertices[faces[i+2]+2]);
        }                    
        else
        {
            glVertex3f(vertices[faces[i]],vertices[faces[i]+1],vertices[faces[i]+2]);                
            glVertex3f(vertices[faces[i+1]],vertices[faces[i+1]+1],vertices[faces[i+1]+2]);                
            glVertex3f(vertices[faces[i+2]],vertices[faces[i+2]+1],vertices[faces[i+2]+2]);
        }

        glEnd();
    }