vaiorabbit / ruby-opengl

Yet another OpenGL wrapper for Ruby (and wrapper code generator).
Other
88 stars 12 forks source link

Error On Calling glLightfv with QtWidget in qtbindings. #26

Closed applesnake closed 7 years ago

applesnake commented 7 years ago

A confusing error occurs on run qtbindings(qt4) example 'grabber'. PS: Example code modified. But everything goes well without qtbindings. May it be a bug from fiddle?

Log: /usr/local/lib/ruby/gems/2.4.0/gems/opengl-bindings-1.6.2/lib/opengl_command.rb:1450:in []': can't convert Array into Integer (TypeError) from /usr/local/lib/ruby/gems/2.4.0/gems/opengl-bindings-1.6.2/lib/opengl_command.rb:1450:incall' from /usr/local/lib/ruby/gems/2.4.0/gems/opengl-bindings-1.6.2/lib/opengl_command.rb:1450:in glLightfv' from /Volumes/Workspace/project/qtruby/examples/opengl/grabber/glwidget.rb:102:ininitializeGL' from /Volumes/Workspace/project/qtruby/examples/opengl/grabber/glwidget.rb:74:in method_missing' from /Volumes/Workspace/project/qtruby/examples/opengl/grabber/glwidget.rb:74:insetXRotation' from /Volumes/Workspace/project/qtruby/examples/opengl/grabber/mainwindow.rb:76:in qt_metacall' from /Volumes/Workspace/project/qtruby/examples/opengl/grabber/mainwindow.rb:76:inmethod_missing' from /Volumes/Workspace/project/qtruby/examples/opengl/grabber/mainwindow.rb:76:in initialize' from main.rb:30:innew' from main.rb:30:in `

'

vaiorabbit commented 7 years ago

Where is your modified 'glwidget.rb'? Show it first, please. Anyway, if you are using glLightfv like:

pos = [0, 0, 0, 1]
# ...
GL.Lightfv(GL::LIGHT0, GL::POSITION, pos) # old/other OpenGL binding style.

you must modify these lines into:

pos = [0, 0, 0, 1].pack('F4')
# ...
glLightfv(GL_LIGHT0, GL_POSITION, pos)

The API style of this gem is not compatible with that of other/old ruby OpenGL bindings. See glut_minimum.rb ( https://github.com/vaiorabbit/ruby-opengl/blob/master/sample/GLUT/glut_minimal.rb ) for example.