[Solution] SWT + jogl -> z ordering issues

Hi,

i’m trying to use jogl with SWT. Everything is up and running with the latest jogl-release from May 2008. Somehow i have problems with z ordering although GL_DEPTH_TEST is enabled.

Below you will find my GLContext creation code (copied from Snipped #209).


org.eclipse.swt.GLCanvas canvas = new GLCanvas(new GLData());

canvas.setCurrent();
GLContext glcontext = GLDrawableFactory.getFactory().createExternalGLContext();
glcontext.makeCurrent();

//do some rendering and enable GL_DEPTH_TEST

glcontext.release();
glcanvas.swapBuffers();

Since i couldn’t find anything to correct this problem: Has someone a solution? Maybe its the same issue for which the GLJPanel was created? And no, i don’t want to use SWT_AWT bridge.

[edit]
OS: Intel Linux 32 bit. Latest nvidia driver (173.xxx). And swt 3.3.2
[/edit]

Just for the records: Solution found!

Ok. This is really somewhat hidden (or i must read more javadoc). What the snipped #209 doesn’t take into account: If the size of the depthbuffer is not set on the passed on GLData object, there is no! depthbuffer.

Corrected lines of code:


GLData gld = new GLData();
gld.depthSize = 4; //measured in bytes.

org.eclipse.swt.GLCanvas canvas = new GLCanvas(gld);

everything else as usual.

Hope this helps other people having the luck to just copy & paste the snipped and than wonder about the wired/ messed up rendering.

Regards,
funsheep

Glad you found a solution; this may be useful to me at some point. Actually, I must admit that it rang a bell from things I’d read before about (but not implemented myself yet) about setting up Frame Buffer Objects, including explicitly creating the depth buffer, so I had a feeling it might’ve been something very similar (ie, that one shouldn’t take presence of depthbuffer for granted) - perhaps I should’ve commented.