   texture mapping (did not show)
  I try to study by myself how to make texture mapping in OpenGl.I think it should be ok but the texture wasn't shown up.I checked that texture id is exist which means texture was sucessfully loaded.but why it doesn't show??#define WIDTH (500)#define HEIGHT (500)GLuint texture;GLuint LoadTextureRAW( const char * filename ){    int width, height;    GLubyte *data =0;    FILE *file=NULL;    // open texture data    file = fopen( filename, "rb" );if ( file == NULL ) {printf("no texture\n");return 0;} // allocate buffer    width = 256;    height = 256;   data = (GLubyte*)malloc(width * height * 3);   // read texture data    fread( data, width * height * 3, 1, file );    fclose( file );  // allocate a texture name  glGenTextures( 1, &texture );  glBindTexture( GL_TEXTURE_2D, texture);    glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST );    glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );  gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width, height,   GL_RGB, GL_UNSIGNED_BYTE, data );    // free buffer    free( data );printf("texture num:%d\n",texture);    return texture;}void drawCube(void){ glPushMatrix();glTranslatef(0,0,0);glRotatef(0, 1.0, 0.0, 0.0);    glBindTexture (GL_TEXTURE_2D, texture);glBegin(GL_QUADS);glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);// Top Left Of The Texture and Quad// Back FaceglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);// Bottom Left Of The Texture and Quad// Top FaceglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f,  1.0f,  1.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f,  1.0f,  1.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);// Top Right Of The Texture and Quad// Bottom FaceglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);// Bottom Right Of The Texture and Quad// Right faceglTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, -1.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f, -1.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);// Top Left Of The Texture and QuadglTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);// Bottom Left Of The Texture and Quad// Left FaceglTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, -1.0f);// Bottom Left Of The Texture and QuadglTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);// Bottom Right Of The Texture and QuadglTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);// Top Right Of The Texture and QuadglTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);// Top Left Of The Texture and Quad    glEnd();glPopMatrix();glDisable (GL_TEXTURE_2D);    }}void display(void){glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glClearColor(1.0f, 1.0f, 1.0f, 0.5f); glEnable (GL_LIGHTING);glEnable (GL_LIGHT0);glEnable ( GL_COLOR_MATERIAL ) ;glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);glEnable(GL_DEPTH_TEST); glViewport(0, 0,WIDTH,HEIGHT);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(90,   (GLfloat)WIDTH/(GLfloat)HEIGHT, 1.0, 50.0);glMatrixMode(GL_MODELVIEW);glLoadIdentity();gluLookAt(0, 0, -50, 1, 0, 0,0.0, 1.0, 0.0);   drawCube();glFlush();glutSwapBuffers();}int InitGL(GLvoid){if (!LoadTextureRAW("0.bmp")){printf("cannot load Texture\n");return false;}glEnable(GL_TEXTURE_2D);glShadeModel(GL_SMOOTH);glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);glDepthFunc(GL_LEQUAL);glDepthFunc(GL_LEQUAL);glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);return true;}int main(int argc, char **argv){glutInit(&argc, argv);glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);glutInitWindowSize (WIDTH, HEIGHT);glutInitWindowPosition (100, 100);glutCreateWindow("cube");InitGL();glutDisplayFunc(display);glutMainLoop();  return 0;}
  What do you see? Be more specific. Does your application work without texturing?   ;Quote:Original post by karwostsWhat do you see? Be more specific. Does your application work without texturing?yes, everything fine except texture.I got white cube.Just white cube....so the texture is missing   ;  u disable Texture2D in your cube draw call at the endbut only enable it once at the initialisation^^;Quote:Original post by Danny02u disable Texture2D in your cube draw call at the endbut only enable it once at the initialisation^^thanks for your help.Now texture is shown but it doesn't cover the whole face.It shows just 1/3 size of the face.And the color of texture is not right.Just kind of white color,....(real color is brown)so what is this problem?   ;  Are you sure your lighting is correct? You should disable all lighting stuff until you're sure you have everything else working correctly. That will just add more debugging headaches.   