   Lib3ds 2
  Hi, i used this tutorial:http://donkerdump.nl/node/207for loading 3ds object. Now i want put texture on this object. My texture is in .tga file... I use this for loading texture:glBindTexture(GL_TEXTURE_2D, textureObjects[BODY_TEXTURE]);    pBytes = gltLoadTGA("body.tga", &iWidth, &iHeight, &iComponents, &eFormat);   glTexImage2D(GL_TEXTURE_2D, 0, iComponents, iWidth, iHeight, 0, eFormat, GL_UNSIGNED_BYTE, (void *)pBytes);    free(pBytes);But what next?Thanks...   
  Take a look here.If that doesn't help, you'll have to be more specific.   ;  I use this for draw objects...:class CModel3DS{public:CModel3DS(std::string filename);virtual ~CModel3DS();// This function counts the total number of faces a model has. void GetFaces(){   m_TotalFaces = 0;Lib3dsMesh * mesh;// Loop through every meshfor(mesh = m_model->meshes;mesh != NULL;mesh = mesh->next){// Add the number of faces this mesh has to the total facesm_TotalFaces += mesh->faces;}}// This function loads the vertices, normals and texture-coordinates into a VBO.void CreateVBO(){  assert(m_model != NULL); // Calculate the number of faces we have in total   GetFaces(); // Allocate memory for our vertices and normals   Lib3dsVector * vertices = new Lib3dsVector[m_TotalFaces * 3];   Lib3dsVector * normals = new Lib3dsVector[m_TotalFaces * 3];Lib3dsTexel * texCoords = new Lib3dsTexel[m_TotalFaces * 3]; Lib3dsMesh * mesh;   unsigned int FinishedFaces = 0;   // Loop through all the meshes   for(mesh = m_model->meshes;mesh != NULL;mesh = mesh->next)   { lib3ds_mesh_calculate_normals(mesh, &normals[FinishedFaces*3]); // Loop through every face for(unsigned int cur_face = 0; cur_face < mesh->faces;cur_face++) {    Lib3dsFace * face = &mesh->faceL[cur_face];    for(unsigned int i = 0;i < 3;i++)    { if(mesh->texels) { memcpy(&texCoords[FinishedFaces*3 + i], mesh->texelL[face->points], <span class="cpp-keyword">sizeof</span>(Lib3dsTexel));<br> }<br>   <br>  memcpy(&amp;vertices[FinishedFaces*<span class="cpp-number">3</span> + i], mesh-&gt;pointL[face-&gt;points].pos, <span class="cpp-keyword">sizeof</span>(Lib3dsVector));<br>    }<br>    FinishedFaces++;<br> }<br>   }<br>   <br>   <span class="cpp-comment">// Generate a Vertex Buffer Object and store it with our vertices</span><br>   glGenBuffers(<span class="cpp-number">1</span>, &amp;m_VertexVBO);<br>   glBindBuffer(GL_ARRAY_BUFFER, m_VertexVBO);<br>   glBufferData(GL_ARRAY_BUFFER, <span class="cpp-keyword">sizeof</span>(Lib3dsVector) * <span class="cpp-number">3</span> * m_TotalFaces, vertices, GL_STATIC_DRAW);<br>   <br>   <span class="cpp-comment">// Generate another Vertex Buffer Object and store the normals in it</span><br>   glGenBuffers(<span class="cpp-number">1</span>, &amp;m_NormalVBO);<br>   glBindBuffer(GL_ARRAY_BUFFER, m_NormalVBO);<br>   glBufferData(GL_ARRAY_BUFFER, <span class="cpp-keyword">sizeof</span>(Lib3dsVector) * <span class="cpp-number">3</span> * m_TotalFaces, normals, GL_STATIC_DRAW);<br>   <br><span class="cpp-comment">// Generate a third VBO and store the texture coordinates in it. </span><br>   glGenBuffers(<span class="cpp-number">1</span>, &amp;m_TexCoordVBO);<br>   glBindBuffer(GL_ARRAY_BUFFER, m_TexCoordVBO);<br>   glBufferData(GL_ARRAY_BUFFER, <span class="cpp-keyword">sizeof</span>(Lib3dsTexel) * <span class="cpp-number">3</span> * m_TotalFaces, texCoords, GL_STATIC_DRAW); <br><br>   <span class="cpp-comment">// Clean up our allocated memory</span><br>   <span class="cpp-keyword">delete</span> vertices;<br>   <span class="cpp-keyword">delete</span> normals;<br>   <span class="cpp-keyword">delete</span> texCoords;<br><br>   <span class="cpp-comment">// We no longer need lib3ds</span><br>   lib3ds_file_free(m_model);<br>   m_model = NULL;<br>}<br><span class="cpp-comment">// This function renders the model using the VBO.</span><br><br><span class="cpp-keyword">void</span> Draw()<br>{    <br>  assert(m_TotalFaces != <span class="cpp-number">0</span>);<br>   <br>   <span class="cpp-comment">// Enable vertex and normal arrays</span><br>   glEnableClientState(GL_VERTEX_ARRAY);<br>   glEnableClientState(GL_NORMAL_ARRAY);<br>   glEnableClientState(GL_TEXTURE_COORD_ARRAY); <br>   <br>   <span class="cpp-comment">// Bind the vbo with the normals</span><br>   glBindBuffer(GL_ARRAY_BUFFER, m_NormalVBO);<br>   <span class="cpp-comment">// The pointer for the normals is NULL which means that OpenGL will use the currently bound vbo</span><br>   glNormalPointer(GL_FLOAT, <span class="cpp-number">0</span>, NULL);<br> glBindBuffer(GL_ARRAY_BUFFER, m_TexCoordVBO);<br>glTexCoordPointer(<span class="cpp-number">2</span>, GL_FLOAT, <span class="cpp-number">0</span>, NULL);   <br>   glBindBuffer(GL_ARRAY_BUFFER, m_VertexVBO);<br><br>   glVertexPointer(<span class="cpp-number">3</span>, GL_FLOAT, <span class="cpp-number">0</span>, NULL);<br>   glPushMatrix();<br>   <span class="cpp-comment">// Render the triangles</span><br>   glDrawArrays(GL_TRIANGLES, <span class="cpp-number">0</span>, m_TotalFaces * <span class="cpp-number">3</span>);<br>   glPopMatrix();<br>   glDisableClientState(GL_VERTEX_ARRAY);<br>   glDisableClientState(GL_NORMAL_ARRAY);<br>glDisableClientState(GL_TEXTURE_COORD_ARRAY);  <br><br><br>}<br><br><span class="cpp-keyword">protected</span>:<br><br><span class="cpp-keyword">unsigned</span> <span class="cpp-keyword">int</span> m_TotalFaces;<br>Lib3dsFile * m_model;<br>GLuint m_VertexVBO, m_NormalVBO, m_TexCoordVBO;<br>};<br>CModel3DS * monkey;<br><span class="cpp-comment">// Load 3DS model</span><br>CModel3DS::CModel3DS(std::string filename)<br>{<br>m_TotalFaces = <span class="cpp-number">0</span>;<br><br>m_model = lib3ds_file_load(filename.c_str());<br><span class="cpp-comment">// If loading the model failed, we throw an exception</span><br><span class="cpp-keyword">if</span>(!m_model)<br>{<br><span class="cpp-comment">//throw strcat("Unable to load ", filename.c_str());</span><br>}<br>}<br><br><span class="cpp-comment">// Destructor</span><br>CModel3DS::~CModel3DS()<br>{<br>glDeleteBuffers(<span class="cpp-number">1</span>, &amp;m_VertexVBO);<br>glDeleteBuffers(<span class="cpp-number">1</span>, &amp;m_NormalVBO);<br>glDeleteBuffers(<span class="cpp-number">1</span>, &amp;m_TexCoordVBO);<br><br><span class="cpp-keyword">if</span>(m_model != NULL)<br>{<br>lib3ds_file_free(m_model);<br>}<br>}<br><br></pre></div><!–ENDSCRIPT–><br><br>this for render scene with rotation…:<br><!–STARTSCRIPT–><!–source lang="cpp"–><div class="source"><pre><span class="cpp-keyword">void</span> RenderScene(<span class="cpp-keyword">void</span>)<br>    {<br><br> <span class="cpp-comment">// Clear the window with current clearing color</span><br>    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);<br><br>    <span class="cpp-comment">// Make the cube a wire frame</span><br>glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);<br><br><span class="cpp-comment">// Save the matrix state</span><br>    glMatrixMode(GL_MODELVIEW);<br>    glPushMatrix();<br>    glTranslatef(<span class="cpp-number">0</span>.0f, <span class="cpp-number">0</span>.0f, -<span class="cpp-number">200</span>.0f);<br>    <br>    <span class="cpp-comment">// Rotate about x and y axes</span><br>    glRotatef(xRot, <span class="cpp-number">1</span>.0f, <span class="cpp-number">0</span>.0f, <span class="cpp-number">0</span>.0f);<br>    glRotatef(yRot, <span class="cpp-number">0</span>.0f, <span class="cpp-number">0</span>.0f, <span class="cpp-number">1</span>.0f);<br><br>    <span class="cpp-comment">// Using Drawarrays</span><br>    monkey-&gt;Draw();<br>  <br>    glPopMatrix();<br><br>    <span class="cpp-comment">// Swap buffers</span><br>    glutSwapBuffers();<br>}<br><br></pre></div><!–ENDSCRIPT–><br><br>And this for loading texture…:<br><!–STARTSCRIPT–><!–source lang="cpp"–><div class="source"><pre><span class="cpp-comment">// This function does any needed initialization on the rendering</span><br><span class="cpp-comment">// context. </span><br><span class="cpp-keyword">void</span> SetupRC()<br>    {<br> GLint iWidth, iHeight,iComponents;<br>    GLenum eFormat;<br>    GLbyte *pBytes;<br>    <br>    GLfloat fAmbLight[] =   { <span class="cpp-number">0</span>.1f, <span class="cpp-number">0</span>.1f, <span class="cpp-number">0</span>.1f, <span class="cpp-number">0</span>.0f };<br>    GLfloat fDiffLight[] =  { <span class="cpp-number">1</span>.0f, <span class="cpp-number">1</span>.0f, <span class="cpp-number">1</span>.0f, <span class="cpp-number">0</span>.0f };<br>    GLfloat fSpecLight[] = { <span class="cpp-number">0</span>.5f, <span class="cpp-number">0</span>.5f, <span class="cpp-number">0</span>.5f, <span class="cpp-number">0</span>.0f };<br>    GLfloat lightPos[] = { <span class="cpp-number">1</span>.0f, <span class="cpp-number">5</span>.0f, <span class="cpp-number">2</span>.0f, <span class="cpp-number">3</span>.0f };<br>    GLfloat fScale = <span class="cpp-number">0</span>.01f;<br>monkey = <span class="cpp-keyword">new</span> CModel3DS(<span class="cpp-literal">"monkey.3ds"</span>);<br>    glClearColor(<span class="cpp-number">1</span>.<span class="cpp-number">0</span>, <span class="cpp-number">1</span>.<span class="cpp-number">0</span>, <span class="cpp-number">1</span>.<span class="cpp-number">0</span>, <span class="cpp-number">0</span>.<span class="cpp-number">0</span>);<br>glShadeModel(GL_SMOOTH);<br><br>    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);<br><br>    glEnable(GL_DEPTH_TEST);<br>    glEnable(GL_CULL_FACE);<br>    <br>   glGenTextures(<span class="cpp-number">2</span>, textureObjects);<br>glBindTexture(GL_TEXTURE_2D, textureObjects[BODY_TEXTURE]);<br>    pBytes = gltLoadTGA(<span class="cpp-literal">"jeep1.tga"</span>, &amp;iWidth, &amp;iHeight, &amp;iComponents, &amp;eFormat);    <br>    glTexImage2D(GL_TEXTURE_2D, <span class="cpp-number">0</span>, iComponents, iWidth, iHeight, <span class="cpp-number">0</span>, eFormat, GL_UNSIGNED_BYTE, (<span class="cpp-keyword">void</span> *)pBytes);<br>    free(pBytes);<br>    <br><br><br><span class="cpp-comment">// Enable lighting and set the position of the light</span><br> glEnable(GL_TEXTURE_2D);<br>glEnable(GL_TEXTURE_GEN_S);<br>glEnable(GL_TEXTURE_GEN_T);<br>glEnable(GL_TEXTURE_GEN_R);<br><br><span class="cpp-comment">// Set up lighting</span><br>    glEnable(GL_LIGHTING);<br>    glEnable(GL_LIGHT0);<br>    glEnable(GL_COLOR_MATERIAL);<br>    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);<br>    glMaterialfv(GL_FRONT, GL_SPECULAR, fDiffLight);<br>    glMateriali(GL_FRONT, GL_SHININESS, <span class="cpp-number">128</span>);<br>    <br>    glLightfv(GL_LIGHT0, GL_AMBIENT, fAmbLight);<br>    glLightfv(GL_LIGHT0, GL_DIFFUSE, fDiffLight);<br>    glLightfv(GL_LIGHT0, GL_SPECULAR, fSpecLight);<br>    glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);<br><br>    <span class="cpp-comment">// Light never changes, put it here</span><br>    glLightfv(GL_LIGHT0, GL_POSITION, lightPos);<br>    <br><span class="cpp-comment">// Generate Vertex Buffer Objects</span><br>monkey-&gt;CreateVBO();<br>glColor3ub(<span class="cpp-number">0</span>,<span class="cpp-number">0</span>,<span class="cpp-number">0</span>);<br>}<br><br></pre></div><!–ENDSCRIPT–><br><br>And I`ve problem with render texture… I don`t know how do it…<br>I tried use <b>glBindTexture(GL_TEXTURE_2D, 0);</b> but it don`t help…