Okay, I'm going stop and actually take a look at this and start asking some questions as I'm not really hearing anything from anyone yet.
I've pulled down the source tree for the OSX port and started taking a look around. Right now I'm in MacOSXOnscreenGLContext.java. I saw some hardcoded stuff for the rendering context for 32 bit color, 24 bit depth, and 8 bit stencil (ouch).
1 2 3 4 5 6 7 8 9 10 11 12
| GLuint attribs[] = { NSOpenGLPFANoRecovery, NSOpenGLPFAWindow, NSOpenGLPFAAccelerated, NSOpenGLPFADoubleBuffer, NSOpenGLPFAColorSize, 32, NSOpenGLPFAAlphaSize, 8, NSOpenGLPFADepthSize, 24, NSOpenGLPFAStencilSize, 8, NSOpenGLPFAAccumSize, 0, 0 }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| protected synchronized boolean makeCurrent(Runnable initAction) throws GLException { try { if (!lockSurface()) { return false; } boolean created = false; if (nsContext == 0) { create(); if (DEBUG) { System.err.println("!!! Created GL nsContext for " + getClass().getName()); } created = true; } if (!CGL.makeCurrentContext(nsView, nsContext)) { throw new GLException("Error making nsContext current"); } if (created) { resetGLFunctionAvailability(); if (initAction != null) { initAction.run(); } } return true; } catch (RuntimeException e) { try { unlockSurface(); } catch (Exception e2) { } throw(e); } } |
Okay I'm starting to see some scary stuff in the OSX code that looks very unfamiliar for regular OpenGL programs and doesn't exist in other ports.
1) What is resetGLFunctionAvailability and why is it being called every makeCurrent().
2) Why is initAction.run() being called here? Or more appropriately - why is makeCurrent taking a runnable at all?
protected synchronized void swapBuffers() throws GLException {
if (!CGL.flushBuffer(nsView, nsContext)) {
throw new GLException("Error swapping buffers");
}
}
Even scarier here. Assuming CGL.flushBuffer is doing what it looks like its doing, why isn't it just calling swapBuffers instead of flushing them and stalling the pipeline?