a deriver pour afficher les objets.
84 {
85 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
86
87
88 GLuint zero= 0;
89 glClearTexImage(m_texture, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, &zero);
90
91
92 static bool zinit= false;
94 {
96 zinit= !zinit;
97
98 if(zinit)
100 else
101 printf(
"Z prepass off\n");
102 }
103
104 static bool cull= true;
106 {
108
109 cull= !cull;
110 if(cull)
111 glEnable(GL_CULL_FACE);
112 else
113 glDisable(GL_CULL_FACE);
114
115 if(cull)
116 printf(
"face culling ON\n");
117 else
118 printf(
"face culling off\n");
119 }
120
121 static bool early_tests= false;
122 static const char *early_tests_definition= "";
123 static bool reload= false;
125 {
127
128 early_tests= !early_tests;
129 if(early_tests)
130 early_tests_definition= "#define EARLY_TESTS";
131 else
132 early_tests_definition= "#undef EARLY_TESTS";
133 reload= true;
134
135 if(early_tests)
136 printf(
"early fragment tests ON\n");
137 else
138 printf(
"early fragment test off\n");
139 }
140
142 {
143 reload= false;
145
146 reload_program(m_program, early_tests_definition);
148
149 reload_program(m_program_display);
151 }
152
153
155 Transform view= m_camera.view();
157 Transform mv= view * model;
158 Transform mvp= projection * mv;
159
160
161 if(zinit)
162 {
163 draw(m_mesh, model, view, projection);
164 }
165
166
167 glUseProgram(m_program);
168 program_uniform(m_program, "mvpMatrix", mvp);
169
170
171 glBindImageTexture(0, m_texture, 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32UI);
172 program_uniform(m_program, "image", 0);
173
174 m_mesh.draw(m_program);
175
177 {
178
179 glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
180
181
182 glUseProgram(m_program_display);
183 program_uniform(m_program_display, "image", 0);
184
185 glDrawArrays(GL_TRIANGLES, 0, 3);
186 }
187
188
189 update_camera( m_camera );
190
191 return 1;
192 }
void clear_key_state(const SDL_Keycode key)
desactive une touche du clavier.
void printf(Text &text, const int px, const int py, const char *format,...)
affiche un texte a la position x, y. meme utilisation que printf().
int key_state(const SDL_Keycode key)
renvoie l'etat d'une touche du clavier. cf la doc SDL2 pour les codes.
float global_time()
renvoie le temps ecoule depuis le lancement de l'application, en millisecondes.
Transform RotationY(const float a)
renvoie la matrice representation une rotation de a degree autour de l'axe Y.