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
|
Menu2D outil2D; // On déclare le gestionnaire de la 2D
....
void screenInit()
{
setScreen(SDL_SetVideoMode( 640, 480, 16, SDL_HWSURFACE ));
SDL_WM_SetCaption( "Utopia Engine ", NULL);
}
....
void changeBackground(std::string filename)
{
screen_loading = outil2D.load_image(filename.c_str());
if(screen_loading == NULL)
{
printf( "Can't init SDL : %s\n", SDL_GetError() );
}
if(screen == NULL)
{
printf( "Can't init SDL : %s\n", SDL_GetError() );
}
apply_surface( 100,100, screen_loading, screen );
if( SDL_Flip( screen ) == -1 )
{
printf( "Can't init SDL : %s\n", SDL_GetError() );
}
}
...
void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
SDL_Rect offset;
offset.x = x;
offset.y = y;
// On blitte la surface
SDL_BlitSurface( source, NULL, destination, &offset );
} |
Partager