Ikari Sdl With Gles Isnt Working


Pickle

Mega GP Mania
Joined
May 30, 2006
Messages
5,518
Location
Detroit, Michigan
Website
Visit site
Anyone get this lib to open an GLES window?
I figured Ikari might have built it with GLES support, but i keep getting a message it isnt supported. Im opening a 320x240x16 with the SDL_OPENGL flag set.

I didnt try to build the lib from scratch yet...
 
Pickle said:
Anyone get this lib to open an GLES window?
I figured Ikari might have built it with GLES support, but i keep getting a message it isnt supported. Im opening a 320x240x16 with the SDL_OPENGL flag set.

I didnt try to build the lib from scratch yet...

For Caanoo, I don't implemented it yet. Sorry.
(It maybe available until next week.)
 
Last edited by a moderator:
ikari said:
Pickle said:
Anyone get this lib to open an GLES window?
I figured Ikari might have built it with GLES support, but i keep getting a message it isnt supported. Im opening a 320x240x16 with the SDL_OPENGL flag set.

I didnt try to build the lib from scratch yet...

For Caanoo, I don't implemented it yet. Sorry.
(It maybe available until next week.)

whoops i meant the wiz (I will move the topic)

Update: I tried a few more things yesterday.
Use LD_PRELOAD to make sure the SDL lib is used
Recompiled the lib from source to be certain gles support was built in
Tried some changes from the application side

Nothing seems to help, im always getting null from SDL_SetVideoMode.
 
Last edited by a moderator:
Pickle said:
ikari said:
Pickle said:
Anyone get this lib to open an GLES window?
I figured Ikari might have built it with GLES support, but i keep getting a message it isnt supported. Im opening a 320x240x16 with the SDL_OPENGL flag set.

I didnt try to build the lib from scratch yet...

For Caanoo, I don't implemented it yet. Sorry.
(It maybe available until next week.)

whoops i meant the wiz (I will move the topic)

Update: I tried a few more things yesterday.
Use LD_PRELOAD to make sure the SDL lib is used
Recompiled the lib from source to be certain gles support was built in
Tried some changes from the application side

Nothing seems to help, im always getting null from SDL_SetVideoMode.

I've recompiled the lib with OpenGL ES support, then it works.

1. You have to rebuild the SDL lib to enable OpenGL ES.
(You have to copy gl.h and egl.h to your toolchain's "include/GLES" directory.)
./configure --host=(arm-your-toolchain) --build=(arch) --enable-pthreads --enable-pthread-sem --enable-threads --disable-video-fbcon --disable-video-directfb --disable-video-x11 --disable-arts --disable-esd --disable-pulseaudio --enable-video --enable-video-gp2xwiz

You don't have to install it into your toolchain. Copy SDL-1.2.13/build/.libs/libSDL-1.2.so.0.11.2 to your SD card, and rename it to libSDL-1.2.so.0

2. Build your application with your own toolchain.
(You have to dynamic link SDL, glport and opengles_lite libraries.)

3. Copy your application file and libSDL-1.2.so.0 to same directory on your SD card.
(You don't have to use LD_PRELOAD.)

See the sample code on below for more information.

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

#include <SDL/SDL.h>
#include <GLES/gl.h>

#define _INT_TO_FIXED(i) ((GLfixed)((i)<<16))
#define _FLOAT_TO_FIXED(i) ((GLfixed)((i)*65536.0f))

void Terminate()
{
	chdir("/usr/gp2x");
	execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
}

int main()
{
	if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) <0) return -1;

	atexit(Terminate);

        //WARNING: The surface "screen" is just a dummy surface for save screen information.
	SDL_Surface *screen = SDL_SetVideoMode(320, 240, 16, SDL_OPENGL);
	if(!screen) return -1;
	SDL_Joystick *joy;

	/* 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 ());
		}
	}

	glClearColorx(0,0,0,0);
	glViewport(0,0,320,240);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	glOrthox(0,_INT_TO_FIXED(320),0,_INT_TO_FIXED(240),0,_INT_TO_FIXED(-1));

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glDisable(GL_CULL_FACE);
	glDisable(GL_LIGHTING);
	
	glEnableClientState(GL_VERTEX_ARRAY);
	const GLfixed vertices[]={_FLOAT_TO_FIXED(-0.5f),_FLOAT_TO_FIXED(-0.5f),_FLOAT_TO_FIXED(-0.5f),_FLOAT_TO_FIXED(0.5f),
					_FLOAT_TO_FIXED(0.5f),_FLOAT_TO_FIXED(-0.5f),_FLOAT_TO_FIXED(0.5f),_FLOAT_TO_FIXED(0.5f)};

	int done =0;
	while(!done)
	{
		SDL_Event event;
		while(SDL_PollEvent(&event))
		{
			if(event.type == SDL_JOYBUTTONDOWN)
				done=1;
		}

		glClear(GL_COLOR_BUFFER_BIT);

		glColor4x(_INT_TO_FIXED(1),0,_INT_TO_FIXED(1),_INT_TO_FIXED(1));

		glPushMatrix();
		glTranslatex(_FLOAT_TO_FIXED((float)64*0.5f),_FLOAT_TO_FIXED((float)64*0.5f),0);
		glScalex(_INT_TO_FIXED(64),_INT_TO_FIXED(64),0);

		glVertexPointer(2,GL_FIXED,0,vertices);
		glDrawArrays(GL_TRIANGLE_STRIP,0,4);
		glPopMatrix();

		SDL_GL_SwapBuffers();
		SDL_Delay(30);
	}

	SDL_JoystickClose(joy);
	SDL_Quit();

	return 0;
}
 
Last edited by a moderator:
sorry Ikari this was my mistake, i didnt look at the config log closely enough and it couldnt find my gl headers so opengles was never compiled in. I fixed that and it indeed works.
thanks for this work, it really makes other stuff easier to work with.

Im working on dxx (descent), which i can now get to the menu thanks to your lib. I get a segfault though....back to debugging.
 
What is "--build=(arch)" supposed to actually be if you're using a Linux-based toolchain?
 
HunterZ said:
What is "--build=(arch)" supposed to actually be if you're using a Linux-based toolchain?
The platform you're building on. You can usually omit this.
 
Last edited by a moderator:
Back
Top