Salut à tous et à toutes;
Alors voilà, je m´était attaqué à un petit problème que j´ai presque réussi mais il me reste un truc à régler :
----
void initGL2D(int left, int top, int right, int bottom)
{
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho( left, right, bottom, top, 0, 100 ) ;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
. ..
while(!bQuit)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,1,1);
initGL2D(0,0,640,480);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
glRotatef(angle,0.0f,0.0f,1.0f);
glTranslatef(
glBegin(GL_QUADS);
glColor3ub(0,0,125); glVertex2i(x,y+50);
glColor3ub(0,0,125); glVertex2i(x+50,y+50);
glColor3ub(255,255,255); glVertex2i(x+50,y);
glColor3ub(255,255,255); glVertex2i(x,y);
glEnd();
glPopMatrix();
SDL_GL_SwapBuffers();
keystate = SDL_GetKeyState(NULL);
if ( keystate[SDLK_RIGHT])
{
angle += PI/50;
}
if ( keystate[SDLK_LEFT])
{
angle -= PI/50;
}
if ( angle>359)angle=0;
if ( angle<0)angle=359;
if ( keystate[SDLK_UP])
{
vitesse=1;
}
x+=vitesse*cos(angle);
y+=vitesse*sin(angle);
vitesse=0;
eventloop();
sync_fps(20);
}
quit();
}
---
Donc voici le problème :
Mon quad tourne autour du point de coordonnées ( 0,0). Comment faire pour qu´il tourne autour de son centre ?
J´ajoute que je débute en OpenGL
Merci et
@+
Vengeur