Posted by
philjord on
Jun 08, 2019; 1:41am
URL: https://forum.jogamp.org/Java3d-Nothing-is-Rendered-tp4039834p4039840.html
Ok good news, I've discovered the source of the problem, but I may need GouesseJ's advice on how to fix it correctly.
Here is a listing of the verbose output from the JoglPipeline of a Retained mode rendering cycle, that simply renders the same cube onto the same canvas.
Retained mode is the "normal" Java3D mode where the rendering thread simply loops and renders constantly (where needed).
Note I've trimmed away the setup calls as they are identical (because the code calling them is also identical - the createUniverse method)
JoglPipeline.validGraphicsMode()
Returning true
JoglPipeline.createNewContext()
JoglPipeline.updateSeparateSpecularColorEnable()
JoglPipeline.setSceneAmbient()
JoglPipeline.disableFog()
JoglPipeline.resetRenderingAttributes()
JoglPipeline.resetTextureNative()
JoglPipeline.resetTexCoordGeneration()
JoglPipeline.resetTextureAttributes()
JoglPipeline.resetPolygonAttributes()
JoglPipeline.resetLineAttributes()
JoglPipeline.resetPointAttributes()
JoglPipeline.resetTransparency()
JoglPipeline.resetColoringAttributes()
JoglPipeline.updateMaterialColor()
JoglPipeline.useCtx()
JoglPipeline.setViewport()
JoglPipeline.setRenderMode()
JoglPipeline.clear()
JoglPipeline.setRenderMode()
JoglPipeline.setProjectionMatrix()
JoglPipeline.setVertexFormat()
JoglPipeline.setModelViewMatrix()
JoglPipeline.setLightEnables()
JoglPipeline.setSceneAmbient()
JoglPipeline.disableFog()
JoglPipeline.disableModelClip()
JoglPipeline.resetRenderingAttributes()
JoglPipeline.resetPolygonAttributes()
JoglPipeline.resetTransparency()
JoglPipeline.updateMaterialColor()
JoglPipeline.resetColoringAttributes()
JoglPipeline.setModelViewMatrix()
JoglPipeline.execute()
JoglPipeline.executeGeometryArray()
JoglPipeline.testForInterleavedArrays()
JoglPipeline.setRenderMode()
JoglPipeline.syncRender()
JoglPipeline.swapBuffers()
JoglPipeline.releaseCtx()Compare with the same output for the immediate mode example
JoglPipeline.validGraphicsMode()
Returning true
JoglPipeline.createNewContext()
JoglPipeline.updateSeparateSpecularColorEnable()
JoglPipeline.setSceneAmbient()
JoglPipeline.disableFog()
JoglPipeline.resetRenderingAttributes()
JoglPipeline.resetPolygonAttributes()
JoglPipeline.resetLineAttributes()
JoglPipeline.resetPointAttributes()
JoglPipeline.resetTransparency()
JoglPipeline.resetColoringAttributes()
JoglPipeline.updateMaterialColor()
JoglPipeline.activeTextureUnit()
JoglPipeline.resetTransparency()
JoglPipeline.getNumCtxLights()
JoglPipeline.clear()
JoglPipeline.setViewport()
JoglPipeline.setProjectionMatrix()
JoglPipeline.setModelViewMatrix()
JoglPipeline.activeTextureUnit()
JoglPipeline.resetTransparency()
JoglPipeline.setModelViewMatrix()
JoglPipeline.setSceneAmbient()
JoglPipeline.setLightEnables()
JoglPipeline.setModelViewMatrix()
JoglPipeline.setVertexFormat()
JoglPipeline.execute()
JoglPipeline.executeGeometryArray()
JoglPipeline.testForInterleavedArrays()
JoglPipeline.syncRender()
JoglPipeline.swapBuffers()Apart from some texture calls that differ (we have no textures in the example) and a few order of operations the most significant difference is the lack of useCtx and releaseCtx calls.
So when I insert the function from useCtx
context(ctx).makeCurrent();into the first interesting render operation for immediate mode - updateSeparateSpecularColorEnable
I get

Woot!
so to get your code going, if you have the source for 1.6.0 and are willing to compile it, in the JoglPipeline class add this line
// Native method to update separate specular color control
@Override
void updateSeparateSpecularColorEnable(Context ctx, boolean enable) {
if (VERBOSE) System.err.println("JoglPipeline.updateSeparateSpecularColorEnable()");
context(ctx).makeCurrent();
GL2 gl = context(ctx).getGL().getGL2();
if (enable) {
gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SEPARATE_SPECULAR_COLOR);
} else {
gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SINGLE_COLOR);
}
}
I will now put together a fix that involves the renderer always using and releasing the context on pure immediate calls, along with the first create of context in GraphicsContext3D.doClear using the context correctly as well.
Note the fix I'm proposing will require all pure immedate systems to call doClear on the GraphicContext3D immedately after creation like this
public void render() {
System.out.println("render");
if (gc == null) {
// Set up Graphics context
gc = canvas.getGraphicsContext3D();
gc.clear();// clear must be the first call for pure immediate to set up the context and pipeline gc.setAppearance(new Appearance());// calls GraphicsContext3D.doSetAppearance a sync
// Set up geometry
cube = new ColorCube(0.4).getGeometry();
}
...
Julien, Harvey I'll put together a git pull request with the changes I think are required shortly, can you check it and see if it will cause trouble or be incomplete or there is a better way to solve the problem.
Thanks,
Phil.