PDA

View Full Version : Displaying Texture Proccess



arkantos
11-22-2012, 10:28 AM
Hello guys, i am trying to display a pgm image which i have loaded into a 2D array of GLubytes. Bellow you can see my code and the output is a 40x40 white box. No texture appeared :| Can anyone help me with this caz i really have no other ideas...?



glGenTextures( 1, &texture );

glBindTexture( GL_TEXTURE_2D, texture );

glTexImage2D(GL_TEXTURE_2D, 0, 256, 40, 40, 0, GL_RED, GL_UNSIGNED_BYTE, img); // img 2 d array with the image

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

glBindTexture( GL_TEXTURE_2D, texture );

glEnable(GL_TEXTURE_2D);
/*glBegin(GL_LINES);
glVertex2i(0, 0);
glVertex2i(1, 40);
glEnd();*/

glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(30,30, 0);
glTexCoord2f(0.0, 1.0); glVertex3f(30,70, 0);
glTexCoord2f(1.0, 1.0); glVertex3f(70,70, 0);
glTexCoord2f(1.0, 0.0); glVertex3f(70,30, 0);
glEnd();
glDisable(GL_TEXTURE_2D);


thanks !

tonyo_au
11-22-2012, 03:21 PM
Are you getting no texturing or nothing rendering? You code does not show how your view and projection matrices are being set.