ScummVM logo Forum Index - ScummVM website - Contact us - Buy Supported Games: GOG.com Rules - Search - Register - Login curved edge
Folder Forum Index > PocketPC/WinCE Port > Trouble setting up SDL
Trouble setting up SDL
  Author    Thread Reply to topic
saratoga



Joined: 04 Jul 2008
Posts: 5
Trouble setting up SDL 

I'm interested in doing some WinCe development, but I'm having some trouble setting up everything. I've got cegcc installed and it compiles the hello world program nicely, which runs great in the MS WinCE5 emulator.

Next I downloaded the binary SDL lib and header and tried linking against them with a simple sdl program I found on google to make sure they were working with my cegcc:

code:

#include "stdlib.h"
#include "SDL.h"

int main(int argc, char *argv[])
{
   SDL_Surface *screen;   //This pointer will reference the backbuffer
   SDL_Surface *image;   //This pointer will reference our bitmap sprite
   SDL_Surface *temp;   //This pointer will temporarily reference our bitmap sprite
   SDL_Rect src, dest;   //These rectangles will describe the source and destination regions of our blit

   //We must first initialize the SDL video component, and check for success
   if (SDL_Init(SDL_INIT_VIDEO) != 0) {
      printf("Unable to initialize SDL: %s\n", SDL_GetError());
      return 1;
   }

   //When this program exits, SDL_Quit must be called
   atexit(SDL_Quit);

   //Set the video mode to fullscreen 640x480 with 16bit colour and double-buffering
   screen = SDL_SetVideoMode(160, 120, 16, SDL_DOUBLEBUF | SDL_FULLSCREEN);
   if (screen == NULL) {
      printf("Unable to set video mode: %s\n", SDL_GetError());
      return 1;
   }

   //Load the bitmap into a temporary surface, and check for success
   temp = SDL_LoadBMP("image.bmp");
   if (temp == NULL) {
      printf("Unable to load bitmap: %s\n", SDL_GetError());
      return 1;
   }

   //Convert the surface to the appropriate display format
   image = SDL_DisplayFormat(temp);

   //Release the temporary surface
   SDL_FreeSurface(temp);

   //Construct the source rectangle for our blit
   src.x = 0;
   src.y = 0;
   src.w = image->w;   //Use image->w to display the entire width of the image
   src.h = image->h;   //Use image->h to display the entire height of the image

   //Construct the destination rectangle for our blit
   dest.x = 100;      //Display the image at the (X,Y) coordinates (100,100)
   dest.y = 100;
   dest.w = image->w;   //Ensure the destination is large enough for the image's entire width/height
   dest.h = image->h;

   //Blit the image to the backbuffer
   SDL_BlitSurface(image, &src, screen, &dest);

   //Flip the backbuffer to the primary
   SDL_Flip(screen);

   //Wait for 2500ms (2.5 seconds) so we can see the image
   SDL_Delay(5000);

   //Release the surface
   SDL_FreeSurface(image);

   //Return success!
   return 0;
}






code:

mike@biosgroup-desktop:~/sdl/test$ arm-mingw32ce-gcc SDL_DisplayBitmap.c -I../include/sdl -L../lib -lSDL
mike@biosgroup-desktop:~/sdl/test$




This compiles without incident, but when I run it, the screen blinks black and then returns to the file browser again without showing the image. I'm not sure if this is a problem with my SDL, or with the code I'm running. Could someone with SDL/wince experience help me out here? I have a lot of ARM development experience, but WinCE and SDL are new to me so I'm feeling a bit lost.[/code]
 Reply with quote  
Post Fri Jul 04, 2008 11:56 pm 
 View user's profile Send private message
Lostech



Joined: 04 May 2007
Posts: 157
 

Try the libraries from Knakos. They compile fine with cegcc and do work without problems.
Additional compiling infos can be found in the Wiki.

 Reply with quote  
Post Sat Jul 05, 2008 8:17 am 
 View user's profile Send private message Visit poster's website
joostp
ScummVM Developer


Joined: 21 Sep 2005
Posts: 490
 

I would try changing those printf()s to fprintf()s and see if it errors out on any of those cases (unless you can already somehow catch these printfs, of course).

I wouldn't be surprised if it couldn't set the 160x120 video mode...

 Reply with quote  
Post Sat Jul 05, 2008 9:00 am 
 View user's profile Send private message
saratoga



Joined: 04 Jul 2008
Posts: 5
 

quote:
Originally posted by Lostech
Try the libraries from Knakos. They compile fine with cegcc and do work without problems.
Additional compiling infos can be found in the Wiki.


Thats what I'm using, I should have been more clear.


quote:

I wouldn't be surprised if it couldn't set the 160x120 video mode...



Oh wow didn't even think about that. I'll try fixing those printfs (they don't work as is) and see what happens.
 Reply with quote  
Post Sat Jul 05, 2008 3:55 pm 
 View user's profile Send private message
  Display posts from previous:      
Reply to topic

Forum Jump:
 



Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Powered by phpBB © 2001, 2006 phpBB Group
Forum design by ScummVM team, icons by raina
curved edge   curved edge