I am having problems with my RenderDevice function (Constructor within the RenderDevice class) in an engine i am developing at the moment. It isnt a final wanted function, but a test for SDL.
My problem is that a SDL window is created, but somehow exits the while loop (from what it appears) but that isnt possible as the variable checked for program end isnt even changed. I took out SDL_quit and it had still closed. From what i was instructed, is that my use of MSVC 2010 ultimate May be interfering with SDL itself. (it being a wrong version or recompilation of the libraries is needed) On the site i took into consideration of reading, lazyfoo, it had Told to go through the steps to use the libraries. I am using the instructed libraries for the project im working on in the compiler im on. So this should not be a problem and have a feeling that the problem lies within the code itself. I however have checked multiple times to see what it could be, and it was no use in my eyes. So i have come here to see if anyone else has encountered this problem or have a possible hint to fixing mine.
RenderDevice(int x_size, int y_size, int Bits_Per_Pixel, char* windowTitle, char* taskbarTitle, void (*execute_per_frame)() ) {
vTimerObject timerobj; //Sets up a timer object to continuously get last time between function calls to calculate fps
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Surface* Window = NULL;
SDL_Event WindowEvent;
Window = SDL_SetVideoMode( x_size, y_size, Bits_Per_Pixel, SDL_SWSURFACE);
if (Window == NULL) { MessageBox(NULL, "Window Creation Failed", "Engine Initialization Failure", MB_ICONEXCLAMATION | MB_OK); }
SDL_WM_SetCaption(windowTitle, taskbarTitle);
while(this->end_rendering == false) { //While device end_rendering not set
if (SDL_PollEvent(&WindowEvent) != 0) {
if (WindowEvent.type == SDL_QUIT) { this->window_close_requested = true; }
}
if (SDL_Flip(Window) != 0) { MessageBox(NULL, "Window Update Failure", "Engine Runtime Error", MB_ICONEXCLAMATION | MB_OK); }
//GetLastTick();
execute_per_frame(); //Programmers loop, game function to call every frame
this->fps = (1000/timerobj.GetLastTick()); //get fps
}
SDL_Quit();
//DEALLOCATION and ENGINE END functions go here. once the person calls
}
Is there a possibility that its got something to do with my code?