   Textures in OpenGL
  Argh..I've been trying to get this to work for over two hours now, and I just can't see what the problem is..This code is basically NeHe's sixth tutorial using SFML instead of WinAPI#include <SFML/Graphics.hpp>void InitGL();void ResizeWindow(GLsizei, GLsizei);void DrawScene();void LoadTextures();GLfloat xrot = 0.0f;GLfloat yrot = 0.0f;GLfloat zrot = 0.0f;GLuint textures[1];int main(){sf::RenderWindow app(sf::VideoMode(800, 600, 32), "OpenGL Test 1");app.PreserveOpenGLStates(true);ResizeWindow(800, 600);LoadTextures();InitGL();bool quit = false;while(!quit){sf::Event e;while(app.GetEvent(e)){if(e.Type == sf::Event::Closed)quit = true;else if(e.Type == sf::Event::Resized)ResizeWindow(e.Size.Width, e.Size.Height);}DrawScene();app.Display();}return 0;}void InitGL(){glEnable(GL_TEXTURE_2D);glShadeModel(GL_SMOOTH);glClearColor(0.0f, 0.0f, 0.0f, 0.5f);glClearDepth(1.0f);glEnable(GL_DEPTH_TEST);glDepthFunc(GL_LEQUAL);glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);}void ResizeWindow(GLsizei width, GLsizei height){if(height == 0)height = 1;glViewport(0, 0, width, height);glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(45.0f, GLfloat(width)/GLfloat(height), 0.1f, 100.0f);glMatrixMode(GL_MODELVIEW);glLoadIdentity();}void LoadTextures(){sf::Image img;if(!img.LoadFromFile("texture.bmp"))throw 1;glGenTextures(1, textures);glBindTexture(GL_TEXTURE_2D, textures[0]);glTexImage2D(GL_TEXTURE_2D, 0, 3, img.GetWidth(), img.GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, img.GetPixelsPtr());glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);}void DrawScene(){glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);glLoadIdentity();glTranslatef(0.0f, 0.0f, -5.0f);glRotatef(xrot, 1.0f, 0.0f, 0.0f);glRotatef(yrot, 0.0f, 1.0f, 0.0f);glRotatef(zrot, 0.0f, 0.0f, 1.0f);glBindTexture(GL_TEXTURE_2D, textures[0]);glBegin(GL_QUADS);// Front 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// 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 QuadglEnd();xrot += 0.05f;yrot += 0.05f;zrot += 0.05f;}I'm supposed to get a cube with an image mapped to each of its faces. The image is 128 pixels by 128 pixels wide.However, what I get is this:http://img193.imageshack.us/img193/4276/openglhelp.pngA bunch of lines drawn on the faces of the cube instead of the required texture. It doesn't matter what the original image contains, even if its just colored red, this is what I see. If the image is purely white however, I get a white cube.Edit: It's worth mentioning that the sample code for OpenGL with SFML given with the SFML SDK works just fine.   
  Try changingglBindTexture(GL_TEXTURE_2D, textures[0]);glTexImage2D(GL_TEXTURE_2D, 0, 3, img.GetWidth(), img.GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, img.GetPixelsPtr());glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);to:glBindTexture(GL_TEXTURE_2D, textures[0]);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);glTexImage2D(GL_TEXTURE_2D, 0, 3, img.GetWidth(), img.GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, img.GetPixelsPtr());(Notice the Parameter lines have moved.Also, you're not accounting for if the image has an Alpha channel, you need to be careful about this as it will cause all sorts of issues if you're not expecting it.;  I tried changing the order of the lines as you suggested but nope, still the same problem.[strike]How do I account for an image with an alpha channel?[/strike]Edit:Aha!I simply changedglTexImage2D(GL_TEXTURE_2D, 0, 3, img.GetWidth(), img.GetHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, img.GetPixelsPtr());toglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.GetWidth(), img.GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, img.GetPixelsPtr());And it worked perfectly!Thanks for your alpha channel suggestion!   