GLProgramming.com

home :: about :: development guides :: irc :: forums :: search :: paste :: links :: contribute :: code dump

-> Click here to learn how to get live help <-


New Paste :: Recent Pastes:: Add Line Numbers


A Paste by Iridium
glGenTextures( 1, &texNum );

glBindTexture( GL_TEXTURE_2D, texNum );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );

imagePixels = malloc( pow2H * pow2W * 3 );
assert( imagePixels != NULL );
memset( imagePixels, 0, sizeof(byte) * pow2H * pow2W * 3 );

glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, pow2W, pow2H, 0, GL_RGB, GL_UNSIGNED_BYTE, imagePixels );

free( imagePixels );

glBegin( GL_QUADS );
glColor4f( 1, 1, 1, 1 );
glTexCoord2f(0, 0); glVertex3f( -1, -1, 0 );
glTexCoord2f(1, 0); glVertex3f( 1, -1, 0 );
glTexCoord2f(1, 1); glVertex3f( 1, 1, 0 );
glTexCoord2f(0, 1); glVertex3f( -1, 1, 0 );
glEnd();

SwapBuffers( hDC );

glDeleteTextures( 1, &texNum );