bonjour, en fait j'ai un projet a faire en opengl 3D mais ca marche pas. en fait j'essaye au début de créer un espace 3D ou je vais construire une maison. voici le code quand j'execute j'ai la page bleu.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
 
/*  Fonctions Prototypes  */
 
GLvoid Initialize( char * );
GLvoid DrawScene( GLvoid );
GLvoid DrawGrid(GLfloat * , GLfloat *);
GLvoid DrawAxes(GLvoid);
GLvoid DrawCube(GLvoid);
GLvoid Resize( GLsizei , GLsizei );
 
/* Variables globales definissant les couleurs
   ------------------------------------------- */
 
GLfloat White[]={1.,1.,1.};
GLfloat Black[]={0.,0.,0.};
GLfloat Red[]={1.,0.,0.};
GLfloat Green[]={0.,1.,0.};
GLfloat Blue[]={0.,0.,1.};
GLfloat Magenta[]={1.,0.,1.};
GLfloat Cyan[]={0.,1.,1.};
GLfloat Yellow[]={1.,1.,0.};
 
/*  Variables globales definissant les dimensions
    --------------------------------------------- */
 
GLfloat Ratio;
GLfloat near = 1.;
GLfloat far = 30.;
GLfloat fovy = 70.;
 
 
/* Programme principal
   ------------------- */
int
main(int argc ,  char ** argv)
{
 
 /* code executable :
   ---------------   */
  glutInit(&argc,argv);
  Initialize(argv[0]);
  glutDisplayFunc(DrawScene);
  glutReshapeFunc( Resize );
  glutMainLoop(); 
  return 0;
}
 
 
GLvoid
Initialize( char * Titre )
{
  GLvoid DefineWindow( char *) ;
 
  glutInitDisplayMode( GLUT_RGBA|GLUT_DEPTH );
 
/* Définition de la fenêtre 
     ------------------------ */
 
  DefineWindow( Titre) ;  
 
 
  /* Definir le monde des coordonnees
     ------------------------------- */
 
  glPointSize(4);
  glLineWidth(2.5);
 
}
 
GLvoid
Resize(GLsizei WindowWidth , GLsizei WindowHeight  )
{
  glViewport( 0, 0,WindowWidth , WindowHeight) ;
 
  Ratio = (GLfloat)  WindowWidth /  WindowHeight;
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(fovy, Ratio,near,far);
  glMatrixMode(GL_MODELVIEW);
}
 
GLvoid DefineWindow( char * Titre)
{
  GLsizei ScreenWidth,ScreenHeight;
 
 
  /* Largeur et hauteur de l'écran
     -------------------------------- */
 
 
/* Largeur et hauteur de l'écran
   ---------------------------------- */
 
   ScreenWidth  = glutGet(GLUT_SCREEN_WIDTH) ;
   ScreenHeight = glutGet(GLUT_SCREEN_HEIGHT);
 
 
/* Definition de la fenetre 
     ------------------------ */
 
  glutInitWindowPosition(ScreenWidth/4,ScreenHeight/4);
  glutInitWindowSize(ScreenWidth/2,ScreenHeight/2);
 
  glutCreateWindow(Titre);
 
/* Definition de la couleur du fond de la fenetre
   ----------------------------------------------- */
 
glClearColor(0.,0.,1.,1.);
 
}
 
 
GLvoid
DrawScene( GLvoid )
{
 
  /* Effacement de la fenetre pour un nouvel affichage
     ------------------------------------------------- */
 
  glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
    glEnable(GL_DEPTH_TEST);
 
 glMatrixMode(GL_MODELVIEW);
 glLoadIdentity();
 glPushMatrix();
  glTranslatef(0.0,0.0,-3.) ;  
  glRotatef(-45.,1.,0.,0);
  /* le sol*/
  glBegin(GL_POLYGON);
    glColor3ub(255,255,255);
    glVertex3d(-15,0,-3);
    glVertex3d(15,0,-3);
    glVertex3d(15,4,-30);
    glVertex3d(-15,4,-30);
 
glPopMatrix();
 
 glFlush();
}