[MacRuby-devel] Some OpenGL sample code
Julien Jassaud
julien at collectapply.jp
Fri Dec 18 04:54:41 PST 2009
Hello to everyone,
I tried to port two OpenGL sample code examples from the ADC in MacRuby ( and plan to port some more ). You can find both projects here : http://github.com/sojastar
Both kind of work but have problems I can't find solutions to so I turn to the list for a little help.
One of the examples ( MacRuby-BoingX ) randomly crashes, either on launch or exit, about one time out of five. When launching the application from XCode, I get :
Program received signal: “EXC_BAD_ACCESS”.
which suggests a memory access error. It is not unlikely since the OpenGL functions use a lot of pointers. I am trying to use DTrace to identify the problem but it is very new territory for me. I wrote a script returning the name of the last function called. I get a different result for every crash. I imagine part of my data ( most often, the vertex data ) must be corrupted, and maybe from the various pointer operations I have to do to use OpenGL. Has anyone any suggestion on how I could troubleshoot such a problem ?
The problem with the second example is directly related to pointers. The function CGLQueryRendererInfo function expects a pointer to a CGLRendererInfoObj object as its second argument. After the call, the pointer points to a valid CGLRendererInfoObj object. So I did something like this :
renderer_info = Pointer.new_with_type("^{_CGLRendererInfoObj}")
renderer_error = CGLQueryRendererInfo(display_mask, renderer_info, renderer_count)
and get :
expected instance of Pointer of type `^{_CGLRendererInfoObject}', got `^{_CGLRendererInfoObj}' (TypeError)
If I change the pointer type to '^{_CGLRendererInfoObject}', CGLQueryRendererInfo doesn't complain anymore, but all other following functions using the CGLRendererInfoObj do. Could this be a bridge support problem ? As anyone who has a better background in Cocoa any idea ? I know some things should be done in bundles but, for sample code, I thought it would be good to try to go Ruby all the way.
My configuration : Intel Core 2 Duo MacBook Pro, Mac OS 10.6.2, MacRuby 0.5b2
Thanks,
Julien Jassaud
More information about the MacRuby-devel
mailing list