Caanoo / WIZ Howto For Opengl-es 1.1 Lite On The Wiz


Pickle

Mega GP Mania
Joined
May 30, 2006
Messages
5,518
Location
Detroit, Michigan
Website
Visit site
To keep the forums flooded with the opengl questions im starting this thread about it. Im not an opengl expert by any means but I can probably get someone who at least started with wiz's opengl method.

1. You need the opengl es library called libopengles_lite.so, this should do in /lib. The rar on the archive has a installer script to do so.

2. The libopengles_lite.so has function calls that need to be defined by the application or another library. I created a library to do this and called it libwizGLES.so. There source floating around in a file called port.cpp which has all of the functions. You can find this in the opengl es demos archive. You can also get the prebuilt shared library built by me in the latest glquake beta. (it also has nanogl shared lib too if you want that)
pickle.gp2x.de/glquake.zip

3. Initializing Opengl-es

global variables (use attrib_list_fsaa for fsaa)
CODE
EGLDisplay glDisplay;
EGLConfig glConfig;
EGLContext glContext;
EGLSurface glSurface;

NativeWindowType hNativeWnd = 0;

const char *gl_vendor;
const char *gl_renderer;
const char *gl_version;
const char *gl_extensions;

EGLint attrib_list_fsaa[] =
{
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BUFFER_SIZE, 0,
EGL_DEPTH_SIZE, 16,
EGL_SAMPLE_BUFFERS, 1,
EGL_SAMPLES, 4,
EGL_NONE
};

EGLint attrib_list[] =
{
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BUFFER_SIZE, 0,
EGL_DEPTH_SIZE, 16,
EGL_NONE
};


Start egl and get the surface (take notice OS_CreateWindow(), this is in libwizGLES)
CODE
EGLint numConfigs;
EGLint majorVersion;
EGLint minorVersion;

// Create native window.
printf( "VID_Init: Creating the window\n" );
hNativeWnd = OS_CreateWindow();
if(!hNativeWnd)
printf( "VID_Init: OS_CreateWindow Failed\n" );

glDisplay = eglGetDisplay( (NativeDisplayType)0 );
if( glDisplay == EGL_NO_DISPLAY )
{
printf( "GL No Display failed\n" );
}

if( !eglInitialize( glDisplay, &majorVersion, &minorVersion ) )
{
printf( "GL Init failed\n" );
}
if( !eglChooseConfig( glDisplay, attrib_list, &glConfig, 1, &numConfigs ) )
{
printf( "GL Config failed\n" );
}
glContext = eglCreateContext( glDisplay, glConfig, NULL, NULL );
if( glContext==0 )
{
printf( "GL Context failed\n" );
}
glSurface = eglCreateWindowSurface( glDisplay, glConfig, hNativeWnd, NULL );
if( glSurface==0 )
{
printf( "GL Surface failed\n" );
}
printf( "EGL Init Completed\n" );

eglMakeCurrent( glDisplay, glSurface, glSurface, glContext );

gl_vendor = (const char*)glGetString (GL_VENDOR);
printf("GL_VENDOR: %s\n", gl_vendor);
gl_renderer = (const char*)glGetString (GL_RENDERER);
printf("GL_RENDERER: %s\n", gl_renderer);

gl_version = (const char*)glGetString (GL_VERSION);
printf("GL_VERSION: %s\n", gl_version);
gl_extensions = (const char*)glGetString (GL_EXTENSIONS);
printf("GL_EXTENSIONS: %s\n", gl_extensions);


Flip the framebuffer
CODE
eglSwapBuffers(glDisplay,glSurface);


Thats basically it. Ive also put up the only spec that GPH has leaked.
pickle.gp2x.de/LF1000_spec.pdf
Everything else is opengles, this should be all for the wiz specifics. I hope its of use.
 
Wow thanks, this is what i need :). Only two thing: which files I've to include? And how I have to modify my makefile?(what libraries I've to link?)
EDIT: Can you upload an example project using libcastor and openGL ES?
Thanks
EDIT2: If i try to compile i get these errors:
QUOTE
In file included from source/main.cpp:19:
/home/aurelio/devkitwiz/arm-openwiz-linux-gnu/include/wizGLES.h:30: error: '___OAL_MEMORY_INFORMATION__' was not declared in this scope
/home/aurelio/devkitwiz/arm-openwiz-linux-gnu/include/wizGLES.h:30: error: 'pMemoryInfomation' was not declared in this scope
/home/aurelio/devkitwiz/arm-openwiz-linux-gnu/include/wizGLES.h:30: error: expected primary-expression before 'int'
/home/aurelio/devkitwiz/arm-openwiz-linux-gnu/include/wizGLES.h:30: error: initializer expression list treated as compound expression

Probably I'm making some errors...
 
EDIT: Can you upload an example project using libcastor and openGL ES?
Thanks
EDIT2: If i try to compile i get these errors:
QUOTE
In file included from source/main.cpp:19:
/home/aurelio/devkitwiz/arm-openwiz-linux-gnu/include/wizGLES.h:30: error: '___OAL_MEMORY_INFORMATION__' was not declared in this scope
/home/aurelio/devkitwiz/arm-openwiz-linux-gnu/include/wizGLES.h:30: error: 'pMemoryInfomation' was not declared in this scope
/home/aurelio/devkitwiz/arm-openwiz-linux-gnu/include/wizGLES.h:30: error: expected primary-expression before 'int'
/home/aurelio/devkitwiz/arm-openwiz-linux-gnu/include/wizGLES.h:30: error: initializer expression list treated as compound expression

Probably I'm making some errors...
I put up the source to nanoGL and wizGLES pickle.gp2x.de/wiz3d.zip
It should have the headers your missing (look in the linux folder of the wizGLES project)

Just so your clear libcastor has nothing to do with opengles
 
Last edited by a moderator:
mmm I can't resolve, sorry I'm noob in wiz coding...can you upload an example using OpenGL ES?
Thanks
 
chickendung posted on May 22 2009 at 01:48 PM said:
Do you have a donation site available, Pickle? I can't use my gift card on Paypal, but if there is another way to donate to you, then I will if you remake PicoDrive so there is no tearing. :D
Ive actually never taken donations for anything ive done. I one point gave my reasoning, it basically comes down to the fact that I use a lot of software from other devs at no cost. Although getting the hw for free is a very nice gesture and i think most devs feel this way.
The tear issue is across the board, its in eveything, even glquake. Im also not touching picodrive notaz handles that.

Can we please use this thread for wiz opengl es discussion?
 
Last edited by a moderator:
hi Pickle, I got the program compiling, but it doesn't work, maybe i've missed something.
This is my project, can you take a look at the code?
Thanks
 
Hi,

I compiled the example code for OpenGL ES successful, but when I start it on the Wiz, I only see an hourglass with the text "loading..." forever. What's wrong?

Here's the source code: http://nopaste.info/1d2a37656c.html

I compiled it like this:

CODE
arm-openwiz-linux-gnu-g++ -I. -lwizGLES -L. main.cpp -lnanoGL -ldl -o opengl_test.gpe
 
Hi, now it works, but it doesn't show anthing...
This is my code
CODE
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <fstream>

#include <fcntl.h>

#include <sys/ioctl.h>

#include <stdint.h>
#include <iostream>
#include <cstring>
#include <sys/mman.h>
#include <unistd.h>
extern "C" {
#include <castor.h>
#include <castor_extra.h>
}
#include "draw.h"
#include <GLES/libogl.h>
#include "GL/nanogl.h"

#include "GL/gl.h"

#include "GL/egl.h"
#include "GL/glesinterface.h"
using namespace std;


typedef struct {

uint16_t pressure;

uint16_t x;

uint16_t y;

uint16_t pad;

struct timeval stamp;

} TS_EVENT;



struct Stylus{

int x, y, pressure, calibX, calibY, NewPress, Held, Released;

}Stylus;

void CalibTouch(){

int fd = open( "/dev/touchscreen/wm97xx", O_RDONLY | O_NOCTTY );

TS_EVENT ts_event;

do{

read(fd, &ts_event, sizeof(TS_EVENT));

}while(ts_event.pressure!=0);

Stylus.calibX = ((ts_event.x-200)*320/3750)/4;

Stylus.calibY = (((ts_event.y-200)*240/3750))/4;

Stylus.x = 160;

Stylus.y = 120;

close(fd);

}



void UpdateStylus(){

int fd = open( "/dev/touchscreen/wm97xx", O_RDONLY | O_NOCTTY );

TS_EVENT ts_event;

read(fd, &ts_event, sizeof(TS_EVENT));

Stylus.NewPress = 0;

if(ts_event.pressure>0){

Stylus.x = ((ts_event.x-200)*320/3750)-Stylus.calibX;

Stylus.y = (240 - ((ts_event.y-200)*240/3750))-Stylus.calibY;

if(Stylus.Held==0){

Stylus.NewPress = 1;

Stylus.Held = 1;

}

}else{

Stylus.Held = 0;

}

Stylus.pressure = ts_event.pressure;

close(fd);

}

EGLDisplay glDisplay;
EGLConfig glConfig;
EGLContext glContext;
EGLSurface glSurface;

NativeWindowType hNativeWnd = 0;

const char *gl_vendor;
const char *gl_renderer;
const char *gl_version;
const char *gl_extensions;

EGLint attrib_list_fsaa[] =
{
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BUFFER_SIZE, 0,
EGL_DEPTH_SIZE, 16,
EGL_SAMPLE_BUFFERS, 1,
EGL_SAMPLES, 4,
EGL_NONE
};

EGLint attrib_list[] =
{
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
EGL_BUFFER_SIZE, 0,
EGL_DEPTH_SIZE, 16,
EGL_NONE
};

int main(int argc, char* argv[]) {
if(lc_init() < 0) {
printf("Could not start libcastor\n");
return 1;
}
EGLint numConfigs;
EGLint majorVersion;
EGLint minorVersion;

// Create native window.
printf( "VID_Init: Creating the window\n" );
hNativeWnd = OS_CreateWindow();
if(!hNativeWnd)
printf( "VID_Init: OS_CreateWindow Failed\n" );

glDisplay = eglGetDisplay( (NativeDisplayType)0 );
if( glDisplay == EGL_NO_DISPLAY )
{
printf( "GL No Display failed\n" );
}

if( !eglInitialize( glDisplay, &majorVersion, &minorVersion ) )
{
printf( "GL Init failed\n" );
}
if( !eglChooseConfig( glDisplay, attrib_list, &glConfig, 1, &numConfigs ) )
{
printf( "GL Config failed\n" );
}
glContext = eglCreateContext( glDisplay, glConfig, NULL, NULL );
if( glContext==0 )
{
printf( "GL Context failed\n" );
}
glSurface = eglCreateWindowSurface( glDisplay, glConfig, hNativeWnd, NULL );
if( glSurface==0 )
{
printf( "GL Surface failed\n" );
}
printf( "EGL Init Completed\n" );

eglMakeCurrent( glDisplay, glSurface, glSurface, glContext );

gl_vendor = (const char*)glGetString (GL_VENDOR);
printf("GL_VENDOR: %s\n", gl_vendor);
gl_renderer = (const char*)glGetString (GL_RENDERER);
printf("GL_RENDERER: %s\n", gl_renderer);

gl_version = (const char*)glGetString (GL_VERSION);
printf("GL_VERSION: %s\n", gl_version);
gl_extensions = (const char*)glGetString (GL_EXTENSIONS);
printf("GL_EXTENSIONS: %s\n", gl_extensions);

glViewport(0, 0, 319, 239);
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix

// Calculate The Aspect Ratio Of The Window
//gluPerspective(45.0f,(GLfloat)319/(GLfloat)239,0.1f,100.0f);
glOrtho(0.f, 1.f, 0.f, 1.f, 0.f, 1.f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity();
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
bool run = 1;
while(run) {
//UpdateStylus();
/*if(Stylus.Held){
x = Stylus.x;
y = Stylus.y;
lc_fb1[x+y*320] = ARGB16(1, 31, 31, 31);
}*/
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
glLoadIdentity();
glTranslatef(-1.5f,0.0f,-6.0f);
glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd();

eglSwapBuffers(glDisplay,glSurface);
if(lc_getbuttons() & BTN_MENU) {
run = 0;
}
usleep(16000);
}

lc_exit();
chdir("/usr/gp2x");

execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
return 0;
}


and this is my makefile:
CODE
OPEN2X = /home/aurelio/devkitwiz/arm-openwiz-linux-gnu
HOST = arm-openwiz-linux-gnu

CC = $(OPEN2X)/bin/$(HOST)-gcc
CXX = $(OPEN2X)/bin/$(HOST)-g++











TARGET := $(shell basename $(CURDIR))
SOURCES := source

LIBS := -lcastor -lcastor_extra -lpng -lz -lwizGLES -lnanoGL -ldl

LIBDIRS := $(OPEN2X)

CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))

all:
$(CXX) $(SOURCES)/*.cpp -L$(LIBDIRS)/lib -I$(LIBDIRS)/include $(LIBS) -o $(TARGET).gpe


clean:
rm -f *.gpe

What is wrong?
Thanks
 
Can someone post the console (as in text terminal) output of the example of the tutorial? I'd like to know what are the values of gl_vendor, gl_renderer, gl_version and gl_extensions :)
 
Does anyone feel like writing a small benchmark? Just something which figures out how many rotated and blended 16x16 sprites can be rendered before it drops below 60fps.

It will probably take 3 weeks till my Wiz arrives and I would really like getting some rule of thumb figure before that. E.g. such a benchmark with 2x2 sprites would outline the general geometry overhead, 16x16 the fillrate/geometry budget for common game scenarios, and 64x64 is basically just about fillrate.

Right now I don't even have a clue what kind of performance I can expect.
 
aho posted on May 24 2009 at 03:27 PM said:
Does anyone feel like writing a small benchmark? Just something which figures out how many rotated and blended 16x16 sprites can be rendered before it drops below 60fps.

It will probably take 3 weeks till my Wiz arrives and I would really like getting some rule of thumb figure before that. E.g. such a benchmark with 2x2 sprites would outline the general geometry overhead, 16x16 the fillrate/geometry budget for common game scenarios, and 64x64 is basically just about fillrate.

Right now I don't even have a clue what kind of performance I can expect.
quake 1 get a little over 20 fps

Aurelio: I would get rid of libcastor too, it actually sets the screen in the init portion, it want it only for controls you can use gpio just like we have done for the gp2x
 
Last edited by a moderator:
Pickle posted on May 24 2009 at 07:31 PM said:
Jan-Nik: that program does nothing..., you init opengles and then quit.
Yes, but even that doesn't seem to work. It gets stuck in this strange loading screen from GPH.
 
Last edited by a moderator:
Pickle posted on May 24 2009 at 09:12 PM said:
quake 1 get a little over 20 fps
[...]
That doesn't actually tell me much about the graphics throughput since the bottleneck is probably elsewhere. That's why I'd like to see a simple graphics centered benchmark.
 
Last edited by a moderator:
I success to compile the wizGLES lib but there are the problem when linking.

CODE
/home/sunya/arm-openwiz-linux-gnu/bin/arm-openwiz-linux-gnu-g++ main.cpp -I/home/sunya/arm-openwiz-linux-gnu/include -L/home/sunya/arm-openwiz-linux-gnu/lib -lopengles_lite -lwizGLES -o gltest.gpe
/home/sunya/arm-openwiz-linux-gnu/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: ERROR: /home/sunya/arm-openwiz-linux-gnu/lib/libopengles_lite.so uses VFP instructions, whereas gltest.gpe does not
/home/sunya/arm-openwiz-linux-gnu/bin/../lib/gcc/arm-openwiz-linux-gnu/4.2.4/../../../../arm-openwiz-linux-gnu/bin/ld: failed to merge target specific data of file /home/sunya/arm-openwiz-linux-gnu/lib/libopengles_lite.so
collect2: ld returned 1 exit status
make: *** [gltest] Error 1


I think my "opengles_lite.so" have something differrent. This is my Makefile.
CODE
OPEN2X = /home/sunya/arm-openwiz-linux-gnu
HOST = arm-openwiz-linux-gnu

CC = $(OPEN2X)/bin/$(HOST)-gcc
CXX = $(OPEN2X)/bin/$(HOST)-g++
AR = $(OPEN2X)/bin/$(HOST)-ar
RANLIB = $(OPEN2X)/bin/$(HOST)-ranlib
INCLUDE = $(OPEN2X)/include
LIBS = $(OPEN2X)/lib
#OPTS = -mcpu=arm926ej-s -mtune=arm926ej-s -mfpu=vfp -mfloat-abi=softfp

all: gltest

gltest:
$(CXX) main.cpp $(OPTS) -I$(INCLUDE) -L$(LIBS) -lopengles_lite -lwizGLES -o gltest.gpe

clean:
rm -f *.o
rm -rf lib*

I tried to enable the VFP option in OPTS but no luck.
 
Pickle posted on May 24 2009 at 09:12 PM said:
aho posted on May 24 2009 at 03:27 PM said:
Does anyone feel like writing a small benchmark? Just something which figures out how many rotated and blended 16x16 sprites can be rendered before it drops below 60fps.
It will probably take 3 weeks till my Wiz arrives and I would really like getting some rule of thumb figure before that. E.g. such a benchmark with 2x2 sprites would outline the general geometry overhead, 16x16 the fillrate/geometry budget for common game scenarios, and 64x64 is basically just about fillrate.

Right now I don't even have a clue what kind of performance I can expect.
quake 1 get a little over 20 fps

Aurelio: I would get rid of libcastor too, it actually sets the screen in the init portion, it want it only for controls you can use gpio just like we have done for the gp2x

So how I have to set the screen?Which layer I have to use?
Thanks
 
Last edited by a moderator:
Jan-Nik posted on May 24 2009 at 05:38 PM said:
I compiled the example code for OpenGL ES successful, but when I start it on the Wiz, I only see an hourglass with the text "loading..." forever. What's wrong?

Here's the source code: http://nopaste.info/1d2a37656c.html

I compiled it like this:

CODE
arm-openwiz-linux-gnu-g++ -I. -lwizGLES -L. main.cpp -lnanoGL -ldl -o opengl_test.gpe

I tried to locate the error and it seems that eglGetDisplay causes a segmentation fault. How can I fix it?
 
Last edited by a moderator:
Back
Top