1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| int main( int argc, char **argv )
{
const SDL_VideoInfo* info = NULL;
int width = 0, height = 0, bpp = 0;
int flags = 0;
fichier_log=fopen("sdl.log", "w");
if( SDL_Init( SDL_INIT_VIDEO ) < 0 )
{
fprintf( fichier_log, "Echec d'initialisation video: %s\n", SDL_GetError( ) );
SDL_quit( 1 );
}
info = SDL_GetVideoInfo( );
if( !info )
{
fprintf( fichier_log, "Erreur dans la demande d'info video: %s\n", SDL_GetError( ) );
SDL_quit( 1 );
}
SDL_WM_SetCaption("Code de base SDL + OpenGL",NULL);
width = 400;
height = 400;
bpp = info->vfmt->BitsPerPixel;
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
flags = SDL_OPENGL|SDL_RESIZABLE ;
if( SDL_SetVideoMode( width, height, bpp, flags ) == 0 )
{
fprintf( fichier_log, "Echec lors du reglage du mode video: %s\n", SDL_GetError( ) );
SDL_quit( 1 );
}
reshape( width, height );
while( 1 )
{
process_events( );
draw_screen( );
}
return 0;
} |
Partager