Problems with the Wii SDL-port March 25, 2009 05:59PM | Registered: 15 years ago Posts: 1 |
//main.cpp #include "testManager.h" int main(int argc, char* args[]) { bool bExit = false; testManager manager; bExit = manager.play(); if(bExit) { exit(0); } manager.freeMemory(); exit(0); return 0; }
//testManager.h #ifndef TESTMANAGER_H #define TESTMANAGER_H //I N C L U D E S ////////////////// #include#include #include #include #include #include #include #include //C O N S T S /////////////// const int SCREEN_WIDTH = 640; const int SCREEN_HEIGHT = 480; //C L A S S ////////////// class testManager { public: testManager(); ~testManager(); bool play(); void init(); void drawBackground(); void updateScreen(); void freeMemory(); private: SDL_Surface *screen; SDL_Surface *background; }; #endif
//testManager.cpp #include "testManager.h" testManager::testManager() { } testManager::~testManager() { } void testManager::init() { SDL_Surface *screen = NULL; SDL_Surface *background = NULL; fatInitDefault();//Initializing fat //Initialize all SDL subsystems if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) { printf("Could not initialize SDL: %s\n", SDL_GetError()); exit(1); } //Set up the screen screen = SDL_SetVideoMode( 640, 480, 24, SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN ); if( screen == NULL) { printf("Couldn't set screen mode to %d x %d: %s\n", SCREEN_WIDTH, SCREEN_HEIGHT, SDL_GetError()); exit(1); } //Check from here, this is where I'm getting the error... background = IMG_Load("data/graphics/background.png"); if (background == NULL) { printf("Couldn't FUCKING load the background image: %s\n", SDL_GetError()); exit(1); } } void testManager::drawBackground() { //Holds offsets SDL_Rect offset; //Get offsets offset.x = 0; offset.y = 0; //Blit SDL_BlitSurface( background, NULL, screen, &offset ); } void testManager::updateScreen() { SDL_Flip(screen); } bool testManager::play() { bool bGameover = false; init(); //drawBackground(); updateScreen(); while (!bGameover) { //drawBackground(); updateScreen(); SDL_Delay(1000/60); } } void testManager::freeMemory() { //Free the sprite map SDL_FreeSurface( screen ); SDL_FreeSurface( background ); //Quit SDL SDL_Quit(); }
Re: Problems with the Wii SDL-port March 25, 2009 07:59PM | Registered: 15 years ago Posts: 703 |
Re: Problems with the Wii SDL-port March 26, 2009 06:29AM | Registered: 16 years ago Posts: 441 |