Talk:SDL Wii/Archive 1
From WiiBrew
|
|
This is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Contents |
SDL Wii Ports Released
ilidrissiamine has released several new items of interest to wii developers:
This project will introduce many ports of SDL games to the Nintendo Wii and will provide various libraries for SDL developers that extend it.
- SDL_gfx-2.0.17.7z SDL_gfx port to the Nintendo Wii
- SDL_ttf-2.0.9.7z SDL_ttf port to the Nintendo Wii with its Freetype port
- SDL_image.7z Slightly modified SDL_image port to accept various types (libjpeg required)
- libjpeg.7z libjpeg port to the Nintendo Wii
http://code.google.com/p/sdl-wii-ports/downloads/list
Ah you are right. Somehow I missed the second download link! CarstenK 05:03, 1 August 2008 (CEST)
Example?
Can someone please write an example of how SDL works with devkitpro please? Thanks ahead of time!
Akirahedgehog 09:49, 12 August 2008 (Central Time)
There are no many differances with a pc version. Just include devkitppc headers to use with sdl (fat, wiiuse...) Anyway, there is a blue screen exemple, quit with HOME
#include <stdlib.h> #include <time.h> #include <SDL/sdl.h> //#include <SDL/sdl_mixer.h> //#include <SDL/sdl_ttf.h> #include <gccore.h> #include <wiiuse/wpad.h> int main(int argc, char** argv) { SDL_Surface *screen=NULL; srand(time(NULL)); // initialize SDL video if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0 ) { fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError() ); exit(EXIT_FAILURE); } fatInitDefault(); //for read files (level, serialized structs...) WPAD_Init(); // make sure SDL cleans up before exit atexit(SDL_Quit); SDL_ShowCursor(SDL_DISABLE); // create a new window screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF); if ( !screen ) { fprintf(stderr, "Unable to set video: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } state_in_game(screen); return 0; } void state_in_game(SDL_Surface *screen) { int tick_count=0; int tick_trigger=15; bool done = false; SDL_EnableKeyRepeat(10,10); while (!done) { SDL_Event event; while (SDL_PollEvent(&event)) { switch ( event.type ) { case SDL_QUIT: done = true; break; } } //With SDL_Event, the wiimote is detected as a mouse, to use wiiuse/wpad to handle inputs WPAD_ScanPads(); u32 held = WPAD_ButtonsHeld(WPAD_CHAN_0); if(held & WPAD_BUTTON_HOME){ done=true; } tick_count = SDL_GetTicks(); if (tick_count > tick_trigger) { tick_trigger = tick_count; SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 50, 150)); SDL_Flip(screen); } //end tick } //end while SDL_Quit(); exit(EXIT_SUCCESS); }
--TheDrev 18:24, 21 October 2008 (UTC)
Bad libs order ?
I got the following error :
linking ... blastguy_wii_b1.elf i:/usr/devkitpro/libogc/lib\libSDL.a(SDL_gamecube_main.o): In function `main': c:\dev\apps\devkitPro\SDL-Port/src/main/gamecube/SDL_gamecube_main.c:59: multipl e definition of `main' i:/usr/devkitpro/libogc/lib\libfreetype.a(gxvfgen.o):d:/Programming/WiiDev/freet ype-2.3.6/source/gxvalid/gxvfgen.c:444: first defined here i:/usr/devkitpro/libogc/lib\libfreetype.a(gxvfgen.o): In function `main': gxvfgen.c:(.text.main+0xc4): undefined reference to `ft_strncmp' collect2: ld returned 1 exit status make[1]: *** [/i/Documents/developpement/test_sdl_plus_ttf.elf] Error 1 make: *** [build] Error 2
when -lfreetype is included before -lSDL, the right order should be
LIBS := -lSDL_ttf -lSDL_mixer -lSDL_image -ljpeg -lpng -lz -lSDL -lfreetype -lfat -lwiiuse -lbte -logc -lm
I changed the lib order in the main page
--TheDrev 15:25, 15 October 2008 (CEST)
- Your libfreetype is either buggy, or was built incorrectly. You shouldn't have a main() in this library.--Michael 15:05, 13 April 2009 (UTC)
I grabbed the lib included in libwiisprite, Apparently a .o having a main function comes from a test program is included in the .a I've removed the object with $ ar d libfreetype.a gxvfgen.o It should have resolved the linker error --TheDrev 09:07, 15 April 2009 (UTC)
- Nice, thanks for that tip with ar. That's useful to know. --Michael
Threads?
This is a great port, and I'm sure it will help porting go a lot smoother for some people. However, there is no threads support. I did find a way around this (although, it makes it slower, because no threads) but I would greatly appreciate if someone added thread support to this. It'll make a bunch of ports a lot faster. Thanks --SquidMan 02:00, 17 December 2008 (UTC)
Yohanes has added threads and USB keyboard support to the SDL library while porting an apple ][e SDL based emulator to the wii. You can find his SDL code here http://tinyhack.com/wii/wiiapple/ 11, January, 2009. —Preceding unsigned comment added by Nowhereman (talk • contribs) 21:53, 11 January 2009 (UTC)
sdl-config
It looks like sdl-config needs to be located in bin/ not in lib/. It worked for me after putting it in $DEVKITPPC/bin. The paths in sdl-config seems to be hard-coded "-L/c/dev/apps/devkitPro/libogc/lib/wii" etc - should be dependent on location of libogc and devkitpro.
- Right, sdl-config is just a shell script for handling includes, flags, etc more easily, the important thing is just to have sdl-config in your PATH
--with-sdl-prefix=PFX Prefix where SDL is installed (optional) --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)
are maybe what set the path before compiling the lib...
--TheDrev 09:24, 15 April 2009 (UTC)
Image
Hello,
I just managed SDL to work on my wii, and i've made a little program with controller input. I've made it so, that it will show a red background when i push on the right button. What i want is to show a photo when i press the right button. How can i do that? Do I need to include SDL_image? And what's the function i have to use?
Thanks, GabberNL 14:25, 28 April 2009 (UTC)
Update
I used this function:
SDL_Surface *load_image( std::string filename ) { //Temporary storage for the image that's loaded SDL_Surface* loadedImage = NULL; //The optimized image that will be used SDL_Surface* optimizedImage = NULL; //Load the image loadedImage = SDL_LoadBMP( filename.c_str() ); //If nothing went wrong in loading the image if( loadedImage != NULL ) { //Create an optimized image optimizedImage = SDL_DisplayFormat( loadedImage ); //Free the old image SDL_FreeSurface( loadedImage ); } //Return optimized image return optimizedImage; }
And applied the loaded image to a new surface with this function:
void apply_surface ( int x, int y, SDL_Surface* source, SDL_Surface* destination ) { //Make a temporary rectangle to hold the offsets SDL_Rect offset; //Give the offsets tot the rectangle offset.x = x; offset.y = y; //Blit the surface SDL_BlitSurface( source, NULL, destination, &offset ); }
But when i try to compile it it sais it doesnt have the length of the image. Can somebody help me?
GabberNL 14:17, 13 May 2009 (UTC)
- Solved. SDL loads from root directory. ltkerr0r

