22 for(
int x= 0; x < 10; x++)
24 float px= (float) x - 5.f + 0.5f;
29 for(
int z= 0; z < 10; z++)
31 float pz= (float) z - 5.f + 0.5f;
43 Pad( ) :
App(1024, 640) {}
51 m_grid.bounds(pmin, pmax);
52 m_camera.lookat(pmin, pmax);
57 glClearColor(0.2f, 0.2f, 0.2f, 1.f);
61 glEnable(GL_DEPTH_TEST);
64 if(!m_gamepads.create())
75 glDeleteTextures(1, &m_texture);
82 int update(
const float time,
const float delta )
92 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
95 update_camera( m_camera );
97 static float position= 0;
99 float speed= m_gamepads.pad(0).axis(SDL_CONTROLLER_AXIS_TRIGGERLEFT);
100 position= position + speed;
102 static float rotation= 0;
104 float angle= m_gamepads.pad(0).axis(SDL_CONTROLLER_AXIS_RIGHTX);
105 rotation= rotation + angle;
109 draw(m_grid, m_camera);
110 draw(m_objet, m_model, m_camera, m_texture);
115 if(m_gamepads.pad(0).button(SDL_CONTROLLER_BUTTON_BACK))
131int main(
int argc,
char **argv )
int run()
execution de l'application.
App(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.
unsigned int vertex(const vec3 &p)
insere un sommet de position p, et ses attributs (s'ils sont definis par color(), texcoord(),...
representation de la camera, type orbiter, placee sur une sphere autour du centre de l'objet.
int init()
a deriver pour creer les objets openGL. renvoie -1 pour indiquer une erreur, 0 sinon.
int render()
a deriver pour afficher les objets. renvoie 1 pour continuer, 0 pour fermer l'application.
int update(const float time, const float delta)
a deriver et redefinir pour animer les objets en fonction du temps.
int quit()
a deriver pour detruire les objets openGL. renvoie -1 pour indiquer une erreur, 0 sinon.
float global_time()
renvoie le temps ecoule depuis le lancement de l'application, en millisecondes.
Transform RotationX(const float a)
renvoie la matrice representation une rotation de angle degree autour de l'axe X.
Transform RotationY(const float a)
renvoie la matrice representation une rotation de a degree autour de l'axe Y.
Transform Translation(const Vector &v)
renvoie la matrice representant une translation par un vecteur.
Mesh read_mesh(const char *filename)
charge un fichier wavefront .obj et renvoie un mesh compose de triangles non indexes....
GLuint read_texture(const int unit, const char *filename, const GLenum texel_type)
representation d'un point 3d.