a deriver pour afficher les objets.
82 {
83 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
84
85
86 GLuint zero= 0;
87 glClearTexImage(m_texture, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, &zero);
88
89
90 update_camera( m_camera );
91
92
93 static bool cull= true;
95 {
97
98 cull= !cull;
99 if(cull)
100 glEnable(GL_CULL_FACE);
101 else
102 glDisable(GL_CULL_FACE);
103
104 if(cull)
105 printf(
"face culling ON\n");
106 else
107 printf(
"face culling off\n");
108 }
109
110
111 static bool early_tests= true;
112 static const char *early_tests_definition= "";
113 static bool reload= false;
115 {
117
118 early_tests= !early_tests;
119 if(early_tests)
120 early_tests_definition= "#define EARLY_TESTS";
121 else
122 early_tests_definition= "#undef EARLY_TESTS";
123 reload= true;
124
125 if(early_tests)
126 printf(
"early fragment tests ON\n");
127 else
128 printf(
"early fragment test off\n");
129 }
130
132 {
133 reload= false;
135
136 reload_program(m_program, "gkit2_tutos/tuto_storage_texture.glsl", early_tests_definition);
138
139 reload_program(m_program_display, "gkit2_tutos/storage_texture_display.glsl");
141 }
142
143
144 glUseProgram(m_program);
145
147 Transform view= m_camera.view();
149 Transform mv= view * model;
150 Transform mvp= projection * mv;
151
152 program_uniform(m_program, "mvpMatrix", mvp);
153
154
155 glBindImageTexture(0, m_texture, 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32UI);
156 program_uniform(m_program, "image", 0);
157
158 m_mesh.draw(m_program);
159
161 {
162
163 glUseProgram(m_program_display);
164
165
166 glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
167
168
169 glBindImageTexture(0, m_texture, 0, GL_TRUE, 0, GL_READ_ONLY, GL_R32UI);
170 program_uniform(m_program_display, "image", 0);
171
172 glDrawArrays(GL_TRIANGLES, 0, 3);
173 }
174
175 return 1;
176 }
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.