View Full Version : gamepark x2 wiz

30-08-2009, 10:44 AM
Looking at the specs for the xp2x wiz it look likes a very nice machine. It seems to have OpenGLes 1.x also. Now that is an oportunity to brush up my opengles pascal unit.
But i am unsure what fpc i need for gp2x (wiz) development. Where do i download what.
But first i need to buy the machine itself (but the dutch shop is a bit unclear if it is in stock or not) ...

30-08-2009, 11:32 AM
Not sure where you would get it from, but if I had the money, I would get one too to complement my gp2x F-100 MkII model :)

I would love to get my hands on the gp2x wiz with touch-screen and OpenGL hard-ware acceleration ;)


31-08-2009, 08:19 PM
I got an answer form the dutch webshop stating a few weeks until the next delivery.

Meanwhile could you give me some more info on what fpc i need and how i should set it up?

I brushed up my opengles unit (should be somewhere here) and got my first white triangle. (fpc op windows xp met opengleslite dll van imagination)

Colors do not work yet as i get confused by this:

glColorPointer(4,VERTTYPEENUM,sizeof(VERTTYPE) * 7, (GLvoid*) (sizeof(VERTTYPE) * 3) /*The color starts after the 3 position values (x,y,z)*/);
How does that last (GLvoid*) need to be written in pascal? A pointer skipping the first 3 elements)

Solved glcolorpointer call like this:

glColorPointer(4,GL_FIXED,sizeof(glfixed) * 7, pglfixed(sizeof(glfixed) * 3)); //The color starts after the 3 position values (x,y,z)

(Confusing opengleslite fact is that it does not support floating point.)

16-09-2009, 05:41 PM
You are not using Delphi form Borland, dont you?. What extension support GP32 or GP technology?

17-09-2009, 07:36 AM
I'm using for GP2X and GP2XWIZ the developer branch 2.3.1 or latest 2.5.1. Both are working very well. I had setup up a colinux environment and develop with delphi, cross compile it under colinux to gp2x and gp2xwiz.

I have no working cross compiler under window yet.

EvilDragon has in his shop some wiz available, http://www.gp2x.de/shop/gamepark-holdings-gp2xwiz-handheld-p-107.html, price 149,00 Ǩ.


17-09-2009, 03:40 PM
Hmm how goes development on this system. Are you able to make a decent game with the development tools available?

17-09-2009, 04:30 PM
I did a pre-order with the dutch webshop with the option to pay the postman when the package arrives (still waiting for it to be delivered).

Also to get started building software for the gamepark 2x wiz we need a freepascal cross compiler since we are either on x86 windows or on x86 linux. Could the nds/gba fpc work for the gamepark (i guess not).

So whe can write a small tutorial on what to download from where how to install it and how to compile a hello world with it. Many thanks in advance.

17-09-2009, 04:47 PM
Paul did a brilliant work with fpc4gp2x (http://fpc4gp2x.eonclash.com/). I guess it could be usable for wiz with minor adjustements

17-09-2009, 05:29 PM
I remember Paul's GP2X port of FPC. Nice work and much appreciated effort indeed. But, I guess what I'm trying to ask is; are all the pieces there right now for a complete start-to-finish project or is there yet more pioneering to do for tools, libraries, etc...?

17-09-2009, 05:43 PM
Hmm how goes development on this system. Are you able to make a decent game with the development tools available?

There is no special development tools.

I develop with SDL under Windows and Delphi, like mtcmatch, which i post some days before.

coLinux/andLinux ist a linux environment running under Windows, on my system it is a debian linux.
I'm install the default freepascal package for linux and get from svn latest code.

I have install a devkit for gp2x, like http://archive.gp2x.de/cgi-bin/cfiles.cgi?0,1,2,0,14,1609

I have made a cross compiler from svn source with "make crosszipinstall CPU_TARGET=arm CROSSOPT='-CfFPA -dGP2X -darm -dno_smpeg -dFPC_ARM -O- -gl' CROSSBINDIR=/usr/local/gp2xdev/bin BINUTILSPREFIX=gp2x-"

And thats all. The compiled version work with gp2x and gp2xwiz. I develop a unit for direct hardware access for gp2x, but i have not used them in a game.


17-09-2009, 05:58 PM
Thank you thomas. Going to try to build the cross compiler this or next weekend.

18-09-2009, 06:03 AM
You got an error if you cross compile it. There is a missing file, but this happens after building the cross compiler. In /tmp/fpc-pack is the cross compiler and all compiled units for arm-linux. Copy them to fpc lib directory, mostly in /usr/lib/ or /usr/local/lib/, where the i386 files for fpc386 are.

I had changed in svn tree "packages/sdl/src/sdl_mixer.pas" before cross compiling, the unit smpeg not working under gp2x. Replace around line 450 this

5 : ( mp3 : PSMPEG );
with this

{$IFNDEF no_smpeg}
5 : ( mp3 : PSMPEG );

Copy a local version of fpc.cfg to your develop directory and add following lines to it:

#ifdef GP2X
#define gp2x

#ifdef gp2x
#define GP2X

#ifdef gp2x
#define no_smpeg
-Fl/usr/local/devkits/gp2xdev/lib ##// <-- where you have installed you binutils for arm
-Xr/usr/local/devkits/gp2xdev ##<-- where you have installed you binutils for arm

For gp2xwiz i have started to write an opengl es unit, which loads all functions dynamically, but i got an access exception on gp2xwiz, on windows it works now.


18-09-2009, 04:11 PM
If you are also working on opengles libs then have a look on this thread: http://www.pascalgamedevelopment.com/forum/index.php?topic=4909.0

18-09-2009, 05:40 PM
Thanks, i found your post last week. :)

I take your egl.pas and egltypes.pas, rewrite egl.pas using dynamically loading of functions, for better testing, which functions are found or not in installed library.

I have now three units, which load all opengl es function on gp2xwiz, and most, except 6, egl functions. On Windows i got your sample working, on gp2xwiz it breaks at moment. Maybe I get it running tomorrow.


19-09-2009, 06:40 PM
Ok, i have no idea why it doesn't work on gp2x wiz.

- I can compile and execute my opengl es program on wiz
- I get a device context
- I can call eglChooseConfig and get a valid configuration

But calling eglCreateWindowSurface failed with out an error message. The functions seems to be not returning, it terminate the application with out a message.

I have no access to the device, network or serial, so i couldn't debug it.


20-09-2009, 09:50 AM
Is it possible to write a log file to the sd card?

On the gamepark forums there are a few howto's on opengles:

PS does my example use float or integers. My current version uses integers as only that is supported by the mbx-lite.

20-09-2009, 01:03 PM
I have read this thread and i init opengl es like them.

procedure DoOpenGLES();
TEGLAttribut = array[0..128] of EGLint;

procedure AddAttribute(var iPos : Integer; var Attr : TEGLAttribut; aType, aValue : EGLInt);
Attr[iPos] := aType; Inc(iPos);
Attr[iPos] := aValue; Inc(iPos);

iMajorVersion : EGLint;
iMinorVersion : EGLint;
iLoop : Integer;
iConfigs : integer;
eglAttribs : TEGLAttribut;

myeglDisplay : EGLDisplay;
myeglConfig : EGLConfig;
myeglSurface : EGLSurface;
myeglContext : EGLContext;
eglWindow : NativeWindowType;
Info : TSDL_SysWMinfo;
dc : LongWord;
if ( SDL_GetWMInfo(@Info) < 0 ) then begin
raise Exception.Create('SDL_GetWMInfo failed!');

iMajorVersion := 0;
iMinorVersion := 0;
myeglDisplay := 0;
myeglConfig := 0;
myeglSurface := nil;
myeglContext := nil;

eglWindow := Info.window;
dc := GetDC(eglWindow);
if (dc = 0) then begin
raise Exception.Create('GetDC failed!');

eglWindow := OS_CreateWindow();
dc := 0;

Log.Add('window handle is: %d', eglWindow);
myeglDisplay := eglGetDisplay(dc);
if (myeglDisplay = EGL_BAD_DISPLAY) then begin
raise Exception.Create('eglGetDisplay failed!');

if (eglInitialize(myeglDisplay, @iMajorVersion, @iMinorVersion) = 0)
then begin
raise Exception.Create('eglInitialize failed!');

iLoop := 0;
AddAttribute(iLoop, eglAttribs, EGL_RED_SIZE, 5);
AddAttribute(iLoop, eglAttribs, EGL_GREEN_SIZE, 6);
AddAttribute(iLoop, eglAttribs, EGL_BLUE_SIZE, 5);
AddAttribute(iLoop, eglAttribs, EGL_ALPHA_SIZE, 0);
AddAttribute(iLoop, eglAttribs, EGL_SURFACE_TYPE, EGL_WINDOW_BIT);
AddAttribute(iLoop, eglAttribs, EGL_NONE, 0);

if (eglChooseConfig(myeglDisplay, @eglAttribs, @myeglConfig, 1, @iConfigs) = 0)
then begin
raise Exception.Create('eglChooseConfig failed!');

if (iConfigs = 0) then begin
raise Exception.Create('No compatible open gl es mode found!');

myeglSurface := eglCreateWindowSurface(myeglDisplay, myeglConfig, eglWindow, nil);
if (myeglSurface = nil) then begin
if (eglWindow <> 0) then begin
myeglSurface := eglCreateWindowSurface(myeglDisplay, myeglConfig, 0, @eglAttribs);
if (myeglSurface = nil) then begin
raise Exception.Create('eglCreateWindowSurface failed!');

myeglContext := eglCreateContext(myeglDisplay, myeglConfig, nil, nil);
if (myeglContext = nil) then begin
raise Exception.Create('myeglContext failed!');

Log.Add('EGL Init Completed');

eglMakeCurrent(myeglDisplay, myeglSurface, myeglSurface, myeglContext);

for iLoop := 0 to Pred(100) do begin
if ((iLoop mod 2) = 1) then begin
glClearColor(0.6, 0.8, 1.0, 1.0); // clear blue
end else begin
glClearColor(1.0, 1.0, 0.66, 1.0); // clear yellow


eglSwapBuffers(myeglDisplay, myeglSurface);
if (myeglDisplay <> EGL_BAD_DISPLAY) then begin
eglMakeCurrent(myeglDisplay, nil, nil, nil);
// eglDestroySurface(myeglDisplay, myeglSurface);
// eglDestroyContext(myeglDisplay, myeglContext);
// eglTerminate(myeglDisplay);

ReleaseDC(eglWindow, dc);

function eglCreateWindowSurface(dpy : EGLDisplay; config : EGLConfig; win: NativeWindowType; const attrib_list: PEGLint) : EGLSurface;
if Assigned(peglCreateWindowSurface) then begin
Result := peglCreateWindowSurface(dpy, config, win, attrib_list);
Log.Add('eglCreateWindowSurface called');

raise Exception.CreateFmt(cmsgUnknowProc, ['eglCreateWindowSurface']);

I write a log file and after calling eglCreateWindowSurface it stops, no entry is written, that eglCreateWindowSurface was called. On Windows it works.

So, it seems to be, that called function, in peglCreateWindowSurface, was not returning.


27-12-2009, 08:43 AM
It is past christmas and still no gamepark wiz delivered by the postman :-( . Luckily i did not pay in advance and opted to pay the postman when it is deliverd :-) .
For me i give up on the gamepark wiz and go with the beagleboard. Development for that goes a bit slow but hello world from freepascal works and so does dynamic calling libraries.

@KidPaddle are you sure the ogles .so files can be found from your application. I made mistakes with that ending up with the .so files not found and getting thing like you experience... If you have a hello world working you can use that to output text on screen whilst preparing opengles and detect what is happening ...

27-12-2009, 04:26 PM
I'm sure. I load dynamically around 160 opengl es functions and i can call some of them. I will make a new try, someone has make a Ethernet over USB and now debugging is much easier.