jmacey
Posts: 135
Joined: Thu May 31, 2012 1:05 pm

OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 8:45 am

Hi,

I've been doing some GL ES programming and am getting some very strange results. So I thought I would see if anyone else has got and info etc. At present I'm using the debian build with the latest kernel sources.

Some things I've noticed so far and if anyone has any info it would be good.

1). There seems to be a lot of deprecated function links in the libGLESv2.so library. Using nm I have discovered at least glColor[] glLight[] glMaterial[] glScale glNormal[] ...

Whilst these will not build if you include the gl2 headers it seems strange that they are still in the lib unless it is a core profile + compatibility lib (i.e. ES1.1 and ES2 combined)?

2). There are no Vertex Array Objects which for me is a real pain as my code I'm porting uses them extensively ( and the iPhone version of OpenGL ES 2 does implement them) is there any chance that these will be included in a later release.

I have managed to get some simple VBO rendering, however If I create two buffers one for Vertex data and one for Colour the second buffer doesn't seem to give the correct colours.

If I use interlaced data ( usually u,v,nx,ny,nz,x,y,z) I just get a mess of vertices and it seems my vertex attribute pointers are off somehow. I know that the data / offsets are correct for Normal OpenGL on Mac / Linux and iPhone so not sure of the main problem at the moment. If anyone has any insight to this I would be good to start sharing this information.

Also are there any documents on what is and isn't implemented in the GL drivers etc?

Cheers

Jon

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 8:53 am

I'm just paddling in the surf myself, so I can't give any definitive answers. I note that the HelloTriangle demo (which is not hello triangle and doesn't display a triangle) is GL ES 1.1 and HelloTriangle2 (which displays a cube) is GL ES 2.0. However I haven't looked at the details of how those two are linked.

jmacey
Posts: 135
Joined: Thu May 31, 2012 1:05 pm

Re: OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 9:05 am

looking at the makefile.include for both it uses

-lGLESv2 so I presume that it's a combined library (on the vanilla install with the old kernel there are two different libs so I presume they have been combined for ease)

IIRC glScale etc were still not part of ES 1.1 so not sure why that is in the lib ( they are in the gl.h headers). Still banging my head against a wall trying to draw a shaded sphere at present. I did have something working but seem to have broken something. I may do another vanilla install of the latest debian and see what I can find different.

dattrax
Posts: 52
Joined: Sat Dec 24, 2011 5:09 pm

Re: OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 11:48 am

1) its a mixed GLES1.1 / 2.0 library. Whilst glScale() / glTranslate() are not in ES2.0, they are still present in ES1.1. The entry points need to be there, but the driver checks the bound context type before executing.

2) All things are possible, but don't hold your breath.

On the topic of VBO, if you have a sample then this would help.

User avatar
RichardUK
Posts: 235
Joined: Fri Jun 01, 2012 5:12 pm

Re: OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 11:55 am

Although I can't help with your issue I feel your pain. For quite a few years I was developing on many embedded systems (pre release dev boards) with GLES 2 and found quite a few 'issues'. For buffer objects I ended up wrapping it in my own code and switched between a kind of 'emulation' for devices I knew failed and uses the proper code for ones that did work. Not ideal.

One thing I did find is that some drivers are more strict / conformant with the order stuff is done. I have had code that worked but failed on new hardware. After a few emails it turned out I was calling a set of shader functions at the wrong time.

If you think it may be a bug in the driver then be worth reporting it. For best results put together a small test app that the driver writers can compile. They like single source files. They will then be able to confirm the bug or not. They can work from just a binary too. But in all cases you get better feedback if you can supply code that works on platform A but not on their hardware. At worst they will give you a work around.

jmacey
Posts: 135
Joined: Thu May 31, 2012 1:05 pm

Re: OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 1:01 pm

It does actually seem to be an order thing, I managed to get my library working now (with some hard coded emulation of how Vertex Array objects work) I'm now in the process of wrapping my own VAO class.

Here is a demo http://www.youtube.com/watch?v=eF81aRHs ... e=youtu.be

Unfortunately I'm also in the middle of exam marking (C++ and OpenGL questions as well ;-) so only doing it intermittently at present, but hope to have a working version running soon.

Pickle
Posts: 68
Joined: Tue Sep 20, 2011 5:09 pm

Re: OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 1:21 pm

I would recommend dropping any use of matrix operations with the GL library and either create your own math lib or use a 3rd party lib.
I recommend the CML math library. http://cmldev.net/

These links are useful for supported standard API
1.X : http://www.khronos.org/opengles/sdk/1.1/docs/man/
2.0 : http://www.khronos.org/opengles/sdk/docs/man/

Iphone is the only GLESv2 ive read about supporting VAO's.

For your VBO problem sounds like a size, stride, or offset problem.
Your using GL_UNSIGNED_SHORT for your indices size?

jmacey
Posts: 135
Joined: Thu May 31, 2012 1:05 pm

Re: OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 1:34 pm

My library does all the math operations etc as well as Camera, Light, Texture Material , Shaders Primitives, Text etc (all OpenGL 3.2 core profile for Desktop) so it's just a matter of porting the main code over to ES (and replacing the Qt dependancies from the Desktop version with more lightweight stuff such as ImageMagick and freetype )

The main problem I had was re-enabling the vertex attributes in the correct order stride etc was all fine. (using ((float *)NULL + (index) ) for the index into the interleaved array of data. I'm in the process of writing the VAO emulation so it should be an easy port from one system to the other soon.

Pickle
Posts: 68
Joined: Tue Sep 20, 2011 5:09 pm

Re: OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 1:38 pm

I use:

Code: Select all

 #define BUFFER_OFFSET(i)    ((uint8_t *)NULL + (i))
Edit: But I store the offset index by byte size

Code: Select all

#define SIZEOF_POSITION             (SIZEOF_FLOAT*3)
#define SIZEOF_NORMAL               (SIZEOF_FLOAT*3)
#define SIZEOF_TEXCOORD             (SIZEOF_FLOAT*2)
#define SIZEOF_COLOR                (SIZEOF_UBYTE*4)
So I think your float* offset would be the same as long as you are counting 1 per 4 byte float

jmacey
Posts: 135
Joined: Thu May 31, 2012 1:05 pm

Re: OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 3:16 pm

It's all working well now decided to push the gpu

http://youtu.be/yFqSF37v1uM
and 3 bunnies ;-)

http://youtu.be/uMxtTFI1hFs

The models are statically linked into my lib so I have to cross compile them on the mac as the pi runs out of virtual memory building the lib, but apart from that a very impressive GPU for such a small machine.

dattrax
Posts: 52
Joined: Sat Dec 24, 2011 5:09 pm

Re: OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 3:20 pm

Have the models been stripped, or are they discrete triangles?

Jim

jmacey
Posts: 135
Joined: Thu May 31, 2012 1:05 pm

Re: OpenGL ES 2 Compatibility and weird behaviours

Thu Jun 07, 2012 4:06 pm

They are discrete triangles, basically I have a program that reads an OBJ file and converts it to triangles / normals /uv's per face. It's done for quick tests rather than speed / efficiency of storage. I'm about to test some of my index array models soon

Return to “C/C++”