Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Trouble with SDL bmp's...


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Aeroman   Members   -  Reputation: 104

Like
0Likes
Like

Posted 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?

Sponsor:

#2 RulerOfNothing   Members   -  Reputation: 1164

Like
0Likes
Like

Posted 04 July 2012 - 09:36 PM

Well, firstly there is no code to draw the second image, and secondly you are repeatedly loading PageButtonPressed.bmp for no reason.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS