do i have to do something with my bmp file and visual c++ ?
And can you tell me why GL_TRIANGLE_FAN works here and not GL_TRIANGLES ?
#include <gl\GLAUX.h>
#include <gl\glut.h>
#include <gl\gl.h>
GLuint texname[1] ;
void init ()
{
AUX_RGBImageRec *texture1;
texture1 = auxDIBImageLoad(“D:\programmation\[Mes programmes Open GL]\Logo.bmp”);
glGenTextures (1, texname) ;
glBindTexture (GL_TEXTURE_2D, texname[0]) ;
glTexImage2D(GL_TEXTURE_2D, 0, 3, (texture1)->sizeX, (texture1)->sizeY,
0, GL_RGB, GL_UNSIGNED_BYTE, (texture1)->data);
glEnable(GL_TEXTURE_2D) ;
}
void reshape (int w, int h)
{
glViewport (0, 0, w, h) ;
glMatrixMode (GL_PROJECTION) ;
glLoadIdentity () ;
glFrustum(-5.0 , 5.0, -15.0, 5.0, 5.0, 500.0); //perspective conique
glMatrixMode(GL_MODELVIEW); //la matrice active de modelisation/visualisation sera affectée
glLoadIdentity(); //charge la matrice identitégluLookAt (0.0, 0.0, -5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) ;
}void display ()
{//glPolygonMode (GL_FRONT_AND_BACK, GL_LINE) ;
glClear (GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT ) ;
glBindTexture (GL_TEXTURE_2D, texname[0]) ;
glBegin (GL_TRIANGLE_FAN) ;
glTexCoord2f(1.0, 0.0) ; glVertex3f (-1.0, -1.0, 0.0) ;//les coordonnées sont fausses, corrigez les
glTexCoord2f(1.0, 1.0) ; glVertex3f (-1.0, 1.0, 0.0) ;
glTexCoord2f(0.0, 1.0) ; glVertex3f (1.0, 1.0, 0.0) ;
glTexCoord2f(0.0, 0.0) ; glVertex3f (1.0, -1.0, 0.0) ;
glEnd () ;glutSwapBuffers() ;
}
void main (int argc, char** argv)
{//cout<<"hello"<<endl ; glutInit (&argc, argv) ; glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) ; glutInitWindowSize (640, 480) ; glutInitWindowPosition (250,250) ; glutCreateWindow (argv [0]) ; glEnable( GL_DEPTH_TEST ); init () ; glutReshapeFunc (reshape) ; glutDisplayFunc (display) ; glutMainLoop () ;
}