opengl-bindings 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/sample/report_env.rb CHANGED
@@ -1,3 +1,9 @@
1
+ # coding: utf-8
2
+ #
3
+ # opengl-bindings
4
+ # * http://rubygems.org/gems/opengl-bindings
5
+ # * http://github.com/vaiorabbit/ruby-opengl
6
+ #
1
7
  require 'opengl'
2
8
  require 'glfw'
3
9
 
@@ -9,12 +15,46 @@ include GLFW
9
15
 
10
16
  if __FILE__ == $0
11
17
  glfwInit()
12
- glfwWindowHint(GLFW_DECORATED, 0)
13
- window = glfwCreateWindow( 1, 1, "Report OpenGL Environment", nil, nil )
18
+
19
+ window = nil
20
+ [4, 3].each do |major_ver|
21
+ glfwDefaultWindowHints()
22
+ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE)
23
+ glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE)
24
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major_ver)
25
+ glfwWindowHint(GLFW_DECORATED, 0)
26
+ window = glfwCreateWindow( 1, 1, "Report OpenGL Environment", nil, nil )
27
+ break unless window.null?
28
+ end
29
+
30
+ if window.null?
31
+ glfwDefaultWindowHints()
32
+ window = glfwCreateWindow( 1, 1, "Report OpenGL Environment", nil, nil )
33
+ if window.null?
34
+ puts "Failed to create the OpenGL context."
35
+ glfwTerminate()
36
+ exit
37
+ end
38
+ end
39
+
14
40
  glfwMakeContextCurrent( window )
15
- puts "Version: #{glGetString(GL_VERSION).to_s}"
41
+
42
+ version_string = glGetString(GL_VERSION).to_s
43
+ version_number = version_string.split(/\./)
44
+ puts "Version: #{version_string}"
16
45
  puts "Extensions:"
17
- puts glGetString(GL_EXTENSIONS).to_s.split(/ /)
46
+ if version_number[0].to_i >= 3
47
+ # glGetString(GL_EXTENSIONS) was deprecated in OpenGL 3.0
48
+ # Ref.: http://sourceforge.net/p/glew/bugs/120/
49
+ extensions_count_buf = ' '
50
+ glGetIntegerv( GL_NUM_EXTENSIONS, extensions_count_buf )
51
+ extensions_count = extensions_count_buf.unpack('L')[0]
52
+ extensions_count.times do |i|
53
+ puts glGetStringi( GL_EXTENSIONS, i ).to_s
54
+ end
55
+ else
56
+ puts glGetString(GL_EXTENSIONS).to_s.split(/ /)
57
+ end
18
58
  glfwDestroyWindow( window )
19
59
  glfwTerminate()
20
60
  end
data/sample/simple.rb CHANGED
@@ -27,8 +27,8 @@ if __FILE__ == $0
27
27
  glfwSetKeyCallback( window, key_callback )
28
28
 
29
29
  while glfwWindowShouldClose( window ) == 0
30
- width_ptr = ' '
31
- height_ptr = ' '
30
+ width_ptr = ' ' * 8
31
+ height_ptr = ' ' * 8
32
32
  glfwGetFramebufferSize(window, width_ptr, height_ptr)
33
33
  width = width_ptr.unpack('L')[0]
34
34
  height = height_ptr.unpack('L')[0]
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opengl-bindings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - vaiorabbit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |
14
- Ruby bindings for OpenGL - 4.5, OpenGL ES - 3.1 and all extensions using Fiddle (For MRI >= 2.0.0).
14
+ Ruby bindings for OpenGL - 4.5, OpenGL ES - 3.2 and all extensions using Fiddle (For MRI >= 2.0.0). GLFW/GLUT/GLU bindings are also available.
15
15
  email:
16
16
  - vaiorabbit@gmail.com
17
17
  executables: []
@@ -68,8 +68,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  version: '0'
69
69
  requirements: []
70
70
  rubyforge_project:
71
- rubygems_version: 2.4.6
71
+ rubygems_version: 2.4.8
72
72
  signing_key:
73
73
  specification_version: 4
74
- summary: Bindings for OpenGL -4.5, ES - 3.1 and extensions (For MRI >= 2.0.0)
74
+ summary: Bindings for OpenGL -4.5, ES - 3.2 and extensions (For MRI >= 2.0.0)
75
75
  test_files: []