C´est bon jai reglé le probleme, mes links n´étaient pas bons...
autre souci : j´execute le fichier exe, une fenetre console s´affiche 1seconde, puis plus rien, comme si le programme se terminait. le tuto indique que je dois voir un carré blanc qui s´approche... su vous avez une idée du probleme, merci !
voici le code :
- include <windows.h>
- include <GL/gl.h>
- include <GL/glu.h>
- include <SDL/SDL.h>
- include <math.h>
- pragma comment( lib, "opengl32.lib" )
- pragma comment( lib, "glu32.lib" )
SDL_Surface *surface;
float e=0.0;
void Quit( int returnCode )
{
SDL_Quit( );
exit( returnCode );
}
void handleKeyPress( SDL_keysym *keysym )
{
switch ( keysym->sym )
{
case SDLK_ESCAPE:
Quit( 0 );
break;
default:
break;
}
return;
}
int initGL( GLvoid )
{
// init
glShadeModel( GL_SMOOTH );
glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
glClearDepth( 1.0f );
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LEQUAL );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
// cadrage
glViewport( 0, 0,1024,768);
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
gluPerspective( 45.0f, 4.0/3.0, 1.0f, 100.0f );
return 1;
}
int drawGLScene( GLvoid )
{
e+=(float)0.005;
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
gluLookAt(0,0,0,0,0,-1,0,1,0);
glTranslatef( -1.5f, 0.0f, -6.0f );
glBegin( GL_TRIANGLES );
glVertex3f( 0.0f, 1.0f, e );
glVertex3f( -1.0f, -1.0f, e );
glVertex3f( 1.0f, -1.0f, e );
glEnd( );
glTranslatef( 3.0f, 0.0f, 0.0f );
glBegin( GL_QUADS );
glVertex3f( -1.0f, 1.0f, e );
glVertex3f( 1.0f, 1.0f, e );
glVertex3f( 1.0f, -1.0f, e );
glVertex3f( -1.0f, -1.0f, e );
glEnd( );
SDL_GL_SwapBuffers( );
return 1;
}
int main( int argc, char **argv )
{
int done = FALSE;
SDL_Event event;
int isActive = TRUE;
SDL_Init(SDL_INIT_VIDEO);
surface =
SDL_SetVideoMode(1024,768,32,SDL_HWSURFACE|SDL_OPE
NGL);
if ( !s urface )
{
fprintf( stderr, "Video mode set failed: %s\n", SDL_GetError( ) );
Quit( 1 );
}
initGL( );
while ( !d one )
{
while ( SDL_PollEvent( &event ) )
{
switch( event.type )
{
case SDL_KEYDOWN:
handleKeyPress( &event.key.keysym );
break;
case SDL_QUIT:
done = 1;
break;
default:
break;
}
}
drawGLScene( );
}
Quit( 0 );
return( 0 );
}