   [Solved] glTexImage2D issues
  I am trying desperately to texture a simple quad using known examples but I always get a white quad with no texture. I tried creating the texture by myself and still nothing !My initialization is :// Initialize display mode to be double buffered, with RGBA color model and with a depth bufferglutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE  | GLUT_DEPTH);// Initialize window position and sizeglutInitWindowPosition(-1, -1); // OS dependentglutInitWindowSize(500, 400);// Initialize the GLUT libraryglutInit(&argc, args);// Initialize openglglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);glShadeModel(GL_SMOOTH);   glEnable(GL_TEXTURE_2D);// Bind and generate the textureglGenTextures(1, &g_uiTextureId);glBindTexture(GL_TEXTURE_2D, g_uiTextureId);unsigned char *data;data = (unsigned char *)malloc(256 * 256 * 3);   // Should create a red texturefor (int i = 0;  i < 256 * 256 * 3; i += 3) {data = 255;data[i+1] = 0;data[i+2] = 0;}glTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, data);   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); if (glGetError() != GL_NO_ERROR)printf("ERROR!"); // Never reached hereRendering :// Clear drawing buffer and depth bufferglClearColor(0, 0, 0, 0);glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glEnable(GL_TEXTURE_2D);// Reset world matrix and set world position for a triangleglLoadIdentity();glTranslatef(0.0f, 0.0f, -6.0f);glBindTexture(GL_TEXTURE_2D, g_uiTextureId);// Render a textured cubeglBegin(GL_QUADS);// Front faceglTexCoord2f(0.0f, 1.0f);glVertex3f(-1.0f, -1.0f, 0.0f);glTexCoord2f(0.0f, 0.0f);glVertex3f(-1.0f,  1.0f, 0.0f);glTexCoord2f(1.0f, 0.0f);glVertex3f( 1.0f,  1.0f, 0.0f);glTexCoord2f(1.0f, 1.0f);glVertex3f( 1.0f, -1.0f, 0.0f);glEnd();glFlush();// Display frameglutSwapBuffers();thx.[Edited by - DesignerX on June 19, 2009 12:40:17 PM]
  The value 3 (third parameter) is invalid, it should be something like GL_RGB.   ;  try using GL_LINEAR instead of GL_NEAREST for GL_TEXTURE_MIN_FILTER, IIRC GL_NEAREST requires you to specify all mipmap levels.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);   ;Quote:Original post by Riraitotry using GL_LINEAR instead of GL_NEAREST for GL_TEXTURE_MIN_FILTER, IIRC GL_NEAREST requires you to specify all mipmap levels.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);False   ;Quote:Original post by Riraitotry using GL_LINEAR instead of GL_NEAREST for GL_TEXTURE_MIN_FILTER, IIRC GL_NEAREST requires you to specify all mipmap levels.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);No, GL_NEAREST doesn't require mipmaps, GL_NEAREST_MIPMAP_* and GL_LINEAR_MIPMAP_* do.   ;Quote:The value 3 (third parameter) is invalid, it should be something like GL_RGB.Are you sure about that? I believe 1, 2, 3, and 4 are valid values for the 'internal format' argument (unless that's changed in a more recent OpenGL version).   ;Quote:Original post by HuntsManQuote:Original post by Riraitotry using GL_LINEAR instead of GL_NEAREST for GL_TEXTURE_MIN_FILTER, IIRC GL_NEAREST requires you to specify all mipmap levels.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);No, GL_NEAREST doesn't require mipmaps, GL_NEAREST_MIPMAP_* and GL_LINEAR_MIPMAP_* do.Oops o.0 that makes more sense, guess my memory doesn't serve me as well as I thought it did...   ;Quote:Original post by jykQuote:The value 3 (third parameter) is invalid, it should be something like GL_RGB.Are you sure about that? I believe 1, 2, 3, and 4 are valid values for the 'internal format' argument (unless that's changed in a more recent OpenGL version).http://www.opengl.org/wiki/Common_Mistakes#Texture_Precision   ;  Thx for the replies but nothing worked ! this is unbelievable, how can this be so complicated ????? do u have any other suggestions ?thx.[Edit]didnt notice the line that says that i should disable mipmapping in HuntsMan link (a very resourceful page I might add, thx alot)   