25 Quads(
const char *filename ) :
AppTime(1024, 640, 4,4)
33 if(m_mesh.vertex_count() == 0)
37 m_mesh.bounds(pmin, pmax);
38 m_camera.lookat(pmin, pmax);
47 m_program_display=
read_program(
"gkit2_tutos/M2/quads_display.glsl");
51 glClearColor(0.2f, 0.2f, 0.2f, 1.f);
54 glDepthFunc(GL_LEQUAL);
55 glEnable(GL_DEPTH_TEST);
59 glEnable(GL_CULL_FACE);
70 glDeleteTextures(1, &m_texture);
77 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
81 glClearTexImage(m_texture, 0, GL_RED_INTEGER, GL_UNSIGNED_INT, &zero);
84 static bool zinit=
false;
96 static bool cull=
true;
103 glEnable(GL_CULL_FACE);
105 glDisable(GL_CULL_FACE);
108 printf(
"face culling ON\n");
110 printf(
"face culling off\n");
113 static bool early_tests=
false;
114 static const char *early_tests_definition=
"";
115 static bool reload=
false;
120 early_tests= !early_tests;
122 early_tests_definition=
"#define EARLY_TESTS";
124 early_tests_definition=
"#undef EARLY_TESTS";
128 printf(
"early fragment tests ON\n");
130 printf(
"early fragment test off\n");
138 reload_program(m_program, early_tests_definition);
141 reload_program(m_program_display);
155 draw(m_mesh, model, view, projection);
159 glUseProgram(m_program);
160 program_uniform(m_program,
"mvpMatrix", mvp);
163 glBindImageTexture(0, m_texture, 0, GL_TRUE, 0, GL_READ_WRITE, GL_R32UI);
164 program_uniform(m_program,
"image", 0);
166 m_mesh.draw(m_program);
171 glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
174 glUseProgram(m_program_display);
175 program_uniform(m_program_display,
"image", 0);
177 glDrawArrays(GL_TRIANGLES, 0, 3);
181 update_camera( m_camera );
191 GLuint m_program_display;
196int main(
int argc,
char **argv )
198 const char *filename=
"data/bigguy.obj";
206 Quads app( filename );
AppTime(const int width, const int height, const int major=3, const int minor=3)
constructeur, dimensions de la fenetre et version d'openGL.
representation d'un objet / maillage.
representation de la camera, type orbiter, placee sur une sphere autour du centre de l'objet.
int quit()
a deriver pour detruire les objets openGL.
int render()
a deriver pour afficher les objets.
int init()
a deriver pour creer les objets openGL.
bool window_resize()
renvoie vrai si la fenetre peut etre redimensionnee.
int window_height()
renvoie la hauteur de la fenetre de l'application.
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.
int window_msaa()
renvoie le nombre de samples MSAA.
int window_width()
renvoie la largeur de la fenetre de l'application.
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.
Mesh read_mesh(const char *filename)
charge un fichier wavefront .obj et renvoie un mesh compose de triangles non indexes....
GLuint read_program(const char *filename, const char *definitions)
int program_print_errors(const GLuint program, const char *filename)
affiche les erreurs de compilation.
int release_program(const GLuint program)
GLuint make_uint_texture(const int unit, const int width, const int height, const GLenum texel_type)
creation de textures pour stocker des donnees (autres qu'une couleur).
representation d'un point 3d.