geo3d 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc3a00916353a730df2887d4c0d4a3b701b252c8
4
- data.tar.gz: 0c2dbbc118ea1d42618e19b8233db5cfac1b4868
3
+ metadata.gz: 45adfa328b2bbe9761b54a83100d9586214ee33f
4
+ data.tar.gz: dc95fd625d68ff56aad0e62b92a7e68cab274059
5
5
  SHA512:
6
- metadata.gz: bc4d3e5fd0f130b41fb5762f3235135e9ef459c239aec73247dc8b7242091924133804f54b6043c58e0ad48b65e5587a5e7ae71bc61ec7374e0e4c85c52c2d38
7
- data.tar.gz: 7eed2898daa4bf1fbfab8c6500e9241ccd194a1dc4ffcc228823841398feddfca655774d9be735096badec96cff48b42ccc3fb10864351c654d05623b268a469
6
+ metadata.gz: 77ada830a67ff35e709ef1efb0e3917696363c61f69d73f9fe27d8c70fd16e6c26d081ad68b8fba61835f4045e10278615b00ca7a41735358695b7a635d8b80d
7
+ data.tar.gz: ef1bedd83c6438fcea8d93cccf0e46ff43fd337f5f15625c00a1bd6ae6f4a3c5c127af401d130a96819167f8e74b7c1f0d0914296a44276bdc665e6a619e0a41
@@ -22,4 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
24
  spec.add_development_dependency "ruby-opengl"
25
+ spec.add_development_dependency "glu"
26
+ spec.add_development_dependency "glut"
27
+
25
28
  end
@@ -7,10 +7,7 @@ module Geo3d
7
7
  alias :w :d
8
8
 
9
9
  def initialize *args
10
- @a = 0.0
11
- @b = 0.0
12
- @c = 0.0
13
- @d = 0.0
10
+ @a, @b, @c, @d = 0.0, 0.0, 0.0, 0.0
14
11
  @a = args[0].to_f if args.size > 0
15
12
  @b = args[1].to_f if args.size > 1
16
13
  @c = args[2].to_f if args.size > 2
@@ -1,3 +1,3 @@
1
1
  module Geo3d
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -1,43 +1,32 @@
1
1
  require 'spec_helper'
2
+ require "opengl"
3
+ require "glu"
4
+ require "glut"
5
+
6
+ # This spec tests the accuracy of Geo3D by comparing its calculations against the same calculations made in OpenGL
2
7
 
3
8
  describe Geo3d::Matrix do
9
+ let(:gl){ Class.new{extend GL} }
10
+ let(:glu){ Class.new{extend GLU} }
11
+
12
+ before :all do
13
+ GLUT.Init
14
+ GLUT.InitDisplayMode(GLUT::DOUBLE | GLUT::RGB)
15
+ GLUT.InitWindowSize(500, 500)
16
+ GLUT.InitWindowPosition(100, 100)
17
+ GLUT.CreateWindow('test')
18
+ end
19
+
4
20
  before :each do
5
- @gl_initialized = false
6
- #require "ruby-sdl-ffi"
7
- require "opengl"
8
- include Gl,Glu,Glut
9
-
10
- glutInit
11
- glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
12
- glutInitWindowSize(500, 500)
13
- glutInitWindowPosition(100, 100)
14
- glutCreateWindow('test')
15
-
16
- =begin
17
- if SDL.Init(SDL::INIT_VIDEO) < 0
18
- puts "not able to init"
19
- else
20
-
21
- SDL.GL_SetAttribute SDL::GL_RED_SIZE, 5
22
- SDL.GL_SetAttribute SDL::GL_GREEN_SIZE, 5
23
- SDL.GL_SetAttribute SDL::GL_BLUE_SIZE, 5
24
- SDL.GL_SetAttribute SDL::GL_DEPTH_SIZE, 16
25
- SDL.GL_SetAttribute SDL::GL_DOUBLEBUFFER, 1
26
-
27
- if 0 == SDL.SetVideoMode(640, 480, SDL.GetVideoInfo.vfmt.BitsPerPixel, SDL::OPENGL)
28
- puts "not able to set video mode"
29
- else
30
- @gl_initialized = true
31
- end
32
- end
33
- =end
34
- # raise "opengl not able to initialize" unless @gl_initialized
21
+ gl.send :glMatrixMode, GL::PROJECTION
22
+ gl.send :glLoadIdentity
23
+ gl.send :glMatrixMode, GL::MODELVIEW
24
+ gl.send :glLoadIdentity
35
25
  end
36
26
 
27
+
37
28
  it "the identity constructor should be functionally equivalent to glLoadIdentity" do
38
- glMatrixMode GL_MODELVIEW
39
- glLoadIdentity
40
- gl_version = Geo3d::Matrix.new *glGetFloatv(GL_MODELVIEW_MATRIX).flatten
29
+ gl_version = Geo3d::Matrix.new *gl.send(:glGetFloatv, GL::MODELVIEW_MATRIX).flatten
41
30
  Geo3d::Matrix.identity.should == gl_version
42
31
  end
43
32
 
@@ -47,11 +36,8 @@ describe Geo3d::Matrix do
47
36
  focus = Geo3d::Vector.new *data[:eye]
48
37
  up = Geo3d::Vector.new *data[:eye]
49
38
 
50
- glMatrixMode GL_MODELVIEW
51
- glLoadIdentity
52
- gluLookAt eye.x, eye.y, eye.z, focus.x, focus.y, focus.z, up.x, up.y, up.z
53
- gl_version = Geo3d::Matrix.new *glGetFloatv(GL_MODELVIEW_MATRIX).flatten
54
-
39
+ glu.send :gluLookAt, eye.x, eye.y, eye.z, focus.x, focus.y, focus.z, up.x, up.y, up.z
40
+ gl_version = Geo3d::Matrix.new *gl.send(:glGetFloatv, GL::MODELVIEW_MATRIX).flatten
55
41
  gl_version.should == Geo3d::Matrix.look_at_rh(eye, focus, up)
56
42
  end
57
43
  end
@@ -59,11 +45,12 @@ describe Geo3d::Matrix do
59
45
  it "gl_frustum should be equivalent to opengl glFrustum" do
60
46
  [{:l => -2, :r => 2, :b => -2, :t => 2, :zn => 1, :zf => 1000},
61
47
  {:l => -231, :r => 453, :b => -232, :t => 2786, :zn => 9.221, :zf => 10000}].each do |data|
62
- glMatrixMode GL_PROJECTION
63
- glLoadIdentity
64
- glFrustum data[:l], data[:r], data[:b], data[:t], data[:zn], data[:zf]
65
48
 
66
- gl_version = Geo3d::Matrix.new *(glGetFloatv(GL_PROJECTION_MATRIX).flatten)
49
+ gl.send :glMatrixMode, GL::PROJECTION
50
+ gl.send :glLoadIdentity
51
+ gl.send :glFrustum, data[:l], data[:r], data[:b], data[:t], data[:zn], data[:zf]
52
+
53
+ gl_version = Geo3d::Matrix.new *(gl.send(:glGetFloatv, GL::PROJECTION_MATRIX).flatten)
67
54
  geo3d_matrix = Geo3d::Matrix.gl_frustum data[:l], data[:r], data[:b], data[:t], data[:zn], data[:zf]
68
55
 
69
56
  gl_version.should == geo3d_matrix
@@ -73,11 +60,11 @@ describe Geo3d::Matrix do
73
60
 
74
61
  it "glu_perspective_degrees should be equivalent to opengl gluPerspective" do
75
62
  [{:fovy_in_degrees => 60, :width => 640, :height => 480, :near => 0.1, :far => 1000}].each do |data|
76
- glMatrixMode GL_PROJECTION
77
- glLoadIdentity
78
- gluPerspective data[:fovy_in_degrees], data[:width].to_f/data[:height].to_f, data[:near], data[:far]
63
+ gl.send :glMatrixMode, GL::PROJECTION
64
+ gl.send :glLoadIdentity
65
+ glu.send :gluPerspective, data[:fovy_in_degrees], data[:width].to_f/data[:height].to_f, data[:near], data[:far]
79
66
 
80
- gl_version = Geo3d::Matrix.new *glGetFloatv(GL_PROJECTION_MATRIX).flatten
67
+ gl_version = Geo3d::Matrix.new *gl.send(:glGetFloatv, GL::PROJECTION_MATRIX).flatten
81
68
  geo3d_matrix = Geo3d::Matrix.glu_perspective_degrees(data[:fovy_in_degrees], data[:width].to_f/data[:height].to_f, data[:near], data[:far])
82
69
 
83
70
  gl_version.should == geo3d_matrix
@@ -87,11 +74,11 @@ describe Geo3d::Matrix do
87
74
  it "gl_ortho should be equivalent to opengl glOrtho" do
88
75
  [{:l => -2, :r => 2, :b => -2, :t => 2, :zn => 1, :zf => 1000},
89
76
  {:l => -231, :r => 453, :b => -232, :t => 2786, :zn => 9.221, :zf => 10000}].each do |data|
90
- glMatrixMode GL_PROJECTION
91
- glLoadIdentity
92
- glOrtho data[:l], data[:r], data[:b], data[:t], data[:zn], data[:zf]
77
+ gl.send :glMatrixMode, GL::PROJECTION
78
+ gl.send :glLoadIdentity
79
+ gl.send :glOrtho, data[:l], data[:r], data[:b], data[:t], data[:zn], data[:zf]
93
80
 
94
- gl_version = Geo3d::Matrix.new *(glGetFloatv(GL_PROJECTION_MATRIX).flatten)
81
+ gl_version = Geo3d::Matrix.new *(gl.send(:glGetFloatv, GL::PROJECTION_MATRIX).flatten)
95
82
  geo3d_matrix = Geo3d::Matrix.gl_ortho data[:l], data[:r], data[:b], data[:t], data[:zn], data[:zf]
96
83
 
97
84
  gl_version.should == geo3d_matrix
@@ -110,11 +97,10 @@ describe Geo3d::Matrix do
110
97
 
111
98
  geo3d_matrix = Geo3d::Matrix.new(*b_values) * Geo3d::Matrix.new(*a_values)
112
99
 
113
- glMatrixMode GL_MODELVIEW
114
- glLoadIdentity
115
- glLoadMatrixf a_values
116
- glMultMatrixf b_values
117
- gl_version = Geo3d::Matrix.new *glGetFloatv(GL_MODELVIEW).flatten
100
+ gl.send :glMatrixMode, GL::MODELVIEW
101
+ gl.send :glLoadMatrixf, a_values
102
+ gl.send :glMultMatrixf, b_values
103
+ gl_version = Geo3d::Matrix.new *gl.send(:glGetFloatv, GL::MODELVIEW).flatten
118
104
 
119
105
  gl_version.should == geo3d_matrix
120
106
  end
@@ -135,9 +121,8 @@ describe Geo3d::Matrix do
135
121
 
136
122
  vector = Geo3d::Vector.new 300, 100, -500
137
123
 
138
- glu_vector = gluProject vector.x, vector.y, vector.z, projection_matrix.to_a, view_matrix.to_a, [viewport_data[:x], viewport_data[:y], viewport_data[:width], viewport_data[:height]]
124
+ glu_vector = glu.send :gluProject, vector.x, vector.y, vector.z, projection_matrix.to_a, view_matrix.to_a, [viewport_data[:x], viewport_data[:y], viewport_data[:width], viewport_data[:height]]
139
125
 
140
- puts "glu vect is #{glu_vector.inspect}"
141
126
  Geo3d::Vector.new(*glu_vector).should == vector.project(viewport_matrix, projection_matrix, view_matrix, Geo3d::Matrix.identity).zero_w
142
127
  end
143
128
 
@@ -156,7 +141,7 @@ describe Geo3d::Matrix do
156
141
 
157
142
  vector = Geo3d::Vector.new 574.1784279190967, 294.42147391181595, 0.8485367205965038
158
143
 
159
- glu_vector = gluUnProject vector.x, vector.y, vector.z, projection_matrix.to_a, view_matrix.to_a, [viewport_data[:x], viewport_data[:y], viewport_data[:width], viewport_data[:height]]
144
+ glu_vector = glu.send :gluUnProject, vector.x, vector.y, vector.z, projection_matrix.to_a, view_matrix.to_a, [viewport_data[:x], viewport_data[:y], viewport_data[:width], viewport_data[:height]]
160
145
  Geo3d::Vector.new(*glu_vector).should == vector.unproject(viewport_matrix, projection_matrix, view_matrix, Geo3d::Matrix.identity).zero_w
161
146
  end
162
147
 
@@ -1 +1,6 @@
1
- require 'geo3d'
1
+ require 'geo3d'
2
+
3
+ RSpec.configure do |config|
4
+ config.expect_with(:rspec) { |c| c.syntax = :should }
5
+ end
6
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geo3d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Misha Conway
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-07 00:00:00.000000000 Z
11
+ date: 2018-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: glu
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: glut
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  description: Library for common 3d graphics vector and matrix operations
70
98
  email:
71
99
  - MishaAConway@gmail.com
@@ -114,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
142
  version: '0'
115
143
  requirements: []
116
144
  rubyforge_project:
117
- rubygems_version: 2.2.1
145
+ rubygems_version: 2.4.8
118
146
  signing_key:
119
147
  specification_version: 4
120
148
  summary: Library for common 3d graphics vector and matrix operations