OpenGL support

Will there ever be updated bindings to OpenGL?
I can’t understand how there’s a language without working bindings to
the biggest open source graphics API out there.

ruby-opengl only seems to work on Ruby 1.8, and ruby/glew is from 2006.
So we get outdated bindings that aren’t worth a thing today.

If I knew how to make them, I’d do it by myself, but I don’t. :confused:

By the way, I don’t know much about writing C extensions, but is it
possible (not for me :frowning: ) to tell a Ruby program to open this page
http://www.opengl.org/registry/api/gl3.h and dynamically make the
bindings using it?
If someone could make that, the bindings will be automatically updated
(you’ll just need to run the program and upload the gem using
the new bindings it created).

On Mon, Dec 20, 2010 at 14:12, Chananya F.
[email protected] wrote:

ruby-opengl only seems to work on Ruby 1.8, and ruby/glew is
from 2006. So we get outdated bindings that aren’t worth a
thing today.

Sorry for being lazy. Can you point me to an URL to download
those two? I have a soft spot for OpenGL and I’m one of the
original authors of GLEW, and I would like to see if I can
update the bindings for both of those libraries and keep them
updated.

Thanks,

Marcelo

“Marcelo” [email protected] wrote in message
news:[email protected]

update the bindings for both of those libraries and keep them
updated.

Thanks,

Marcelo

Hello Marcelo:

Ruby Glew http://rubyforge.org/projects/rubyglew/
Ruby OpenGL http://ruby-opengl.rubyforge.org/

Thanks in advance for anything you do to update these.

Michael

Chananya F. wrote in post #969634:

Will there ever be updated bindings to OpenGL?
I can’t understand how there’s a language without working bindings to
the biggest open source graphics API out there.

ruby-opengl only seems to work on Ruby 1.8, and ruby/glew is from 2006.
So we get outdated bindings that aren’t worth a thing today.

If I knew how to make them, I’d do it by myself, but I don’t. :confused:

Perhaps, you may be interested in ffi-opengl too:

GitHub - remogatto/ffi-opengl: A ruby-ffi binding to OpenGL libraries

I don’t know if it is still working with latest ruby-ffi. In case, I’ll
be happy to accept patches :slight_smile:

Cheers,
Andrea

Hi Marcelo

Sorry for being lazy. Can you point me to an URL to download
those two? I have a soft spot for OpenGL and I’m one of the
original authors of GLEW, and I would like to see if I can
update the bindings for both of those libraries and keep them
updated.
This would be great! Thanx for the work.

regards
ralf

I looked a bit into C extensions and I thought of a pretty easy way of
making the bindings.
However, this way isn’t really “portable” in the sense that you have to
run a Ruby file on every computer, and have to have something that can
create an OpenGL context (I am using GLFW at the moment).

All these steps are done in an rb file, no need to do it manually.

Step 1) Download the gl3.h file from opengl.org
Step 2) Create a tiny C extension that creates an OpenGL context, gets
the OpenGL version supported by the computer, and terminates the
context.
Step 3) Start creating the bindings by parsing gl3.h and taking the
version into consideration.

The parsing itself is pretty easy.

You figure where the first occurrence of “#define GL_VERSION_x_y”, where
x and y are your major and minor parts of the GL version.
You find the next occurrence of any GL_VERSION.
This is where your drivers stop supporting constants, so you parse
everything that far.

Now, you get the next occurrence of “#define GL_VERSION_x_y”, and again
the next occurrence of any GL_VERSION.
This is where the drivers stop supporting actual GL function entry
points, so you parse the entry points until there.

And…that’s basically it.

Constants are a quick one-liner in a String#scan:

data.scan(/#define (GL_[A-Z0-9_]+)[ \t]+([0-9A-Fx]+)/) { |block|
f.puts “rb_define_const(GL, "#{block[0]}", INT2FIX(#{block[1]}));”
}

Functions are a little harder because of the argument types that need to
be taken into account, but it shouldn’t be too hard (I started working
on them and then realized that I forgot to remove functions of higher GL
version then I have so I got tons of linker errors :P).

The main problem of this as I see it is the fact that you must create a
context to get the GL version.
Running a Ruby file is sort of an annoyance, but then installing gems is
more work.
Having to have a specific library, however, is sort of un-portable and
annoying.

What do you guys think about this?