Setting Up The Hw Sdl Libs.


deathrabbit

Still Fresh
Joined
Nov 20, 2006
Messages
8
ALthough this probably sounds really stupid, I can't figure out what includes and libraries to put where. I am using the GPH windows devkit. From looking at Tools>compiler settings in dev-c++, it seems the the directory for includes is "GP2XSDK\Tools\include" and libraries is "GP2XSDK\Tools\arm-gp2x-linux\lib". I have tried replacing files in there with various combinations of the following:
http://paeryn.myby.co.uk/SDL_includes.tar.bz2
http://paeryn.myby.co.uk/libSDL.tar.bz2
http://archive.gp2x.de/cgi-bin/cfiles.cgi?0,0,0,0,19,1240
http://www.distant-earth.com/SDLlib_overwrite.zip
but when I try to compile something, it either fails to compile, or none of the libs that i replaced are used. One thing I've tried which seems to me to be the most logical combination is the SDL_includes, and the libSDL from paeryn's site, but when I try to compile something using it, there is no effect since libSDL.a does not seem to be used, and things compile fine if I delete the libSDL.a file from the lib folder, proving that its not being used.

Can anyone tell me which packages I need to use?
 
First off, the devkit that includes dev-c++ includes hardware SDL libraries, no?

Second off, you should post your error, although I'm positive it relates to differences in compiler setting between the created SDL lib and the rest of the Dev kit. I tried to install the X libraries only to find that they were build with hardware floating points, which are slow, and don't mix with the software floating point libraries in the devkit.

I'm pretty sure that you need no SDL changes. Delete your GP2XSDK folder and re-extract it. You should be able to make SDL applications out of the box and easily.
 
SDL_SetVideoMode crashes my gp2x if I tell it to use double buffering with the libs that came with that SDK, so I think it doesn't have hw sdl.

You are probably correct about the compiler differences, since I saw many FP warnings, and also some linker errors about it unable to find certain functions. I don't have specific messages for you, since I tried many combinations of the different libs and includes I linked to in the first post, and reverted to normal after each.
 
SDL_SetVideoMode should not crash if you tell it to use double buffering. Are you sure thats the problem?

I'm writing flashplayer2x in it. It works fine with double buffering on windows and the gp2x. I think your code might be faulty, but that would be jumping to conclusions. Try the example directly. It has double buffering.

Post your initialization and main loops if you think it might be your code. If your using the example and your having the problem, then I'm not sure whats happening. In that case, maybe the latest SDK is faulty :(

In case your SDK isn't giving you the example when you create a new application:

Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <SDL.h>

/* GP2X button mapping */
enum MAP_KEY
{
	VK_UP		 , // 0
	VK_UP_LEFT	, // 1
	VK_LEFT	   , // 2
	VK_DOWN_LEFT  , // 3
	VK_DOWN	   , // 4
	VK_DOWN_RIGHT , // 5
	VK_RIGHT	  , // 6
	VK_UP_RIGHT   , // 7
	VK_START	  , // 8
	VK_SELECT	 , // 9
	VK_FL		 , // 10
	VK_FR		 , // 11
	VK_FA		 , // 12
	VK_FB		 , // 13
	VK_FX		 , // 14
	VK_FY		 , // 15
	VK_VOL_UP	 , // 16
	VK_VOL_DOWN   , // 17
	VK_TAT		  // 18
};

/* The screen surface, joystick device */
SDL_Surface *screen = NULL;
SDL_Joystick *joy = NULL;

void Terminate(void)
{
	SDL_Quit();
#ifdef GP2X
	chdir("/usr/gp2x");
	execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
#endif
}

int main (int argc, char *argv[])
{
	int done;

	/* Initialize SDL */
	if (SDL_Init (SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0) {
		fprintf (stderr, "Couldn't initialize SDL: %s\n", SDL_GetError ());
		exit (1);
	}
	atexit (Terminate);

	SDL_ShowCursor(SDL_DISABLE);

	/* Set 320x240 16-bits video mode */
	screen = SDL_SetVideoMode (320, 240, 16, SDL_SWSURFACE);
	if (screen == NULL) {
		fprintf (stderr, "Couldn't set 320x240x16 video mode: %s\n", SDL_GetError ());
		exit (2);
	}

	/* Check and open joystick device */
	if (SDL_NumJoysticks() > 0) {
		joy = SDL_JoystickOpen(0);
		if(!joy) {
			fprintf (stderr, "Couldn't open joystick 0: %s\n", SDL_GetError ());
		}
	}

#ifdef GP2X
	/* Only use GP2X code here */
#endif

#ifdef WIN32
	/* Only use Windows code here */
#endif

	done = 0;
	while (!done)
	{
		SDL_Event event;

		/* Check for events */
		while (SDL_PollEvent (&event))
		{
			switch (event.type)
			{
				case SDL_KEYDOWN:
					/* if press Ctrl + C, terminate program */
					if ( (event.key.keysym.sym == SDLK_c) && (event.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) )
						done = 1;
					break;
				case SDL_KEYUP:
					break;
				case SDL_JOYBUTTONDOWN:
					/* if press Start button, terminate program */
					if ( event.jbutton.button == VK_START )
						done = 1;
					break;
				case SDL_JOYBUTTONUP:
					break;
				case SDL_QUIT:
					done = 1;
					break;
				default:
					break;
			}
		}

		/* Processing */
	}

	return 0;
}
C Compiler settings
Code:
-D_REENTRANT
Linker settings:
Code:
-lSDL_image -lSDL_mixer -lSDL_ttf -lSDL_inifile -lSDL -lpng -ljpeg -lvorbisidec -lmad -lfreetype -lz -lunicodefont


Good luck.
 
The example directly works, but if I change:
Code:
screen = SDL_SetVideoMode (320, 240, 16, SDL_SWSURFACE);
to
Code:
screen = SDL_SetVideoMode (320, 240, 16, SDL_HWSURFACE|SDL_DOUBLEBUF);
then it crashes my gp2x.
 
Although I have tried with it flipping the buffer, I'm not sure why that matters if it doesn't make it past the SDL_SetVideoMode call.
 
Oh, i get it now. You have pinpointed it. sorry.

I think double buffering is default.

I'm flipping the screen and I have not added the double buffering flag. No problems. If i stop flipping the screen, i don't see anything. The only rather strange thing is that adding | SDL_DOUBLEBUF to my flags does nothing... Maybe it causes another flag to turn on because of the way it works. Not sure. And then that is a possible explanation for gp2x crashes.

So after all of this i conclude that it must be default.

Hopefully I've shed some light on this issue and you can continue working.
 
Unfortunatly, it doesn't work quite the same for me. If I change the SDL_SWSURFACE to SDL_HWSURFACE and don't add the |SDL_DOUBLEBUF, and display a picture and flip, the image flickers, which I assume is the same problem that is answered here( http://www.gp32x.de/board/index.php?showt...mp;#entry442608 ) and the souldution is to add the double buffer flag <_<
 
Last edited by a moderator:
Try using frame capping. I think this is your problem.
Why? Well, at a certain frame rate, my pc will start tearing. *coughglxgearscough*

Put this after flipping:
SDL_Delay(1000/60);

And maybe decrease 60 to 30-50 to make sure were not going too fast.

Don't use this function in the full version of a game or application, instead, you can count the ticks at the frame start, precalculate 1000/60, and take away the difference between the current ticks and the ticks at the start of the frame.

Counting ticks with: SDL_GetTicks();

Using Uint32 to store time data will make your game much longer playable since it will store a much higher amount of seconds.
 
I went all the way down to 15 and it still flickered, just less.

I know how to calculate from rates, I have previous SDL experiance, just not on the gp2x.

I don't think you realize that data types loop back aorund, and their calculations work even if they go over the break, so the game won't stop functioning when you hit the max amount.

EDIT: I have found a way to prove that it only has 1 buffer. If I blit an image to only 1 of the 2 buffers, and flip it back and forth, it should flicker, but instead is always there.
 
Ok, i'm clueless. Sorry...

Aside from that... you could try an alternative dev kit with an rxvt, if your a Linux Is Not UniX user you'll have no problem with getting into makefiles and such. But if you've never worked with makefiles, i have no idea what to tell you. Your problem is rather strange. Good luck.

And maybe yours is using only 1 buffer. Mine will not behave the same way.
 
Thanks for trying.

I guess I'll probably either use software surfaces, or just deal with the flicker if its not too bad(since hardware has a major speed boost).
 
Without the SDL_DOUBLEBUF flag, you don't flip the buffer. In my last program, I used:

SDL_HWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF

Which worked fine for me :S.
 
From the SDL docs:
On hardware that doesn't support double-buffering, this is equivalent to calling SDL_UpdateRect(screen, 0, 0, 0, 0)

I assume that not enabling is the same as not supporting, since calling SDL_UpdateRect gives similar results.

That combination doesn't work either. Which SDK are you using?
 
I ported my program to the minimal libs and it flickers. Something was wrong with those SDL Libs. This is much faster.

But anyways, You might be experiencing flickers because the LCD needs to be adjusted. I managed to heavily reduce flickering using the top scroller in FW 2.1.1
 
Back
Top