views:

98

answers:

2

I am writing an OpenGL game which will hopefuflly be for both linux and iphoneOS, I basically want to be able to build using the OpenGL ES 1.5 headers and run it on my linux desktop. Can I do this? IE, I want to only use the subset of API calls common between OpenGL and OpenGL-ES.

Doing the above and linking with normal libGL.a from my system gets me my screen but I seem to be able to do nothing but change the scene background colour.

+1  A: 

I've done exactly that, and it worked well for me.

There are a bunch OpenGL|ES extensions that aren't available on standard OpenGL but very nice to have on a low spec platform. glDrawTexImage is such an extension. Emulating these extensions using a hand full of desktop OpenGL-calls is not a big deal though.

Also OpenGL|ES supports the fixed-point data-format for most entrypoints. Take glClearColorx for example. These aren't available for the desktop OpenGL, so you have to write a wrapper if you want to use them. It's a bit more work if you also store your vertex data in this format.

Oh - and note that OpenGL|ES does not come with the glu-library. You can use it on the desktop, but if you do you'll have to reimplement them later (see the 100 questions about gluLookAt and gluUnproject).

Nils Pipenbrinck
Thanks, good to know I have a chance of success.
IanNorton
+1  A: 

There is no such thing as OpenGL ES 1.5. Did you mean 1.1 ?

Also, how do you get a window ? This is platform specific.

In any case, you still should compile against the header that corresponds to the lib you will link against. You don't know for sure what the header sets up (e.g. on windows, which you don't care about but still, calling conventions are specified in there).

There are also some calls that don't map well between the 2. E.g. APIs that are only using doubles in GL are float in GLES (from the ES spec):

The double-precision only commands DepthRange, Frustum, and Ortho are replaced with single-precision or fixed-point variants

So in short, there is a bit more work than just using the same code, although the work in question is still minimal if you stick to GL ES subset.

Bahbar
Yes, I did mean ES 1.1. I have managed to get my program to render properly now.
IanNorton