larskanis / opengl

The official repository of the ruby-opengl wrapper
http://larskanis.github.com/opengl
MIT License
57 stars 11 forks source link

How to create GLSL shader with thid OpenGL bindings? #19

Open ghost opened 6 years ago

ghost commented 6 years ago

Program -just creating a variable for the vertex shader: require 'opengl' require 'glu' require 'glut'

$vertexShader = glCreateShader(GL_VERTEX_SHADER)

Result from Jetbrains Rubymine: C:\Ruby24-x64\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/Users/Andrew/Desktop/task3.rb C:/Users/Andrew/Desktop/task3.rb:7:in <top (required)>': uninitialized constant GL_VERTEX_SHADER (NameError) from -e:1:inload' from -e:1:in `

'

Process finished with exit code 1

ghost commented 6 years ago

1

larskanis commented 6 years ago

You must include the GL namespace or prefix the constants like: GL::GL_VERTEX_SHADER .

Apart from this, I recommend to use the ruby-opengl library for new projects. There is a shader example: https://github.com/vaiorabbit/ruby-opengl/blob/master/sample/OrangeBook/brick.rb