void ViewerOGL::initializeGL(){
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Efface en noir
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST ); // Autorise le test de profondeur
glDepthFunc(GL_LEQUAL);
glFrontFace(GL_CCW ); // Normale dans le sens horaire
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glShadeModel(GL_SMOOTH); // Autorise anti-aliasing
glEnable(GL_CULL_FACE ); // Face arriere cache
glEnable(GL_LIGHT0); // Active la 1ere lampe
glEnable(GL_COLOR_MATERIAL); // Autorise les materiaux
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); // Autorise l'affichage
glNewList(1, GL_COMPILE);
GLuint nuId;
glGenTextures(1, &nuId); // ID OpenGL sur la texture
glBindTexture(GL_TEXTURE_2D, nuId);
glTexImage2D(GL_TEXTURE_2D, 0, 4, tex.width(), tex.height(), 0, GL_RGBA,GL_UNSIGNED_BYTE, tex.bits());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glEnable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLES);
glTexCoord2f(0, 0);
glNormal3f(0, 0, 1);
glVertex3f(0, 0, 0);
glTexCoord2f(1, 0);
glNormal3f(0, 0, 1);
glVertex3f(200, 0, 0);
glTexCoord2f(0.5, 1);
glNormal3f(0, 0, 1);
glVertex3f(100, 200, 0);
glEnd();
glDisable(GL_TEXTURE_2D);
glEndList();
}
void ViewerOGL::initializeGL(){
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Efface en noir
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST ); // Autorise le test de profondeur
glDepthFunc(GL_LEQUAL);
glFrontFace(GL_CCW ); // Normale dans le sens horaire
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glShadeModel(GL_SMOOTH); // Autorise anti-aliasing
glEnable(GL_CULL_FACE ); // Face arriere cache
glEnable(GL_LIGHT0); // Active la 1ere lampe
glEnable(GL_COLOR_MATERIAL); // Autorise les materiaux
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); // Autorise l'affichage
glNewList(1, GL_COMPILE);
QImage img("C:\\test.png");
QImage tex;
tex = QGLWidget::convertToGLFormat(img);
GLuint nuId;
glGenTextures(1, &nuId); // ID OpenGL sur la texture
glBindTexture(GL_TEXTURE_2D, nuId);
glTexImage2D(GL_TEXTURE_2D, 0, 4, tex.width(), tex.height(), 0, GL_RGBA,GL_UNSIGNED_BYTE, tex.bits());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glEnable(GL_TEXTURE_2D);
glBegin(GL_TRIANGLES);
glTexCoord2f(0, 0);
glNormal3f(0, 0, 1);
glVertex3f(0, 0, 0);
glTexCoord2f(1, 0);
glNormal3f(0, 0, 1);
glVertex3f(200, 0, 0);
glTexCoord2f(0.5, 1);
glNormal3f(0, 0, 1);
glVertex3f(100, 200, 0);
glEnd();
glDisable(GL_TEXTURE_2D);
glEndList();
}
To copy to clipboard, switch view to plain text mode
Bookmarks