Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ParadigmShift

OpenGL textures problem

This topic is 5449 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

I used to use OpenGL extensively in Windows, now I''m using DX9 but porting it back to OpenGL on Mandrake 9.2... For some reason textures won''t work. I''m trying to make a simple color pattern. The code is:
  // TEST ONLY BEGIN
  unsigned char *buffer = new unsigned char[256*256*4];
  for (long x=0;x<256;x++)
  for (long y=0;y<256;y++) {
    buffer[x*256*4+y*4] = x;
    buffer[x*256*4+y*4+1] = y;
    buffer[x*256*4+y*4+2] = (x*x+y*y)/256;
    buffer[x*256*4+y*4+3] = 255;
  }

  glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

  glEnable(GL_TEXTURE_2D);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
  // TEST ONLY END
    
   GFXVERTEX *vertices = obj->GetVertices();
   WORD *indices = obj->GetIndices();
      
   glBegin( GL_TRIANGLES );            /* Drawing Using Triangles */
   for (long i=0;inumFaces;i++) {
      glColor3f(1.0, 1.0, 1.0);
      glTexCoord2f(0, 0);
      glVertex3f(vertices[indices[i*3]].x,
                vertices[indices[i*3]].y,
                vertices[indices[i*3]].z);
      glTexCoord2f(0,1);
      glVertex3f(vertices[indices[i*3+1]].x,
                vertices[indices[i*3+1]].y,
                vertices[indices[i*3+1]].z);
      glTexCoord2f(1,0);
      glVertex3f(vertices[indices[i*3+2]].x,
                vertices[indices[i*3+2]].y,
                vertices[indices[i*3+2]].z);
   }
   glEnd( );                       
 
But I just see white triangles. Any ideas? Thanks, Tom

Share this post


Link to post
Share on other sites
Advertisement
glGenTextures/glBindTexture was called at least once before this code was run.

I added the two functions and it still doesn''t work. Has anyone run across a problem like this before?

Tom

Share this post


Link to post
Share on other sites

  • 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!