Bonjour Julien,
On Dec 18, 2009, at 4:54 AM, Julien Jassaud wrote:
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
Awesome! I would love to ship these as part of the MacRuby samples
once they are completed :)
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 ?
I would start by getting the full backtrace from the debugger and
examine it. Most of the time it is easy to find what's wrong.
Could you enter "thread apply all bt" into the debugger shell and
paste us the result?
If the crash is random there is a possibility that it might be related
to garbage collection. A good way to know for sure is to disable it,
by setting the GC_DISABLE environment variable to any value before
starting the application.
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.
I'm not familiar with OpenGL but it might be a BridgeSupport
problem... What other functions using the CGLRendererInfoObj are
failing? It might be good to reduce this problem to a small script
(even if it can be hard, because of OpenGL).
Laurent
_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel