mittsu 0.1.3 → 0.1.4

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: d7b8204b98ee764f5d16b7f05080fdfef61e40d9
4
- data.tar.gz: f0414817f8f8d34396c8e2db3fc78940e1e9da5f
3
+ metadata.gz: 904b39d95b5ddd686b51b4b34d62c47e38747eda
4
+ data.tar.gz: 8d39e2085e02c706fcf05fc51d5ebf46d35135cf
5
5
  SHA512:
6
- metadata.gz: 794ce9888d5bec3b342cdce1b06111f2d194467ad8b8964f81eb9f84d09540bf62b10dfe1b24aa241a402b31e5c0bfb76cc64e9eb35146e4407be4d8781cd8e6
7
- data.tar.gz: f193740db7fd18fb93c31e7daaae4c1ccbab6b6de93a6eb03e806da99dd3eb88e8069b365546b14ec3ce4ba35dcdc2bab2bc08799c969fe6e3c43bc8139a1d06
6
+ metadata.gz: 83638f36f9019a0dfd6f03516fa7dde89233553fea9a8267401e67f6bb19855382aeea27be2df6c0afe21b42a8319f0e42f48ef4b532dee12a0602b634b69d9a
7
+ data.tar.gz: ab8740820fd6569365f52e4270c96a005df010f03dc64532ba08124954fce0d8aa376cb22b2b5d28b83f85ba34091204a772bdcc9058150ce5e7395779e7d599
data/README.md CHANGED
@@ -6,6 +6,12 @@
6
6
 
7
7
  Mittsu makes 3D graphics easier by providing an abstraction over OpenGL, and is based heavily off of [THREE.js](http://threejs.org). No more weird pointers and wondering about the difference between a VAO and a VBO (besides the letter). Simply think of something awesome and make it!
8
8
 
9
+ ## GIFs!
10
+
11
+ ![Normal-mapped Earth](https://cloud.githubusercontent.com/assets/1171825/18411863/45328540-7781-11e6-986b-6e3f2551c719.gif)
12
+ ![Point Light](https://cloud.githubusercontent.com/assets/1171825/18411861/4531bb4c-7781-11e6-92b4-b6ebda60e2c9.gif)
13
+ ![Tank Demo](https://cloud.githubusercontent.com/assets/1171825/18411862/4531fe9a-7781-11e6-9665-b172df1a3645.gif)
14
+
9
15
  ## Installation
10
16
 
11
17
  Install the prerequisites:
@@ -14,7 +20,7 @@ Mittsu depends on Ruby 2.x, OpenGL 3.3+, GLFW 3.1.x and ImageMagick 6.4.9+
14
20
 
15
21
  ```bash
16
22
  # OSX
17
- $ brew intall glfw3 imagemagick
23
+ $ brew install glfw3 imagemagick
18
24
 
19
25
  # Ubuntu
20
26
  $ sudo apt-get install libglfw3-dev libmagickwand-dev
@@ -3,12 +3,12 @@ require 'glfw'
3
3
 
4
4
  GLFW_LIB_EXT = OpenGL.get_platform == :OPENGL_PLATFORM_MACOSX ? 'dylib' : 'so'
5
5
  if OpenGL.get_platform != :OPENGL_PLATFORM_TEST
6
- GLFW_LIB = begin
6
+ GLFW_LIB = ENV["MITTSU_LIBGLFW_FILE"] || begin
7
7
  "lib#{`pkg-config --libs-only-l glfw3`.gsub(/^-l/, '').chomp.strip}.#{GLFW_LIB_EXT}"
8
8
  rescue
9
9
  "libglfw.#{GLFW_LIB_EXT}"
10
10
  end
11
- GLFW_LIB_PATH = begin
11
+ GLFW_LIB_PATH = ENV["MITTSU_LIBGLFW_PATH"] || begin
12
12
  s = `pkg-config glfw3 --libs-only-L`.gsub(/^-L/, '').chomp.strip
13
13
  s.empty? ? nil : s
14
14
  rescue
@@ -13,38 +13,106 @@ module OpenGLLib
13
13
  end
14
14
 
15
15
  class Linux
16
+ def initialize(loader = Linux)
17
+ @loader = loader
18
+ end
19
+
16
20
  def path
17
- # http://www.pilotlogic.com/sitejoom/index.php/wiki?id=398<F37>
18
- # 32 64
19
- # /usr/lib /usr/lib64 redhat, mandriva
20
- # /usr/lib32 /usr/lib64 arch, gento
21
- # /usr/lib /usr/lib64 slackware
22
- # /usr/lib/i386.. /usr/libx86_64/ debian
23
- libs = Dir.glob("/usr/lib*/**/libGL.so")
24
- if libs.size == 0
25
- puts "no libGL.so"
26
- exit 1
27
- end
28
- case kernel_module_in_use
29
- when /nvidia/
30
- return File.dirname(libs.grep(/nvidia/)[0])
31
- end
32
- # Get the same architecture that the runnning ruby
33
- if 1.size == 8 # 64 bits
34
- File.dirname(libs.grep(/64/)[0])
35
- else # 32 bits
36
- File.dirname(libs[0])
37
- end
21
+ return nil if file_path.nil?
22
+ File.dirname file_path
38
23
  end
39
24
 
40
25
  def file
41
- 'libGL.so'
26
+ return nil if file_path.nil?
27
+ File.basename file_path
42
28
  end
43
29
 
44
- private
30
+ class << self
45
31
  def kernel_module_in_use
46
32
  lspci_line = `lspci -nnk | grep -i vga -A3 | grep 'in use'`
47
- return /in use:\s*(\S+)/ =~ lspci_line && $1
33
+ /in use:\s*(\S+)/ =~ lspci_line && $1
34
+ rescue
35
+ ''
36
+ end
37
+
38
+ def libgl_paths
39
+ Dir.glob('/usr/lib*/**/libGL.so*')
40
+ rescue
41
+ []
42
+ end
43
+
44
+ def sixtyfour_bits?
45
+ 1.size == 8
46
+ end
47
+
48
+ def ldconfig
49
+ `ldconfig -p | grep 'libGL\\.so'`.lines
50
+ rescue
51
+ []
52
+ end
53
+ end
54
+
55
+ private
56
+ def file_path
57
+ @_file_path ||= begin
58
+ ldconfig_lib || driver_specific_lib || sixtyfour_bit_lib || fallback_lib || give_up
59
+ end.tap do |result|
60
+ print_debug_info(result) if Mittsu::DEBUG
61
+ end
62
+ end
63
+
64
+ def ldconfig_lib
65
+ return nil if ldconfig.empty?
66
+ @_debug = { source: 'ldconfig', info: ldconfig.inspect } if Mittsu::DEBUG
67
+ ldconfig_for_arch = ldconfig.reject { |lib| @loader.sixtyfour_bits? ^ ldconfig_64?(lib) }
68
+ ldconfig_for_arch.first.match(/=> (\/.*)$/)[1]
69
+ end
70
+
71
+ def ldconfig_64?(lib)
72
+ lib =~ /\([^\)]*64[^\)]*\) =>/
73
+ end
74
+
75
+ def driver_specific_lib
76
+ return nil if libs.empty?
77
+ @_debug = { source: 'driver', info: kernel_module } if Mittsu::DEBUG
78
+ libs.select { |lib| lib =~ /nvidia/ }.first if kernel_module =~ /nvidia/
79
+ end
80
+
81
+ def sixtyfour_bit_lib
82
+ return nil if libs.empty?
83
+ sixtyfour_bit_libs = libs.select { |lib| lib =~ /64/ }
84
+ @_debug = { source: '64', info: sixtyfour_bit_libs.inspect } if Mittsu::DEBUG
85
+ sixtyfour_bit_libs.first if @loader.sixtyfour_bits?
86
+ end
87
+
88
+ def fallback_lib
89
+ return nil if libs.empty?
90
+ @_debug = { source: 'fallback', info: libs.inspect } if Mittsu::DEBUG
91
+ libs.first
92
+ end
93
+
94
+ def give_up
95
+ @_debug = { source: 'none', info: nil } if Mittsu::DEBUG
96
+ nil
97
+ end
98
+
99
+ def kernel_module
100
+ @_kernel_module ||= @loader.kernel_module_in_use
101
+ end
102
+
103
+ def libs
104
+ @_libs ||= @loader.libgl_paths.sort_by(&:length)
105
+ end
106
+
107
+ def ldconfig
108
+ @_ldconfig ||= @loader.ldconfig
109
+ end
110
+
111
+ def print_debug_info(result)
112
+ puts "Loading lib path: #{result.inspect}"
113
+ puts "Source: #{@_debug[:source]}"
114
+ puts "Info: #{@_debug[:info]}"
115
+ puts "64-bit? #{@loader.sixtyfour_bits?}"
48
116
  end
49
117
  end
50
118
 
@@ -5,7 +5,7 @@ require 'fiddle'
5
5
 
6
6
  require 'mittsu/renderers/opengl/opengl_lib'
7
7
  opengl_lib = OpenGLLib.discover
8
- OpenGL.load_lib(opengl_lib.file, opengl_lib.path)
8
+ OpenGL.load_lib(ENV["MITTSU_LIBGL_FILE"] || opengl_lib.file, ENV["MITTSU_LIBGL_PATH"] || opengl_lib.path)
9
9
 
10
10
  require 'mittsu'
11
11
  require 'mittsu/renderers/glfw_window'
@@ -1,4 +1,4 @@
1
1
  module Mittsu
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  REVISION = "71"
4
4
  end
data/mittsu.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  "bug_tracker" => "https://github.com/jellymann/mittsu/issues"
18
18
  }
19
19
 
20
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|examples)/}) }
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{(^(test|examples)/|\.sh$)}) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
23
  spec.required_ruby_version = '>= 2.0.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mittsu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-10 00:00:00.000000000 Z
11
+ date: 2016-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opengl-bindings
@@ -157,7 +157,6 @@ files:
157
157
  - bin/console
158
158
  - bin/setup
159
159
  - circle.yml
160
- - install-glfw-3.1.2.sh
161
160
  - lib/mittsu.rb
162
161
  - lib/mittsu/cameras.rb
163
162
  - lib/mittsu/cameras/camera.rb
@@ -359,7 +358,6 @@ files:
359
358
  - lib/mittsu/textures/video_texture.rb
360
359
  - lib/mittsu/version.rb
361
360
  - mittsu.gemspec
362
- - run_all_examples.sh
363
361
  homepage: https://github.com/jellymann/mittsu
364
362
  licenses:
365
363
  - MIT
@@ -1,14 +0,0 @@
1
- set -x
2
- set -e
3
- if [ ! -e glfw-3.1.2/include/GLFW/glfw3.h ]; then
4
- wget https://github.com/glfw/glfw/releases/download/3.1.2/glfw-3.1.2.zip
5
- unzip glfw-3.1.2.zip;
6
- fi
7
- cd glfw-3.1.2
8
- if [ ! -e src/libglfw3.so ]; then
9
- cmake -D BUILD_SHARED_LIBS=ON .
10
- make;
11
- fi
12
- if [ ! -e /usr/local/lib/libglfw.so ]; then
13
- sudo make install;
14
- fi
data/run_all_examples.sh DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -x
3
- set -e
4
-
5
- cd examples
6
-
7
- ls *.rb | grep '^[0-9]' | xargs -n 1 ruby