Sdl_creatergbsurface


rooster

Member
Joined
Jun 11, 2006
Messages
167
Location
New Mills, Derbyshire
Website
Visit site
Hi guys,

just wondering if anyone can help me with this:

Code:
  bg_scroll_data = SDL_CreateRGBSurface(SDL_SWSURFACE,1000,1000,32,r_mask, g_mask, b_mask,a_mask);

It's working fine on Windows, when the GP2X hits the line above it's quitting.

I'm using the official devkit.

All my other code has been behaving fine in this project on both platforms, its just now I've decided to add this scrolling background the GP2X has gone f-ing mental.

Help plz you gurus! thanks,
rooster :D
 
The way I use it is in 16 not 32 bit, and instead of r_mask, etc., I put 0 values. Another problem may be its incredibly large size, I think the SDL libs have a limit to how much video they can load, so you may have hit the roof?

Good luck!

- Alex
 
You don't say what values you have for the masks, so I'll assume they are the ones shown in the example at www.libsdl.org!

This code seems to work fine for me with the GPH toolchain (the one that makes a dynamic SDL executable):

Code:
		Uint32 r_mask, g_mask, b_mask, a_mask;
		SDL_Surface *tmp_surface_p, *background_p;

#	   if SDL_BYTEORDER == SDL_BIG_ENDIAN
		r_mask = 0xff000000;
		g_mask = 0x00ff0000;
		b_mask = 0x0000ff00;
		a_mask = 0x000000ff;
#	   else
		r_mask = 0x000000ff;
		g_mask = 0x0000ff00;
		b_mask = 0x00ff0000;
		a_mask = 0xff000000;
#	   endif
		tmp_surface_p = SDL_CreateRGBSurface(SDL_SWSURFACE, 1000, 1000
		 , 32, r_mask, g_mask, b_mask, a_mask);

		// ... do stuff with tmp_surface_p ...

But you may wish to rethink using 32bit (as 16bit is the highest the GP2x can display anyway), or at the very least translate the surface into display format (prior to using it in the game) and add error checking.

Append this to above:

Code:
		if (tmp_surface_p == NULL) {
				fprintf(stderr, "Unable to create SDL Surface for background"
				 ": %s\n", SDL_GetError());
				exit(1);
		} else {
				background_p = SDL_DisplayFormat(tmp_surface_p);
				SDL_FreeSurface(tmp_surface_p);
				tmp_surface_p = NULL;
				printf("Created surface OK.\n");
		}

		// ... do stuff with background_p ...

Are you allocating loads of other surfaces prior to creating this huge surface? If so you may be running out of resources as Alex says.

Personnally I'd force the PC to work with a format that is GP2x friendly (8 or 16 bit) rather then force the GP2x to work with a PC friendly 32bit format!

Anyway, it's nice to see you dev'n again Rooster, best of luck, look forward to seeing your game! :)
 
Thanks for those ideas guys, I've tried altering the program accordingly but to no avail.

Just as I was about to really lose control I found that an old, "definitely working source" no longer works now when compiled for GP2X pointing to the fact that I've shafted the compiler somehow.

I don't like this official devkit compiler 'bloodshed' I think it's frickin nasty.
Gonna reinstall it and see if that fixes stuff.

The guy who is co-developing with me said that his copy of bloodshed exhibited similar symptoms and had to be reinstalled. He gave up with it and is using Linux as recommended by you Mr Bunn! Hey fancy meeting you here! How's things? How's your mother? Hope you're getting more devtime than she's getting tetris time! Mr Fru.T Bunn ladies & gentlemen on bass guitar..... sorry, lead emulation....of the BBC! A living legend god damn it :D I hope your timer issues are resolving themselves sir and you have the correct number of 6502 cycles emulated these days!?

Beebem2x. god damn it it's my favourite gp2x app, there i've said it. All hail the Master Baker, for he is the chosen one!
 
Back
Top