Not logged inGosu Forums
Forum back to libgosu.org Help Search Register Login
Up Topic Gosu / Gosu Exchange / Raspberry Ruby - Could not initialize OpenGL
- - By PeterWAWood Date 2015-06-22 07:14
I followed the very thorough instructions on https://github.com/gosu/gosu/wiki/Getting-Started-on-Raspbian-(Raspberry-Pi). I'm pretty sure that I got everything correct as I copied all the commands from the wiki page into the command line.

When I run a very simple test program, I get this error:


pi@raspibplus ~/Code/Ruby/Gosu $ ruby test.rb
/usr/local/lib/ruby/gems/2.2.0/gems/gosu-0.9.2/lib/gosu/swig_patches.rb:19:in initialize': Could not create window: Could not initialize OpenGL / GLES library (RuntimeError)
  from /usr/local/lib/ruby/gems/2.2.0/gems/gosu-0.9.2/lib/gosu/swig_patches.rb:19:in
initialize'
  from test.rb:4:in initialize'
  from test.rb:15:in
new'
  from test.rb:15:in `<main>'
terminate called after throwing an instance of 'std::runtime_error'
  what():  Could not create window: Could not initialize OpenGL / GLES library
Aborted


Any suggestions as to what I may have done incorrectly?

Thanks in advance

Peter
Parent - - By jlnr (dev) Date 2015-06-22 08:45
I wonder if I have broken something in Gosu 0.9.x - I didn't have a chance to test this version on a Raspberry Pi. Can you please try using Gosu 0.8.x? If that helps, I'll need to grab a Raspi again and debug Gosu 0.9.x. Thanks.
Parent - - By PeterWAWood Date 2015-06-22 13:52
I tried with Gosu 0.8.7.2 and got a similar error when I tried to run the tutorial program:


pi@raspibplus /usr/local/lib/ruby/gems/2.2.0/gems/gosu-0.8.7.2/examples $ gem list gosu

*** LOCAL GEMS ***

gosu (0.8.7.2)
pi@raspibplus /usr/local/lib/ruby/gems/2.2.0/gems/gosu-0.8.7.2/examples $ ruby Tutorial.rb
Tutorial.rb:84:in initialize': Could not open window: Could not initialize OpenGL / GLES library (RuntimeError)
  from Tutorial.rb:84:in
initialize'
  from Tutorial.rb:130:in new'
  from Tutorial.rb:130:in
<main>'
Parent - - By jlnr (dev) Date 2015-06-22 15:14
I've diffed the sources for Gosu 0.8.0 (which I know worked on Raspbian) and 0.8.7.2 and couldn't find anything that should cause this issue. =/ I wonder if anything in SDL 2 or Raspbian has changed since then. The only advice I can give is to compile an OpenGL ES 1.x demo that uses SDL 2 and see if it works on your machine. Sorry! I've already given away my Pi.
Parent - - By PeterWAWood Date 2015-06-23 02:34
I'll try to do that over the next few days. If I'm able I'll let you know how I got on.
Parent - - By jlnr (dev) Date 2015-06-23 21:49
Cool, thanks!
Parent - - By PeterWAWood Date 2015-07-05 07:18 Edited 2015-07-05 08:08
It took me a little longer than I had hoped. I wasn't able to get any of the SDL2 test programs working but that was probably because I was making mistakes.

However, by following these instructions - https://solarianprogrammer.com/2015/01/22/raspberry-pi-raspbian-getting-started-sdl-2/ - I was able to compile and run the simple test program at the end of the blog.

I installed gosu 0.9.2 again using the command from the Gosu wiki but still got the "Could not initialize OpenGL / GLES library message" when I ran the tutorial.

(By the way, it seems that the examples don't get installed with 0.9.2)
Parent - - By jlnr (dev) Date 2015-07-05 08:11
Right, the examples live in the gosu-examples gem now: https://github.com/gosu/gosu-examples (a recent and not very well documented move)

Can you please try calling SDL_GL_CreateContext(window) after creating the window and see what it returns?
Parent - - By PeterWAWood Date 2015-07-07 02:25
Thanks for the reply. I'm afraid I don't know any C++ and only a little C. I found from the compiler that SDL_CreateContext returns a pseudonym for void. I printed this value as an integer, it contained 1. (I'm not sure if this is what you needed or any use).

Please let me know what I can do to help (given my limitations).

This is the line of code that I inserted:

   printf("SDL_GL_CreateContext returns %d\n", int(SDL_GL_CreateContext(window)));

I put that immediately after:

   SDL_Window* window = SDL_CreateWindow("Test SDL 2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
                                        800, 600, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
   check_error_sdl(window == nullptr, "Unable to create window");


This is the output:

  ~/SDL2test $ ./sdl2_test
SDL_GL_CreateContext returns 1
~/SDL2test $
Parent - - By jlnr (dev) Date 2015-08-01 09:09
I am a little confused why SDL_GL_CreateContext would return 1 – but anything that's not 0 is good, I guess!

There's been a GitHub issue about the Pi just this week: https://github.com/gosu/gosu/issues/285

...so I guess Gosu does *theoretically* work on Raspbian, but at this point I can only say that the Pi is terrible platform for SDL 2/OpenGL (ES), and that I don't know how to support it properly. :(
Parent - By PeterWAWood Date 2015-08-10 06:23
Being an optimist, I hope that in the not so distant future Raspian will include a decent SDL 2 implementation. In the meantime, I will enjoy learning about Gosu on my Mac.

Thanks for taking a look into the issue.
Up Topic Gosu / Gosu Exchange / Raspberry Ruby - Could not initialize OpenGL

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill