Hi all,
here is a snip of my code:
#include “main.h”
int main(int argc, char **argv){
SDL_Surface *screen,*sinfo,*sdialogue,*sdisplay,*szoom;
SDL_Rect rinfo,rdialogue,rdisplay,rzoom;
SDL_Event test_event;
atexit(SDL_Quit);
/* initialize video */
if((SDL_Init(SDL_INIT_VIDEO)==-1))
printf("Could not initialize SDL: %s.\n", SDL_GetError());
exit(-1);
}
/* do the stuff as long as we have to */
test_event.type=SDL_KEYDOWN;
SDL_PushEvent(&test_event);
/* prepare the screen */
screen=SDL_SetVideoMode(640,480,8,SDL_HWPALETTE);
if(!screen){
printf(“video mode error %s\n”,SDL_GetError());
exit(-1);
}
sdisplay = SDL_CreateRGBSurface(SDL_HWSURFACE,410,410,8,0,0,0,0);
if(!sdisplay){
printf(“video mode error %s\n”,SDL_GetError());
exit(-1);
}
sdialogue=SDL_CreateRGBSurface(SDL_HWSURFACE,410,70,8,0,0,0,0);
if(!sdialogue){
printf(“video mode error %s\n”,SDL_GetError());
exit(-1);
}
sinfo=SDL_CreateRGBSurface(SDL_HWSURFACE,230,480,8,0,0,0,0);
if(!sinfo){
printf(“video mode error %s\n”,SDL_GetError());
exit(-1);
}
szoom=SDL_CreateRGBSurface(SDL_HWSURFACE,128,128,8,0,0,0,0);
if(!szoom){
printf(“video mode error %s\n”,SDL_GetError());
exit(-1);
}
rdisplay.x=0; rdisplay.y=0;
rdisplay.w=410; rdisplay.h=410;
rdialogue.x=0; rdialogue.y=411;
rdialogue.w=410; rdialogue.h=70;
rinfo.x=411; rinfo.y=0;
rinfo.w=230; rinfo.h=480;
rzoom.x=461; rzoom.y=176;
rzoom.w=128; rzoom.h=128;
/* fill the different screen with a color */
SDL_FillRect(sdisplay,NULL,25);
SDL_FillRect(sdialogue,NULL,140);
SDL_FillRect(sinfo,NULL,240);
SDL_FillRect(szoom,NULL,80);
/* blit those screens onto the main screen */
SDL_BlitSurface(sdisplay,NULL,screen,&rdisplay);
SDL_BlitSurface(sdialogue,NULL,screen,&rdialogue);
SDL_BlitSurface(sinfo,NULL,screen,&rinfo);
SDL_BlitSurface(szoom,NULL,screen,&rzoom);
SDL_Flip(screen);
SDL_ShowCursor(0);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
while(1){
while(SDL_PollEvent(&test_event)){
switch(test_event.type){
case SDL_KEYDOWN:{
switch(test_event.key.keysym.sym){
case SDLK_ESCAPE: test_event.type = SDL_QUIT;
SDL_PushEvent(&test_event); break;
}
}
break;
case SDL_QUIT:{
exit(0);
}
break;
default: break;
}
}
}
exit(0);
}
EOF
The goal is to create a main SDL_Surface called screen but do all my work on
the different subscreen (sdisplay, sdialogue, sinfo and szoom) and simply
blit those SDL_Surfaces on the main one, at precise, set, coordinates.
Try to compile the source I put and see what happens… NOTHING!
Anyone can be of some help??
I have a gut feeling the SDL_Fill doesn’t do its jobs on this one.
Thanks for your help
Aurelien