Debugging my render code

I’m currently going crazy trying to work out why an object I think I should be rendering can’t be seen. Off the top of my head it might be too small, on the wrong side of one of 6 clip planes, or behind something nearer and hence killed by the z-buffer.

I could extract the various matrices etc. from the GL object and compute the projected positions of the vertices, but that sounds like a lot of work with potential for its own subtle bugs, so I thought it would be worth asking whether anyone knows of a library or GL call which would allow me to call a method to reset counters, then later ask how many pixels have been drawn to, how many faces have been clipped entirely away, etc.

Any other suggestions also welcomed.

I’ve had a similar problem before. In my case I think I messed up setting the clipping planes(put zNear where zFar should have been).
A good idea if your IDE doesn’t have a good debugger is to rig your spacebar or enterkey to use a series of System.out.println statements such as:

Camera| X: # Y:# Z:#
Object| X: # Y:# Z:#
Object Scale| X:# Y:# Z:#

I’m sure I recapped things you’ve already checked for but I figured no one else responded so I might as well.
but as for GL commands that return that kind of information, to be honest I’m not sure.

If that’s the debugging approach you want, try looking into the feedback and selection render modes for opengl. However, I don’t recommend this because they seem complicated to use and interpret.

An approach that works for me, is to use a TraceGL to print out all of the gl commands I execute per-frame. Then I copy these into a simple GLEventListener (and fix up the syntax) and start tweaking from there to get the test case working.

Some other options as to why it’s not appearing include: you have lighting enabled but individual lights are not enabled (so it’d be black on a black background), or you it might be culled in appropriately on the CPU if you’re doing frustum culling yourself. I find it useful to use a gray background so that an object rendered as black (because of bad textures/shaders/ or gl state mishaps, etc.) is still visible.

I did in fact manage to get that particular problem fixed by finding some code elsewhere in the project which I could refactor to get the transform I wanted. It’s cargo cult programming at its finest, but.

The feedback selection mode does look interesting. If I run into similar problems in the future I will try using it, although I suspect that it might not be helpful if the problem is due to the object being outside the clip frustrum.