opengl-bindings2 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/sample/simple.rb CHANGED
@@ -1,57 +1,57 @@
1
- #
2
- # For more samples, visit https://github.com/vaiorabbit/ruby-opengl/tree/master/sample .
3
- #
4
- # Ref.: /glfw-3.0.1/examples/simple.c
5
- #
6
- require 'opengl'
7
- require 'glfw'
8
-
9
- # Press ESC to exit.
10
- key_callback = GLFW::create_callback(:GLFWkeyfun) do |window, key, scancode, action, mods|
11
- GLFW.SetWindowShouldClose(window, 1) if key == GLFW::KEY_ESCAPE && action == GLFW::PRESS
12
- end
13
-
14
- if __FILE__ == $PROGRAM_NAME
15
- GLFW.load_lib() # Give path to "glfw3.dll (Windows)" or "libglfw.dylib (macOS)" if needed
16
- GLFW.Init()
17
-
18
- window = GLFW.CreateWindow(640, 480, "Simple example", nil, nil)
19
- GLFW.MakeContextCurrent(window)
20
- GLFW.SetKeyCallback(window, key_callback)
21
-
22
- GL.load_lib() # Call GL.load_lib after OpenGL context is available
23
-
24
- width_buf = ' ' * 8
25
- height_buf = ' ' * 8
26
- until GLFW.WindowShouldClose(window) == GLFW::TRUE
27
- GLFW.GetFramebufferSize(window, width_buf, height_buf)
28
- width = width_buf.unpack1('L')
29
- height = height_buf.unpack1('L')
30
- ratio = width.to_f / height.to_f
31
-
32
- GL.Viewport(0, 0, width, height)
33
- GL.Clear(GL::COLOR_BUFFER_BIT)
34
- GL.MatrixMode(GL::PROJECTION)
35
- GL.LoadIdentity()
36
- GL.Ortho(-ratio, ratio, -1.0, 1.0, 1.0, -1.0)
37
- GL.MatrixMode(GL::MODELVIEW)
38
-
39
- GL.LoadIdentity()
40
- GL.Rotatef(GLFW.GetTime() * 50.0, 0.0, 0.0, 1.0)
41
-
42
- GL.Begin(GL::TRIANGLES)
43
- GL.Color3f(1.0, 0.0, 0.0)
44
- GL.Vertex3f(-0.6, -0.4, 0.0)
45
- GL.Color3f(0.0, 1.0, 0.0)
46
- GL.Vertex3f(0.6, -0.4, 0.0)
47
- GL.Color3f(0.0, 0.0, 1.0)
48
- GL.Vertex3f(0.0, 0.6, 0.0)
49
- GL.End()
50
-
51
- GLFW.SwapBuffers(window)
52
- GLFW.PollEvents()
53
- end
54
-
55
- GLFW.DestroyWindow(window)
56
- GLFW.Terminate()
57
- end
1
+ #
2
+ # For more samples, visit https://github.com/vaiorabbit/ruby-opengl/tree/master/sample .
3
+ #
4
+ # Ref.: /glfw-3.0.1/examples/simple.c
5
+ #
6
+ require 'opengl'
7
+ require 'glfw'
8
+
9
+ # Press ESC to exit.
10
+ key_callback = GLFW::create_callback(:GLFWkeyfun) do |window, key, scancode, action, mods|
11
+ GLFW.SetWindowShouldClose(window, 1) if key == GLFW::KEY_ESCAPE && action == GLFW::PRESS
12
+ end
13
+
14
+ if __FILE__ == $PROGRAM_NAME
15
+ GLFW.load_lib() # Give path to "glfw3.dll (Windows)" or "libglfw.dylib (macOS)" if needed
16
+ GLFW.Init()
17
+
18
+ window = GLFW.CreateWindow(640, 480, "Simple example", nil, nil)
19
+ GLFW.MakeContextCurrent(window)
20
+ GLFW.SetKeyCallback(window, key_callback)
21
+
22
+ GL.load_lib() # Call GL.load_lib after OpenGL context is available
23
+
24
+ width_buf = ' ' * 8
25
+ height_buf = ' ' * 8
26
+ until GLFW.WindowShouldClose(window) == GLFW::TRUE
27
+ GLFW.GetFramebufferSize(window, width_buf, height_buf)
28
+ width = width_buf.unpack1('L')
29
+ height = height_buf.unpack1('L')
30
+ ratio = width.to_f / height.to_f
31
+
32
+ GL.Viewport(0, 0, width, height)
33
+ GL.Clear(GL::COLOR_BUFFER_BIT)
34
+ GL.MatrixMode(GL::PROJECTION)
35
+ GL.LoadIdentity()
36
+ GL.Ortho(-ratio, ratio, -1.0, 1.0, 1.0, -1.0)
37
+ GL.MatrixMode(GL::MODELVIEW)
38
+
39
+ GL.LoadIdentity()
40
+ GL.Rotatef(GLFW.GetTime() * 50.0, 0.0, 0.0, 1.0)
41
+
42
+ GL.Begin(GL::TRIANGLES)
43
+ GL.Color3f(1.0, 0.0, 0.0)
44
+ GL.Vertex3f(-0.6, -0.4, 0.0)
45
+ GL.Color3f(0.0, 1.0, 0.0)
46
+ GL.Vertex3f(0.6, -0.4, 0.0)
47
+ GL.Color3f(0.0, 0.0, 1.0)
48
+ GL.Vertex3f(0.0, 0.6, 0.0)
49
+ GL.End()
50
+
51
+ GLFW.SwapBuffers(window)
52
+ GLFW.PollEvents()
53
+ end
54
+
55
+ GLFW.DestroyWindow(window)
56
+ GLFW.Terminate()
57
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opengl-bindings2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaiorabbit
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-01 00:00:00.000000000 Z
10
+ date: 2025-01-25 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: fiddle