Module: RAGE
- Defined in:
- lib/rage.rb,
lib/rage/game.rb,
lib/rage/mesh.rb,
lib/rage/text.rb,
lib/rage/audio.rb,
lib/rage/color.rb,
lib/rage/input.rb,
lib/rage/camera.rb,
lib/rage/common.rb,
lib/rage/loader.rb,
lib/rage/window.rb,
lib/rage/location.rb,
lib/rage/resource.rb,
lib/rage/viewport.rb
Overview
Viewport constructs and methods
Copyright © 2010 Mohammed Morsi <[email protected]> Licensed under the GPLv3+ www.gnu.org/licenses/gpl.txt
Defined Under Namespace
Modules: InputHandlers Classes: Audio, Camera, Color, Game, InputHandler, Loader, Location, LocationsManager, Logger, Mesh, ResourcesManager, Text, Viewport, Window
Class Method Summary collapse
-
.to_3d_coordinates(x2, y2) ⇒ Object
Helper method to get 3d coords cooresponding to 2d ones via OPENGL unprojection.
Class Method Details
.to_3d_coordinates(x2, y2) ⇒ Object
Helper method to get 3d coords cooresponding to 2d ones via OPENGL unprojection
142 143 144 145 146 147 148 149 |
# File 'lib/rage/location.rb', line 142 def to_3d_coordinates(x2, y2) model_view = Gl.glGetDoublev Gl::GL_MODELVIEW_MATRIX projection = Gl.glGetDoublev Gl::GL_PROJECTION_MATRIX = Gl.glGetIntegerv Gl::GL_VIEWPORT depth = Gl.glReadPixels x2, y2, 1, 1, Gl::GL_DEPTH_COMPONENT, Gl::GL_FLOAT x3, y3, z3 = Glu.gluUnProject x2, y2, depth[0], model_view, projection, return [x3, y3, z3] end |