Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Displaying Texture Proccess

Hybrid View

  1. #1
    Newbie Newbie
    Join Date
    Nov 2012
    Posts
    1

    Displaying Texture Proccess

    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...?

    Code :
    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 !

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    Are you getting no texturing or nothing rendering? You code does not show how your view and projection matrices are being set.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •