iDevGames Forums
SDL problem - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: SDL problem (/thread-3148.html)



SDL problem - riddick1 - Jul 25, 2007 02:51 AM

which function in this code respond for showing picture on the screen
Thanks.


SDL problem - OneSadCookie - Jul 25, 2007 03:11 AM

SDL_BlitSurface
No problem.


SDL problem - riddick1 - Jul 25, 2007 04:59 AM

Code:
SDL_Surface *obrazek;

obrazek = IMG_Load("obrazek.jpg");
    
    if(obrazek = NULL)
    {
               return 1;
               }
    obrazek = SDL_DisplayFormat(ekran);
    SDL_FreeSurface(ekran);
    
    SDL_Rect dest;
    dest.x = 150;
    dest.y = 200;
    dest.w = obrazek->w;
    dest.h = obrazek->h;
    SDL_SetAlpha( obrazek, SDL_SRCALPHA, 255); // ustawiamy przeźroczystość
    SDL_BlitSurface( obrazek, NULL, ekran, &dest); // FUNKCJA ODPOWIEDZIALANA ZA WSTAWIENIE OBRAZKA NA EKRANIE
    
    SDL_Flip(ekran);

this code responds for loading an image, but this image doesn't show up on the screen


SDL problem - sealfin - Jul 25, 2007 08:47 AM

Well, there are three glaring bugs which may be why your image is not be showing up on the screen:

Code:
if(obrazek [b]=[/b] NULL)
{
return 1;
}

That might be your problem.

Code:
obrazek = SDL_DisplayFormat([b]ekran[/b]);
Or that.

Code:
[b]SDL_FreeSurface(ekran);[/b]
[...]
[b]SDL_Flip(ekran);[/b]

Or that.

N.b. also, depending on the version of SDL you are using, your call to SDL_SetAlpha() could be setting the surface alpha to transparent.