1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| ***********************
image.load("grille.png") ;
image = QGLWidget::convertToGLFormat(image) ;
************************************
glGenTextures( 1, &texture_name );
glBindTexture( GL_TEXTURE_2D, texture_name);
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, GL_RGBA8, image.width(),
image.height(), 0,GL_RGBA, GL_UNSIGNED_BYTE, image.bits());
********************************************
glClear(GL_COLOR_BUFFER_BIT); //clear color and deph buffer
glEnable (GL_TEXTURE_2D); //allow texture
glBindTexture (GL_TEXTURE_2D, texture_name);
glBegin(GL_QUADS);
//each vertex object is associated to a vertex texture
glTexCoord2f(0.0, 0.0); glVertex2f(-0.5, -0.7);
glTexCoord2f(0.0, 1.0); glVertex2f(-0.5, 0.5);
glTexCoord2f(1.0, 1.0); glVertex2f(0.5, 0.5);
glTexCoord2f(1.0, 0.0); glVertex2f(0.5, -0.5);
glEnd();
**************************** |
Partager