why dont this simple ass sdl code work?

it runs but it doesnt show any images!!

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
SDL_Surface *screen = NULL;
//SDL_Surface *leftclips = NULL;
//SDL_Surface *rightclips = NULL;

int SCREEN_WIDTH=560;
int SCREEN_HEIGHT=340;
int SCREEN_BPP = 32;

SDL_Event event;

SDL_Rect clipsRight[ 10 ];
SDL_Rect clipsLeft[ 10 ];
SDL_Rect clipsRightthrow[ 5 ];
SDL_Rect clipsLeftthrow[ 5 ];

bool quit = false;

bool init()
{
    if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
    {
        return false;
    }
    screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
    if( screen == NULL )
    {
        return false;
    }
    SDL_WM_SetCaption( "Animation Test", NULL );
    return true;
}
SDL_Surface *leftclips = load_image("cd.bmp");
SDL_Surface *rightclips = load_image("daegclipsright.png");


int main ( int argc, char** argv )
{
init();
apply_surface(SCREEN_WIDTH,SCREEN_HEIGHT,leftclips,screen);


SDL_Flip(screen);
SDL_Delay (3000);

    return 0;
}

Haven't used SDL in a long while, but where are you blitting the image onto the surface? Is that apply_surface your own function?
yeah its in applyimage, its identical to lazy foos, thats where its blitting
Last edited on
Post the code for apply_surface()
You are calling load_image before you have initialized SDL.
ooh yeah again dumb thank you peter, but it still dont work here.

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
bool init()
{
    if( SDL_Init( SDL_INIT_EVERYTHING ) == -1 )
    {
        return false;
    }
    screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
    if( screen == NULL )
    {
        return false;
    }
    SDL_WM_SetCaption( "Animation Test", NULL );
    return true;
}


int main ( int argc, char** argv )
{
init();
SDL_Surface *leftclips = load_image("daegclipleft.png");
SDL_Surface *rightclips = load_image("daegclipsright.png");

apply_surface(SCREEN_WIDTH,SCREEN_HEIGHT,leftclips,screen);


SDL_Flip(screen);
SDL_Delay (3000);
apply_surface(SCREEN_WIDTH,SCREEN_HEIGHT,rightclips,screen);
SDL_Flip (screen);
SDL_Delay (3000);

    return 0;
}


i should have a hotkey that just sends you sdl problems, you solve em all.
Last edited on
You are drawing the images outside the screen.
yep :D
Topic archived. No new replies allowed.