Hello
I’m trying to draw an image using textures.
But somehow it doesn’t draw the image
I’ve got this init code:
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_FLAT);
QImage plaatje;
plaatje.load("plaatje.png");
cout << "Width: " << plaatje.width() << endl;
cout << "Height: " << plaatje.height() << endl;
cout << "Pixels: " << plaatje.bits() << endl;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, plaatje.width(), plaatje.height(), 0, GL_RGB, GL_UNSIGNED_BYTE, plaatje.bits());
glEnable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
drawing code:
glBindTexture(GL_TEXTURE_2D, tex);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBegin(GL_QUADS);
/*glTexCoord2f(0.0, 0.0);*/ glVertex2f(-2.5, -2.5);
/*glTexCoord2f(0.0, 1.0);*/ glVertex2f(-2.5, 2.5);
/*glTexCoord2f(1.0, 1.0);*/ glVertex2f(2.5, 2.5);
/*glTexCoord2f(1.0, 0.0);*/ glVertex2f(2.5, -2.5);
glEnd();
QT seems to load the image perfectly(it shows the right width, height and probably the pixels too).
The width and height of the image can be divided by 2.
It will probably some stupid line that i forgot or something similar, but i can’t find.
So can somebody please help me, and say what’s the problem?
Thanx #ma*