Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Current state of OpenGL?
- - By siebharinn Date 2012-12-28 21:05
Hey all. I've been browsing through the forums, trying to get a handle on where we sit with using OpenGL from Ruby. It seems like there are is a pretty wide range of success.

1) Does anyone have the stock OpenGL gem working with Ruby 1.9.x ? If so, how?

2) What version of OpenGL does Gosu support?

3) If I create a native extension, can it access the OpenGL context that is running in Gosu? This is essentially what Ashton is doing?

4) If I want to get into 3D, while still retaining all of the niceties of Gosu, I can wrap my calls in gl() { } in the draw method?

Thanks!!
Parent - By erisdiscord Date 2012-12-28 21:16
2) I'm pretty sure that's up to your OpenGL library and hardware. Someone please correct me if I'm wrong.

4) Precisely.

I'll leave the other questions to folks who are better equipped to answer them.
Parent - By siebharinn Date 2012-12-28 22:08
I managed to get the opengl gem installed (someone else on the forum recommended "gem install opengl --pre", which worked for me). Requiring gosu and opengl in the same app gives me access to the opengl side of things. It reports my OpenGL version as "2.1 NVIDIA-8.0.61" (OS X 10.8.2). So that answers 1 and 2.
Parent - By Spooner Date 2012-12-29 00:43
1) The ruby-opengl gem isn't compatible with 1.9 and was abandoned. The opengl --pre gem, is just a fork from that code to fix it for 1.9, since the original author wasn't going to update it.

2) Gosu requires OpenGL 1.1. Ashton requires OpenGL 2.0 for minimum shader support. I intentionally kept the provided Ashton shaders at maximum compatibility (GLSL 1.1), though there is no reason that its users can't write much more advanced shader code if it suits them (I'd recommend using at least GLSL 1.3).

3) If you create a native extension, then yes you can manipulate the OpenGL context, but you need to provide your own bindings to OpenGL if you want to access it directly from C, not by dropping out to Ruby (the latter would be very slow). Ashton compiles the GLee bindings, which I found to be a lot nicer than GLEW, in my limited experience. Look at the Ashton source if you want to see how to do that (or I can answer specific questions).

4) You can do whatever you like in a gl block. The only issue is that it is intended to keep the context consistent, but it doesn't reset some things which are more advanced than Gosu itself uses, so be careful. For example, a gl block resets the view, but it doesn't reset the current shader.
Parent - - By BlueScope Date 2013-01-02 04:57
There's this pretty going-around pre-compiled package by Trebor that I'm using... works well with 1.9.3 and the recent Gosu versions.
Parent - - By Spooner Date 2013-01-03 23:22
I think it is much better to use the fully working, published 'opengl' gem though, if you are distributing your game though. Packaging it with a hacked version of a non-working published gem 'ruby-opengl' is not the best thing.
Parent - - By bestguigui Date 2013-01-07 11:21
I'm using Trebor's version too ! Everything is working great with it.

I'm using only gl do block to create anything in 3D and I'm drawing behind it to create anything in 2D, using Gosu primary drawing methods, which is really a great thing, really pleasant way to do it.

I don't use shaders and nothing more complex than a display list, so I guess I'm using really simple OpenGL, but check out my channel to see that there are still great possibilities :

http://www.youtube.com/user/solidboko?feature=g-crec-u
Parent - - By BlueScope Date 2013-01-07 12:22
Interestingly, I've been checking out your channel just a few days ago... congrats on a lot of interesting projects, while I'm at it ;) and thanks for sharing some of those sources, which really helped me understanding the whole OpenGL stuff a lot better!

On topic, I guess I agree with Spooner that relying on a widely available gem would be preferred. I had compatibility problems sharing one of my projects just the other day, for exactly this reason...
If it's actually as easy to install 'opengl --pre' on 1.9 to get it working, that'd definitely be better... got to try that out later.
Parent - - By BlueScope Date 2013-01-07 19:21
Now that I removed ruby-opengl and opengl --pre seems to be working fine, I wonder if just uninstalling ruby-opengl via 'gem uninstall ruby-opengl' removes everything related? Just trying to make sure I'm running on a clean opengl gem here...
Parent - By Spooner Date 2013-01-07 23:16
Both gems are required with "require 'opengl'" so unless you've specified which one you want in a bundler Gemfile, it will always take the non-pre version over the --pre version, unless there is ONLY the --pre one available. Using Bundler is pretty much standard now and there is little excuse for avoiding it and a lot of reasons to use it.
Up Topic Gosu / Gosu Exchange / Current state of OpenGL?

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill