OpenGL support

C

Chananya Freiman

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. :/
 
C

Chananya Freiman

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

Marcelo

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
 
M

Michael Brooks

Marcelo said:
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

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
 
R

Ralf Mueller

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
 
A

Andrea Fazzi

Chananya Freiman 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. :/


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

https://github.com/remogatto/ffi-opengl

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

Cheers,
Andrea
 
C

Chananya Freiman

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.

Parsing should be too hard.

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.
The parsing itself is pretty easy.

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top