Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Aeroman

Member Since 29 Jun 2012
Offline Last Active Jul 13 2012 06:56 PM

Topics I've Started

Trouble with SDL bmp's...

04 July 2012 - 11:53 AM

Hey, I'm not really new to game development in general- mostly the programming behind it. Anyway I'm having trouble loading more than 1 image and using getmousestate-but mostly just displaying multiple images. Here I'll post my code:
[source lang="cpp"]#ifdef __cplusplus #include <cstdlib>#else #include <stdlib.h>#endif#ifdef __APPLE__#include <SDL/SDL.h>#else#include <SDL.h>#endifint main ( int argc, char** argv ){ if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) { printf( "Unable to init SDL: %s\n", SDL_GetError() ); return 1; } atexit(SDL_Quit); SDL_Surface* screen = SDL_SetVideoMode(1300, 630, 16, SDL_HWSURFACE|SDL_DOUBLEBUF); if ( !screen ) { printf("Unable to set 640x480 video: %s\n", SDL_GetError()); return 1; } SDL_WM_SetCaption("Z Soft", NULL); // load an image SDL_Surface* bmp = SDL_LoadBMP("TaskBar.bmp"); if (!bmp) { printf("Unable to load bitmap: %s\n", SDL_GetError()); return 1; } SDL_Rect dstrect; dstrect.x = (screen->w - bmp->w) / 2; dstrect.y = (screen->h - bmp->h) / 14; //This does what? SDL_Surface*PBP = SDL_LoadBMP("PageButtonPressed.bmp"); if (!PBP) { printf("Unable to perform that action. This situation sucks for you...%s\n", SDL_GetError()); return 1; } SDL_Rect dstrectPBP; dstrectPBP.x = (screen->w - PBP->w) / 2; dstrectPBP.y = (screen->h - PBP->h) / 2; // program main loop bool done = false; while (!done) { // message processing loop SDL_Event event; while (SDL_PollEvent(&event)) { // check for messages switch (event.type) { // exit if the window is closed case SDL_QUIT: done = true; break; // check for keypresses case SDL_KEYDOWN: { // exit if ESCAPE is pressed if (event.key.keysym.sym == SDLK_ESCAPE) done = true; break; if (event.key.keysym.sym == SDLK_UP) SDL_Surface*PBP = SDL_LoadBMP("PageButtonPressed.bmp"); if (!PBP) { printf("Unable to perform that action. This situation sucks for you...%s\n", SDL_GetError()); return 1; } SDL_Rect dstrectPBP; dstrectPBP.x = (screen->w - PBP->w) / 2; dstrectPBP.y = (screen->h - PBP->h) / 2; break; } } // end switch } // end of message processing // clear screen SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0)); // draw bitmap SDL_BlitSurface(bmp, 0, screen, &dstrect); // DRAWING ENDS HERE SDL_Flip(screen); } // end main loop // free loaded bitmap SDL_FreeSurface(bmp); printf("Finally you closed it!\n"); return 0;}[/source]
So can anyone help to pinpoint the problem?

PARTNERS