SDL problem

riddick1
Unregistered
 
Post: #1
which function in this code respond for showing picture on the screen
Thanks.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
SDL_BlitSurface
No problem.
Quote this message in a reply
riddick1
Unregistered
 
Post: #3
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
Quote this message in a reply
Moderator
Posts: 700
Joined: 2002.04
Post: #4
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.

Mark Bishop
--
Student and freelance OS X & iOS developer
Quote this message in a reply
Post Reply