From: Bill Kelly Date: 2006-02-22T01:18:26+09:00 Subject: Re: How can I evaluate and visualize code instead of running it. Hi, From: "anne001" >I am using a tree and traversing down a tree to generate opengl code > How could I easily list the opengl code that I am generating, instead > of running it? > > def applytransform > GL.PushMatrix(); > GL.Translate(*@Translation); > GL.Translate(*@jointP); > if @parent != nil > GL.Translate(*@parentjointP); > end > GL.Rotate(*@rotation); > GL.Translate(*@jointP.minus); > end > > def traversetree > GL.Clear(GL::COLOR_BUFFER_BIT); > GL.PushMatrix(); > applytransform > @children.each {|childnode| childnode.traversetree} > drawprimitive > GL.PopMatrix(); > GLUT.SwapBuffers(); > end Maybe one possibility: require 'opengl' RealGL = GL class LoggingGL class << self def method_missing(meth, *args) puts "#{meth}(#{args.join(', ')})" RealGL.send(meth, *args) # remove this line if you don't want to really call GL end def const_missing(const) RealGL.const_get(const) end end end GL = LoggingGL ##################################### The above will turn this: GL.MatrixMode(GL::PROJECTION) GL.LoadIdentity GL.Scaled(1.5, 1.2, 1.0) Into the following output: MatrixMode(5889) LoadIdentity() Scaled(1.5, 1.2, 1.0) Hope this helps, Bill