Jump to content
  • Advertisement
Sign in to follow this  

OpenGL VBOs, Texture Mapping and lib3DS

This topic is 3765 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone. I am new to OpenGL programming and what follows may be a silly question. I am writing some code to display 3DS objects using "lib3ds". I've found a single tutorial on the web on how to use "lib3ds" and using another post from this forum I've managed to more or less display 3DS objects (albeit without textures). At the moment, I use VBOs to load in the vertices, normals and texture coords:
for(mesh=model->meshes; mesh!=NULL; mesh=mesh->next)
    lib3ds_mesh_calculate_normals(mesh, &normals[finishedFaces*3]); // normals
    // loop through every face
    for(unsigned int curFace=0; curFace < mesh->faces; curFace++)
        Lib3dsFace *face = &mesh->faceL[curFace];
        for(unsigned int i=0; i<3; i++)
            memcpy(&vertices[finishedFaces*3+i],mesh->pointL[face->points[ i ]].pos, sizeof(Lib3dsVector));
            if(mesh->texels)    // texture coordinates
                memcpy(&texCoords[finishedFaces*3+i], mesh->texelL[face->points[ i ]], sizeof(Lib3dsTexel));

However, I have no idea how to load the "lib3ds" texture data and how to then draw the textures using glDrawArrays(). I can manually load a single texture file, and then call glBindTexture() before calling glDrawArrays() and that works fine. This is of course not ideal as many of the 3DS files I am dealing with have more than a single texture. I've tried reading the "red book" and NeHe's OpenGL tutorials, but found nothing on this topic. Any help would be appreciated. Cheers -EM

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!