Better tracing output - patch

http://jogl.dev.java.net/issues/show_bug.cgi?id=12

direct link to patch

http://nwn-j3d.sf.net/jogl/trace.diff

This patch against BuildComposablePipeline.java creates TraceGL which IMHO is a bit better. In addition to reporting function name, it dumps arguments, including arrays up to 16 values long (longer are truncucated) and return value of function if available.

Example output:


glVertex3f(1.0517219,-0.7641209,0.25)
glNormal3f(-1.0,-1.7484555E-7,0.0)
glVertex3f(1.3,2.2729921E-7,-0.25)
glVertex3f(1.3,2.2729921E-7,0.25)
glEnd()
glEndList()
glEnable(2977)
glMatrixMode(5889)
glGetString(7936) = NVIDIA Corporation
glGetString(7937) = GeForce3/AGP/3DNOW!
glGetString(7938) = 1.4.0
isFunctionAvailable(glLoadTransposeMatrixfARB) = true
isFunctionAvailable(glLoadTransposeMatrixfARB) = true
glLoadTransposeMatrixfARB([1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0])
glFrustum(-1.0,1.0,-0.9109588861465454,0.9109588861465454,5.0,60.0)

Unfortunately, constants are not resolved at the moment - still thinking about best way for that.

Awesome! This is the style TraceGL that Magician used, and it’s very handy. I wanted to implement it for JOGL but just didn’t have time.

Some more nice things to add at some point would be support for indenting the stuff between glBegin*()/glEnd*() pairs, and outputting the actual constant name (e.g., GL_LIGHT0) instead of its integer value. That shouldn’t be too hard to do with reflection.

chris

Indenting is indeed not hard - I’ll try to do it. As for the constants, it is unfortunately not so easy. Reflection will not tell a difference between plain int and GLenum.
Ugly solution would be to always output both integer and possible constant value - but this is not acceptable for ‘serious’ API. I don’t think there is anything that can be done with current way it is handled. Only solution I see, is to add some kind of dump to GlueGen code, to output function prototypes in some readable form (probably just serialiazed Map) and the reading it from pipeline builder and checking exact type of ‘int’ arguments. Possible, but this is not few-line patch and I’m a bit afraid to play with so big changes to build system at the moment.

Yes, you’re right. The composable pipeline builder works purely via reflection, and doesn’t have any info about the Types of the function arguments. I did it this way initially just because it was the fastest way to get a composable pipeline built.

In light of this, perhaps I’ll sink some time into building an emitter a la GLEmitter so that we can generate the pipeline classes with full knowledge of type information.

-chris

Indent is here
http://nwn-j3d.sourceforge.net/jogl/indent.diff

It is incremental path against previous one. I have added it to issue on jogl bugzilla, so both patches are there.

Currently it indents on glBegin and glNewList.