PDA

View Full Version : Porting OpenGL sw to OpenGL-ES, help needed



yipton
10-27-2004, 09:17 PM
I'm trying to port an OpenGL game to an embedded device running OpenGL-ES. I'm fairly good at porting stuff, but know *very* little of OpenGL, so bear with me. So far, I've got the game compiled and running under WIN32 using both he video card's OpenGL and MESA 6.2. I've also done an analysis of OGL APIs the game uses and whether those APIs exists in OGL-ES 1.1. It doesn't look too bad.

I'm now trying to modify the sw to only use OGL functions that are also in OGL-ES. That way I can test the OGL --> OGL-ES transition fully under WIN32 before the final port to the embedded device I'm ultimately porting it to. That's where MESA comes in because it supports things like glMultiTexCoord4f.

First specific question....

The game uses the following OGL commands to render a character in its menu system:
glBindTexture (GL_TEXTURE_2D, texnum);
glBegin (GL_QUADS);
glTexCoord2f (fcol, frow);
glVertex2f (x, y);
glTexCoord2f (fcol + size, frow);
glVertex2f (x+8, y);
glTexCoord2f (fcol + size, frow + size);
glVertex2f (x+8, y+8);
glTexCoord2f (fcol, frow + size);
glVertex2f (x, y+8);
glEnd ();

Do I assume correctly that I need to replace this using OGL-ES's glMultiTexCoord4f?

I've tried both
glMultiTexCoord4f(draw_chars->texnum, fcol, fcol+size, frow, frow+size);
and
glMultiTexCoord4f(draw_chars->texnum, x, y, x+8, y+8);
Both didn't work, the menu was not visible.

Any help would be appreciated!

cheers, Pete

[ October 28, 2004: Message edited by: yipton ]

KristofBeets
10-28-2004, 03:13 AM
<BLOCKQUOTE><font size="1" face="Arial, Verdana, Helvetica, sans-serif">quote:</font><HR>Originally posted by yipton:

glBegin (GL_QUADS);
glTexCoord2f (fcol, frow);
glVertex2f (x, y);
glTexCoord2f (fcol + size, frow);
glVertex2f (x+8, y);
glTexCoord2f (fcol + size, frow + size);
glVertex2f (x+8, y+8);
glTexCoord2f (fcol, frow + size);
glVertex2f (x, y+8);
glEnd ();
<HR></BLOCKQUOTE>

The glBegin / glEnd technique of submitting geometry is not supported by OGLES. You must draw using glDrawElements or glDrawArrays.

Normally the code above would draw a quad, and between Begin and End 4 vertices are defined that form this quad. In OGLES you need to place those 4 vertex definitions (4 positions using glVertexf and 4 2D texcoords using glTexCoord2f in your code) in a buffer which you point to and then draw using the commands mentioned above. Check the documentation for more help.

K-

[ October 28, 2004: Message edited by: Kristof - PowerVR ]

hmwill
10-29-2004, 10:07 PM
Just two comments:

Instead of Mesa you could use either the reference implementation or the desktop version of Hybrid's library.

There is a conversion library sf.net/projects/dogless (http://sf.net/projects/dogless) that could potentially speed up the conversion; with a performance penalty, of course.

The conversion of float to fixed is going to be the main effort if you want to achieve optimal performance for devices, especially those featuring an ARM processor (most devices I am aware of do not have an FPU).

- HM

yipton
10-30-2004, 05:17 AM
Using your suggestion and this posting http://khronos.org/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=4&t=000115
I've managed to rewrite all quads drawing using triangles. As with a lot of things, it's quite simple once you know how :-)
Next step is to rewrite the polygons, but I get the general idea now.

The game indeed uses fp but it's just too much work to change that. I take my changes and stick with fp.

Many thanks for your help! Rest assured I will be posting other newbie questions as I go along :-D

cheers, Pete