Welcome! Log In Create A New Profile

Advanced

Problems with the Wii SDL-port

Posted by Tonberry 
Problems with the Wii SDL-port
March 25, 2009 05:59PM
Hi!
I am pretty new to the Wii homebrew scene, but I'm trying to learn stuff.
My plan is to port a SDL game I made myself for PC to the Wii, but I'm having problems loading images
to the Wii when running the game. I simply get the error message "Couldn't load", which obviously means
there are problems loading the picture.

I haven't made anything for Wii before, so I probably have to do something different to load pictures to Wii,
but I have no idea how. I've searched for answers at google for 5 hours, and haven't found anything that helped me.

The image types I'm planning to use is .png types, but I can also use .jpg or .bmp in the worst case.
I've tried to load .jpg and .bmp files as well, so I'm obviously doing something wrong.
Also, I'm writing the game in C++.

Includes I used in the testManager.h file(they somehow are invisible in the code posted on this forum)
The arrow signs seems to remove the text...:
//I N C L U D E S
//////////////////
SDL/SDL.h
SDL/SDL_image.h
SDL/jpeglib.h
wiiuse/wpad.h
string
cstdlib
fat.h
libpng/png.h

The code:
//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();
}


Thanks in advance :)



Edited 3 time(s). Last edit at 03/25/2009 06:11PM by Tonberry.
Re: Problems with the Wii SDL-port
March 25, 2009 07:59PM
I'm sorry you spent so long trying it figure this out. The SDL port under the development tools here does not work very well. I've been told that the Wiiapple has modified the port so it works. Although it did not work for me.

If you can't get one working then I have a port of SDL that I have modified. The RW ops work but I've not had the time to fix stuff like SDL threads. I've actually not tried it with IMG_Load as thus far I've only used BMP's and the SDL_LoadBMP() function.

Anyway if you can't get the Wiiapple's SDL to work. Shoot me an email and I'll be happy to send you what I use. (scanff AT Yahoo.com)

We may want to remove or put a warning on the Wiki's SDL page as this is a FAQ. Including myself when I first started here.
Re: Problems with the Wii SDL-port
March 26, 2009 06:29AM
Good idea. I've added a little warning box =)
Sorry, only registered users may post in this forum.

Click here to login