mirror of
https://github.com/cyberarm/i-mic-fps.git
synced 2025-12-15 15:42:35 +00:00
Cleanup i-mic-fps.rb a bit
This commit is contained in:
65
i-mic-fps.rb
65
i-mic-fps.rb
@@ -7,68 +7,17 @@ require "time"
|
|||||||
require "opengl"
|
require "opengl"
|
||||||
require "glu"
|
require "glu"
|
||||||
|
|
||||||
#begin
|
begin
|
||||||
require_relative "../cyberarm_engine/lib/cyberarm_engine"
|
require_relative "../cyberarm_engine/lib/cyberarm_engine"
|
||||||
#rescue LoadError
|
rescue LoadError => e
|
||||||
# require "cyberarm_engine"
|
pp e
|
||||||
#end
|
require "cyberarm_engine"
|
||||||
|
end
|
||||||
|
|
||||||
Dir.chdir(File.dirname(__FILE__))
|
Dir.chdir(File.dirname(__FILE__))
|
||||||
|
|
||||||
case OpenGL.get_platform
|
require_relative "lib/ext/numeric"
|
||||||
when :OPENGL_PLATFORM_WINDOWS
|
require_relative "lib/ext/load_opengl"
|
||||||
OpenGL.load_lib("opengl32.dll", "C:/Windows/System32")
|
|
||||||
GLU.load_lib("GLU32.dll", "C:/Windows/System32")
|
|
||||||
when :OPENGL_PLATFORM_MACOSX
|
|
||||||
OpenGL.load_lib("libGL.dylib", "/System/Library/Frameworks/OpenGL.framework/Libraries")
|
|
||||||
GLU.load_lib("libGLU.dylib", "/System/Library/Frameworks/OpenGL.framework/Libraries")
|
|
||||||
when :OPENGL_PLATFORM_LINUX
|
|
||||||
# Black magic to get GLSL 3.30 support on older Intel hardware
|
|
||||||
# if `glxinfo | egrep "OpenGL vendor|OpenGL renderer"`.include?("Intel")
|
|
||||||
# ENV["MESA_GL_VERSION_OVERRIDE"] = "3.3"
|
|
||||||
# ENV["MESA_GLSL_VERSION_OVERRIDE"] = "330"
|
|
||||||
# end
|
|
||||||
|
|
||||||
gl_library_path = nil
|
|
||||||
|
|
||||||
if File.exist?("/usr/lib/x86_64-linux-gnu/libGL.so") # Ubuntu (Debian)
|
|
||||||
gl_library_path = "/usr/lib/x86_64-linux-gnu"
|
|
||||||
|
|
||||||
elsif File.exist?("/usr/lib/libGL.so") # Manjaro (ARCH)
|
|
||||||
gl_library_path = "/usr/lib"
|
|
||||||
|
|
||||||
elsif File.exist?("/usr/lib/arm-linux-gnueabihf/libGL.so") # Raspbian (ARM/Raspberry Pi)
|
|
||||||
gl_library_path = "/usr/lib/arm-linux-gnueabihf"
|
|
||||||
end
|
|
||||||
|
|
||||||
if gl_library_path
|
|
||||||
OpenGL.load_lib("libGL.so", gl_library_path)
|
|
||||||
GLU.load_lib("libGLU.so", gl_library_path)
|
|
||||||
else
|
|
||||||
raise RuntimeError, "Couldn't find GL libraries"
|
|
||||||
end
|
|
||||||
else
|
|
||||||
raise RuntimeError, "Unsupported platform."
|
|
||||||
end
|
|
||||||
|
|
||||||
if RUBY_VERSION < "2.5.0"
|
|
||||||
puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
|
|
||||||
puts "|NOTICE| Ruby is #{RUBY_VERSION} not 2.5.0+..............................|Notice|"
|
|
||||||
puts "|NOTICE| Monkey Patching Float to add required '.clamp' method.|Notice|"
|
|
||||||
puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
|
|
||||||
puts
|
|
||||||
class Float
|
|
||||||
def clamp(min, max)
|
|
||||||
if self < min
|
|
||||||
min
|
|
||||||
elsif self > max
|
|
||||||
max
|
|
||||||
else
|
|
||||||
return self
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
include CyberarmEngine
|
include CyberarmEngine
|
||||||
include OpenGL
|
include OpenGL
|
||||||
|
|||||||
35
lib/ext/load_opengl.rb
Normal file
35
lib/ext/load_opengl.rb
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
case OpenGL.get_platform
|
||||||
|
when :OPENGL_PLATFORM_WINDOWS
|
||||||
|
OpenGL.load_lib("opengl32.dll", "C:/Windows/System32")
|
||||||
|
GLU.load_lib("GLU32.dll", "C:/Windows/System32")
|
||||||
|
when :OPENGL_PLATFORM_MACOSX
|
||||||
|
OpenGL.load_lib("libGL.dylib", "/System/Library/Frameworks/OpenGL.framework/Libraries")
|
||||||
|
GLU.load_lib("libGLU.dylib", "/System/Library/Frameworks/OpenGL.framework/Libraries")
|
||||||
|
when :OPENGL_PLATFORM_LINUX
|
||||||
|
# Black magic to get GLSL 3.30 support on older Intel hardware
|
||||||
|
# if `glxinfo | egrep "OpenGL vendor|OpenGL renderer"`.include?("Intel")
|
||||||
|
# ENV["MESA_GL_VERSION_OVERRIDE"] = "3.3"
|
||||||
|
# ENV["MESA_GLSL_VERSION_OVERRIDE"] = "330"
|
||||||
|
# end
|
||||||
|
|
||||||
|
gl_library_path = nil
|
||||||
|
|
||||||
|
if File.exist?("/usr/lib/x86_64-linux-gnu/libGL.so") # Ubuntu (Debian)
|
||||||
|
gl_library_path = "/usr/lib/x86_64-linux-gnu"
|
||||||
|
|
||||||
|
elsif File.exist?("/usr/lib/libGL.so") # Manjaro (ARCH)
|
||||||
|
gl_library_path = "/usr/lib"
|
||||||
|
|
||||||
|
elsif File.exist?("/usr/lib/arm-linux-gnueabihf/libGL.so") # Raspbian (ARM/Raspberry Pi)
|
||||||
|
gl_library_path = "/usr/lib/arm-linux-gnueabihf"
|
||||||
|
end
|
||||||
|
|
||||||
|
if gl_library_path
|
||||||
|
OpenGL.load_lib("libGL.so", gl_library_path)
|
||||||
|
GLU.load_lib("libGLU.so", gl_library_path)
|
||||||
|
else
|
||||||
|
raise RuntimeError, "Couldn't find GL libraries"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise RuntimeError, "Unsupported platform."
|
||||||
|
end
|
||||||
18
lib/ext/numeric.rb
Normal file
18
lib/ext/numeric.rb
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
if RUBY_VERSION < "2.5.0"
|
||||||
|
puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
|
||||||
|
puts "|NOTICE| Ruby is #{RUBY_VERSION} not 2.5.0+..............................|Notice|"
|
||||||
|
puts "|NOTICE| Monkey Patching Numeric to add required '.clamp' method.|Notice|"
|
||||||
|
puts "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
|
||||||
|
puts
|
||||||
|
class Numeric
|
||||||
|
def clamp(min, max)
|
||||||
|
if self < min
|
||||||
|
min
|
||||||
|
elsif self > max
|
||||||
|
max
|
||||||
|
else
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user