SDL help
Apr 20, 2013 at 4:25am UTC
hey, I am sort of a beginner is SLD but not to c++ and in the tutorials they always give me a certain image to put on the screen, but I want to put one of my own pictures on the screen. Every time I try it comes up with a blank screen and the wanted resolution.
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
#include "SDL/SDL.h"
void returnBackground(int x, int y,SDL_Surface *source, SDL_Surface *destination){
SDL_Rect rect;
rect.x = x;
rect.y = y;
SDL_BlitSurface(source, NULL, destination, &rect);
}
int main(int argc, char * args[]){
SDL_Surface *screen = NULL;
SDL_Surface *background = NULL;
bool gameRunning = true ;
SDL_Event event;
SDL_Init(SDL_INIT_EVERYTHING);
screen = SDL_SetVideoMode(1366,768,16,SDL_SWSURFACE);
background = SDL_LoadBMP("windows.bmp" );
while (gameRunning == true ){
if (SDL_PollEvent(&event)){
if (event.type ==SDL_QUIT){
gameRunning = false ;
}
}
}
returnBackground(0,0,background,screen);
SDL_Flip(screen);
SDL_Quit();
return 0;
}
Help please, also sorry if this is wrong section.
Last edited on Apr 20, 2013 at 4:42am UTC
Apr 22, 2013 at 7:18pm UTC
Make sure that the .bmp is in the proper folder, I believe it should be in the same folder as the .exe
Apr 23, 2013 at 11:07am UTC
i am also helpless....
Topic archived. No new replies allowed.