[MacRuby-devel] Initializing Pointer.new with specific value

Dave Baldwin dave.baldwin at dsl.pipex.com
Mon Jan 10 05:42:06 PST 2011


In OpenGL some functions take pointers and these are easily handled via

v = Pointer.new('f', 20)
glVertexPointer(3, GL_FLOAT, 3,  v)

(the C prototype is 
void glVertexPointer(GLint  size, GLenum  type, GLsizei  stride, const GLvoid *  pointer);


however in some cases this function has been overloaded so you pass in an integer as the last parameter.  In C this is easy
glVertexPointer(3, GL_FLOAT, 3, (void *) 12)

but how do I do this with MacRuby Pointer objects?  (the source code and googling hasn't helped).  I can (and have) written this as an objective-C method and called this method from ruby so I have a workaround.  I can understand if this is not possible or desirable from ruby as it is a horrible bit of API design in OpenGL in any case.

Dave.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110110/7ecbba28/attachment.html>


More information about the MacRuby-devel mailing list