GP2X Working Sdl Libraries


nickspoon

vultum stultum habes
Joined
Nov 4, 2005
Messages
4,234
Age
32
Location
Essex, UK
Website
Visit site
(Sorry to get you all excited with the title)

Somebody needs to post what the community wants: a complete working SDL library!

Developers with the working libraries compiled (including _image, _mixer, _ttf etc.) could you please upload them to the file archive or something, we're a bit stuck :).

Thanks!
 
Is building from source out of the question?

GP2X versions of a range of libs (inc. most of the SDL suite) are in Open2x's CVS and if you need help to build them pop into #GP2XDev. A lot of the libs are still being worked on (SDL esp.) to support things like the hardware scaler, blitter. As such it makes a release right now of all the libs a little premature (IMHO).
 
synkro posted on Dec 13 2005 at 08:02 PM said:
@nickspon: if you get sdl_mixer woring I would like how init'd it and what sound data you used.

Sorry to interrupt, but I've got some wav sounds working like this, although there's a slight delay before I hear the sound:

Code:
  /* initialize SDL */
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_TIMER | SDL_INIT_AUDIO);

  // Open up the Audio
  if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, AUDIO_S16, MIX_DEFAULT_CHANNELS, 512) < 0) {
	printf("Unable to open audio!\n");
	exit(1);
  }

  // Pre-load the sound effects */
  Mix_Chunk *pop = NULL;
  pop = Mix_LoadWAV("pop2.wav");  
  Mix_Chunk *pinc = NULL;
  pinc = Mix_LoadWAV("pinc.wav");

These sounds came from Tintagel's Free Sound Archive


I hope this is helpful.
 
Last edited by a moderator:
evening2005 posted on Dec 13 2005 at 09:15 PM said:
synkro posted on Dec 13 2005 at 08:02 PM said:
@nickspon: if you get sdl_mixer woring I would like how init'd it and what sound data you used.

These sounds came from Tintagel's Free Sound Archive

I hope this is helpful.
sorry for the offtopic,
but: woot!, this site is just what I needed.
Im making a movie at school and a was wondering where to get them :).

btw. do you know anymore of these archives with sounds?
 
Last edited by a moderator:
This is the code I use, but it does not work! I get an error:
Unable to initialize audio: Could not open requested file
Can anyone please test this code, maybe I am doing something awfully wrong!

Code:
#include <unistd.h>
#include <stdlib.h>
#include <SDL/SDL.h>
#include <SDL/SDL_mixer.h>

int main(int argc, char *argv[])
{
	SDL_Surface *screen;  
	Mix_Chunk *sound = NULL;	
	int channel;    
    
	//Initialize BOTH SDL video and SDL audio
	if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) != 0)
	{
  printf("Unable to initialize SDL: %s\n", SDL_GetError());
  return 1;
	}
	
	//Initialize SDL_mixer with our chosen audio settings
	if(Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, AUDIO_S16, MIX_DEFAULT_CHANNELS, 512) != 0)
	{
  printf("Unable to initialize audio: %s\n", Mix_GetError());
  exit(1);
	}
	
	//Load our WAV file from disk
	sound = Mix_LoadWAV("sound.wav");
	if(sound == NULL)
	{
  printf("Unable to load WAV file: %s\n", Mix_GetError());
	}
	
	//Set the video mode to anything, just need a window
	screen = SDL_SetVideoMode(320, 240, 0, SDL_SWSURFACE);
	if (screen == NULL) {
  printf("Unable to set video mode: %s\n", SDL_GetError());
  return 1;
	}
	
	//Play our sound file, and capture the channel on which it is played
	channel = Mix_PlayChannel(-1, sound, 0);
	if(channel == -1) {
  printf("Unable to play WAV file: %s\n", Mix_GetError());
	}
	
	//Wait until the sound has stopped playing
	while(Mix_Playing(channel) != 0);
	
	//Release the memory allocated to our sound
	Mix_FreeChunk(sound);
	
	//Need to make sure that SDL_mixer and SDL have a chance to clean up
	Mix_CloseAudio();
#ifdef GP2X
	chdir("/usr/gp2x");
	execl("gp2xmenu","gp2xmenu",NULL);
#endif
	SDL_Quit();	

	return 0;
}
 
DJWillis posted on Dec 13 2005 at 08:31 PM said:
Is building from source out of the question?

GP2X versions of a range of libs (inc. most of the SDL suite) are in Open2x's CVS and if you need help to build them pop into #GP2XDev. A lot of the libs are still being worked on (SDL esp.) to support things like the hardware scaler, blitter. As such it makes a release right now of all the libs a little premature (IMHO).
But that would give more people the opportunity to start their own development. When a new version will be ready, a simple recompile would be sufficient.
 
Last edited by a moderator:
Better would be a compilation tutorial, so everyone can compile the libraries he sees fit at any time it is required.
 
the sad thhings is that cross-compiling libs is not that easy. I was not able to compile even small things like libsndfile and stuff. that's just plain awful...
 
fragment posted on Dec 14 2005 at 04:38 PM said:
thanks theoddbot, finally got the SDL_mixer working (plays mods atleast)

could you please paste your code/makefile here? because I don't get it to work ;( *puh-leeez*
 
Last edited by a moderator:
It works!!! Thanks very much, theoddbot.

I'm using DevKit on XP. If anyone is interested, here is the LIBS line inside my Makefile:
Code:
LIBS = -L"C:/devkitGP2X/lib" -lSDLmain -lSDL_image -lpng12 -ljpeg -lz -lc -lm -lgcc -lSDL_mixer -lvorbisidec -lmikmod -lSDL -lpthread
Btw, to avoid latency problems, I've had to change chunksize in Mix_OpenAudio. Mine looks like this (128 instead of 4096):
Code:
Mix_OpenAudio(22050, AUDIO_S16, 2, 128)
I expected skipping but music and sound effects play properly. The only thing I don't like is that it's mono instead of stereo. I'll try to see if that patch someone released days ago solves it.

Edit: I forgot to mention that it works for OGG and WAV. Haven't checked other formats, but somebody from GP32Spain reports that XM work as well.
 
Back
Top