Black Screen When Using Sdl_gfx


Atgast

Still Fresh
Joined
Apr 3, 2007
Messages
13
Hi all,

I recently bought a GP2X and started deving the same day the package arrived. I've been using SDL for quite some time now, So I felt pretty confident when I started. Sure enough, within a few hours I had everything set up and the first few squares where blitting happily across my screen.

Then I wanted to try the SDL_gfx library. As I have never used it for earlier programs (always did my rotating using openGL) I expected it to work along the lines of the other SDL libs. I had some linking problems for my windows version, so I included SDL_rotozoom into my project. It works fine when I run the exe, but problems occur when I try to run the .gpe on my GP2X.

My program runs fine when I do not use any SDL_gfx methods, when I do use them, the program only crashes (screen goes black) on my GP2X.

I hope you guys can help me figure out where this goes wrong, as I find this a very difficult problem to solve.

thanks in advance,

Atgast
 
Static or dynamic linking? If the latter, try static linking, or include the .so's in your GP2X executable package ..

Also, got a serial console/cable rig up yet? If not: highly recommended .. makes it easier to see debugging output. Try the USB-Serial setup, for example ..
 
well, I compiled the SDL_rotozoom.c/h files along with my own code, so that really shouldn't be the problem.
(same thing when I link to it btw.)

haven't got a serial cable yet...but I print my debug messages to a file, so that kinda works

CODE
std::eek:fstream debug("/mnt/sd/dev/log.txt", std::ios_base::app);
debug << SDL_GetTicks() << std::endl;
debug << (void*)rotozoomSurface << std::endl << std::endl;
debug.close();


this prints an adres to the function I'm calling, it returns a number, which is consistent, so I'm guessing that it's a valid pointer to the function.
QUOTE
0xe374


[edit]
it would seem that the function that hangs is 'rotozoomSurfaceSizeTrig'
[/edit]
 
All sdl_gfx functions (including rotozoomSurface) have always worked fine for me. RotozoomSurface is very slow on the gp2x though so I hope you're not trying to use it for real time fancy rotations.
 
woogal said:
All sdl_gfx functions (including rotozoomSurface) have always worked fine for me. RotozoomSurface is very slow on the gp2x though so I hope you're not trying to use it for real time fancy rotations.
Well, atm I am trying to get it to work for real time, but I could do some pre-rendering offcourse.

But as I have not yet been able to get it to work, I can't judge wheater it is to slow.

Do I have to install something on my GP2X?
 
Last edited by a moderator:
You don't need to install anything, just static link with the lib (if you static link then no libs should ever need to be installed). To find out why it's crashing you need to be checking stdout and stderr and looking for the error.
 
woogal said:
You don't need to install anything, just static link with the lib (if you static link then no libs should ever need to be installed). To find out why it's crashing you need to be checking stdout and stderr and looking for the error.
I don't know what is going on here, but nothing seems to run atm :(

I stripped the code to it's bare minimum, without error checking -> still a black screen!

CODE

#ifdef GP2X
#include "SDL/SDL.h"
#include "SDL/SDL_rotozoom.h"
#else
#include "SDL.h"
#endif

#include <unistd.h>

int main(int argc, char **argv) {
SDL_Surface *src, *screen;

SDL_Init(SDL_INIT_VIDEO);

screen = SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE);

src = SDL_LoadBMP("/mnt/sd/dev/image.bmp");

SDL_FillRect(screen, 0, 0);

SDL_Rect srcR, dstR;
srcR.x = 0;
srcR.y = 0;
srcR.w = src->w;
srcR.h = src->h;

dstR.x = 0;
dstR.y = 0;
dstR.w = src->w;
dstR.h = src->h;

SDL_BlitSurface(src, &srcR, screen, &dstR);

SDL_Flip(screen);

SDL_Delay(1000);

chdir("/usr/gp2x");
execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);

return 0;
}


I really don't get it, I must be doing something wrong. compiling this code results in a black screen, but the unit is stil accesible through ethernet over usb.

what am I missing here :eek:
 
Last edited by a moderator:
Sphinxter said:
QUOTE

what am I missing here :eek:
You forgot to meditate first while chanting the mantra, "A value returned is a value checked".

you are right offcourse, but I stripped the error checking for post-size-sake.

this code also displays nothing but a black screen... :(
CODE

SDL_Surface *src, *screen = NULL;

int init = SDL_Init(SDL_INIT_VIDEO);

if(init < 0) goto quit;

screen = SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE);

if(!screen) goto quit;

src = SDL_LoadBMP("/mnt/sd/dev/image.bmp");

if(!src) goto quit;


SDL_FillRect(screen, 0, 0);

SDL_Rect srcR, dstR;
srcR.x = 0;
srcR.y = 0;
srcR.w = src->w;
srcR.h = src->h;

dstR.x = 0;
dstR.y = 0;
dstR.w = src->w;
dstR.h = src->h;

SDL_BlitSurface(src, &srcR, screen, &dstR);

SDL_Flip(screen);

SDL_Delay(1000);

SDL_FreeSurface(screen);

SDL_FreeSurface(src);

quit:

SDL_Quit();

chdir("/usr/gp2x");
execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
 
Last edited by a moderator:
CODE

dstR.h = src->h;


// check src->w/h in case something is borked ..
printf("src->w : %d, src->h : %d\n", src->w, src->h);

SDL_BlitSurface(src, &srcR, screen, &dstR);
 
torpor said:
CODE

dstR.h = src->h;
// check src->w/h in case something is borked ..
printf("src->w : %d, src->h : %d\n", src->w, src->h);

SDL_BlitSurface(src, &srcR, screen, &dstR);




I'm afraid that's not the problem, as the black screen continues to show, even if I skip the entire 'action' part of this 'game' and go straight to the quit statement :(
 
Last edited by a moderator:
CODE
if (src == NULL) {
printf("Unable to open BMP\n");
}

Run that over telnet, see what it says. Also:

CODE
SDL_BlitSurface(src, &srcR, screen, &dstR);

Is redundant, because

CODE
SDL_BlitSurface(src, NULL, screen, NULL);

Will blit the whole of src on to screen.
 
nickspoon said:
CODE
if (src == NULL) {
printf("Unable to open BMP\n");
}

Run that over telnet, see what it says. Also:

CODE
SDL_BlitSurface(src, &srcR, screen, &dstR);

Is redundant, because

CODE
SDL_BlitSurface(src, NULL, screen, NULL);

Will blit the whole of src on to screen.

As it turned out, I was missing some libraries, but I find this strange as I linked them staticaly into my program
QUOTE
./pong.gpe: error while loading shared libraries: libSDL_gfx.so.13: cannot open shared object file: No such file or directory

Thank god for telnet!

I'll keep you informed :)
QUOTE
./pong.gpe: relocation error: ./pong.gpe: symbol __ltdf2, version GCC_3.0 not defined in file libgcc_s.so.1 with link time reference
this is what I get when I compile the functions along with my program. Could this be because my gp2x came with firmware 3.0 as standard?
 
Last edited by a moderator:
Sounds like you might be using the GPH toolchain with libs built for a more recent GCC. Try using something like devkitgp2x instead if you want to use static libs.
 
woogal said:
Sounds like you might be using the GPH toolchain with libs built for a more recent GCC. Try using something like devkitgp2x instead if you want to use static libs.
that was it :)

but using the rotozoom function results in a single pixel on my display, but on my windows version it works as expected...any thoughts on that?
 
Last edited by a moderator:
Back
Top