├── .gitignore ├── Assets ├── cornell_box.mtl └── cornell_box.obj ├── GIGL.sln ├── GIGL.vcxproj ├── GIGL.vcxproj.filters ├── LICENSE.txt ├── README.md └── Source ├── Common ├── BBox.cpp ├── BBox.h ├── Camera.cpp ├── Camera.h ├── Constants.h ├── Definitions.h ├── Halton.hpp ├── Interpolation.hpp ├── Random.cpp ├── Random.h ├── Renderer.cpp ├── Renderer.h ├── Scene.cpp ├── Scene.h ├── Timer.cpp ├── Timer.h └── Utility.hpp ├── Fog ├── DensityField.cpp ├── DensityField.h ├── FogVolume.cpp └── FogVolume.h ├── GIGL.cpp ├── GL ├── GLElementBuffer.cpp ├── GLElementBuffer.h ├── GLPersistentBuffer.h ├── GLPersistentBuffer.hpp ├── GLRTBLockMngr.cpp ├── GLRTBLockMngr.h ├── GLShader.cpp ├── GLShader.h ├── GLShader.hpp ├── GLTexture2D.h ├── GLTexture2D.hpp ├── GLTextureBuffer.cpp ├── GLTextureBuffer.h ├── GLUniformBuffer.cpp ├── GLUniformBuffer.h ├── GLUniformManager.h ├── GLUniformManager.hpp ├── GLVertArray.cpp └── GLVertArray.h ├── Include ├── GLFW │ ├── COPYING.txt │ ├── README.md │ ├── glfw3.h │ └── glfw3native.h ├── GLM │ ├── CMakeLists.txt │ ├── common.hpp │ ├── copying.txt │ ├── detail │ │ ├── _features.hpp │ │ ├── _fixes.hpp │ │ ├── _literals.hpp │ │ ├── _noise.hpp │ │ ├── _swizzle.hpp │ │ ├── _swizzle_func.hpp │ │ ├── _vectorize.hpp │ │ ├── dummy.cpp │ │ ├── func_common.hpp │ │ ├── func_common.inl │ │ ├── func_exponential.hpp │ │ ├── func_exponential.inl │ │ ├── func_geometric.hpp │ │ ├── func_geometric.inl │ │ ├── func_integer.hpp │ │ ├── func_integer.inl │ │ ├── func_matrix.hpp │ │ ├── func_matrix.inl │ │ ├── func_noise.hpp │ │ ├── func_noise.inl │ │ ├── func_packing.hpp │ │ ├── func_packing.inl │ │ ├── func_trigonometric.hpp │ │ ├── func_trigonometric.inl │ │ ├── func_vector_relational.hpp │ │ ├── func_vector_relational.inl │ │ ├── glm.cpp │ │ ├── hint.hpp │ │ ├── intrinsic_common.hpp │ │ ├── intrinsic_common.inl │ │ ├── intrinsic_exponential.hpp │ │ ├── intrinsic_exponential.inl │ │ ├── intrinsic_geometric.hpp │ │ ├── intrinsic_geometric.inl │ │ ├── intrinsic_integer.hpp │ │ ├── intrinsic_integer.inl │ │ ├── intrinsic_matrix.hpp │ │ ├── intrinsic_matrix.inl │ │ ├── intrinsic_trigonometric.hpp │ │ ├── intrinsic_trigonometric.inl │ │ ├── intrinsic_vector_relational.hpp │ │ ├── intrinsic_vector_relational.inl │ │ ├── precision.hpp │ │ ├── precision.inl │ │ ├── setup.hpp │ │ ├── type_float.hpp │ │ ├── type_gentype.hpp │ │ ├── type_gentype.inl │ │ ├── type_half.hpp │ │ ├── type_half.inl │ │ ├── type_int.hpp │ │ ├── type_mat.hpp │ │ ├── type_mat.inl │ │ ├── type_mat2x2.hpp │ │ ├── type_mat2x2.inl │ │ ├── type_mat2x3.hpp │ │ ├── type_mat2x3.inl │ │ ├── type_mat2x4.hpp │ │ ├── type_mat2x4.inl │ │ ├── type_mat3x2.hpp │ │ ├── type_mat3x2.inl │ │ ├── type_mat3x3.hpp │ │ ├── type_mat3x3.inl │ │ ├── type_mat3x4.hpp │ │ ├── type_mat3x4.inl │ │ ├── type_mat4x2.hpp │ │ ├── type_mat4x2.inl │ │ ├── type_mat4x3.hpp │ │ ├── type_mat4x3.inl │ │ ├── type_mat4x4.hpp │ │ ├── type_mat4x4.inl │ │ ├── type_vec.hpp │ │ ├── type_vec.inl │ │ ├── type_vec1.hpp │ │ ├── type_vec1.inl │ │ ├── type_vec2.hpp │ │ ├── type_vec2.inl │ │ ├── type_vec3.hpp │ │ ├── type_vec3.inl │ │ ├── type_vec4.hpp │ │ └── type_vec4.inl │ ├── exponential.hpp │ ├── ext.hpp │ ├── fwd.hpp │ ├── geometric.hpp │ ├── glm.hpp │ ├── gtc │ │ ├── constants.hpp │ │ ├── constants.inl │ │ ├── epsilon.hpp │ │ ├── epsilon.inl │ │ ├── matrix_access.hpp │ │ ├── matrix_access.inl │ │ ├── matrix_integer.hpp │ │ ├── matrix_inverse.hpp │ │ ├── matrix_inverse.inl │ │ ├── matrix_transform.hpp │ │ ├── matrix_transform.inl │ │ ├── noise.hpp │ │ ├── noise.inl │ │ ├── packing.hpp │ │ ├── packing.inl │ │ ├── quaternion.hpp │ │ ├── quaternion.inl │ │ ├── random.hpp │ │ ├── random.inl │ │ ├── reciprocal.hpp │ │ ├── reciprocal.inl │ │ ├── type_precision.hpp │ │ ├── type_precision.inl │ │ ├── type_ptr.hpp │ │ ├── type_ptr.inl │ │ ├── ulp.hpp │ │ └── ulp.inl │ ├── gtx │ │ ├── associated_min_max.hpp │ │ ├── associated_min_max.inl │ │ ├── bit.hpp │ │ ├── bit.inl │ │ ├── closest_point.hpp │ │ ├── closest_point.inl │ │ ├── color_space.hpp │ │ ├── color_space.inl │ │ ├── color_space_YCoCg.hpp │ │ ├── color_space_YCoCg.inl │ │ ├── compatibility.hpp │ │ ├── compatibility.inl │ │ ├── component_wise.hpp │ │ ├── component_wise.inl │ │ ├── constants.hpp │ │ ├── dual_quaternion.hpp │ │ ├── dual_quaternion.inl │ │ ├── epsilon.hpp │ │ ├── euler_angles.hpp │ │ ├── euler_angles.inl │ │ ├── extend.hpp │ │ ├── extend.inl │ │ ├── extented_min_max.hpp │ │ ├── extented_min_max.inl │ │ ├── fast_exponential.hpp │ │ ├── fast_exponential.inl │ │ ├── fast_square_root.hpp │ │ ├── fast_square_root.inl │ │ ├── fast_trigonometry.hpp │ │ ├── fast_trigonometry.inl │ │ ├── gradient_paint.hpp │ │ ├── gradient_paint.inl │ │ ├── handed_coordinate_space.hpp │ │ ├── handed_coordinate_space.inl │ │ ├── inertia.hpp │ │ ├── inertia.inl │ │ ├── int_10_10_10_2.hpp │ │ ├── int_10_10_10_2.inl │ │ ├── integer.hpp │ │ ├── integer.inl │ │ ├── intersect.hpp │ │ ├── intersect.inl │ │ ├── io.hpp │ │ ├── io.inl │ │ ├── log_base.hpp │ │ ├── log_base.inl │ │ ├── matrix_cross_product.hpp │ │ ├── matrix_cross_product.inl │ │ ├── matrix_interpolation.hpp │ │ ├── matrix_interpolation.inl │ │ ├── matrix_major_storage.hpp │ │ ├── matrix_major_storage.inl │ │ ├── matrix_operation.hpp │ │ ├── matrix_operation.inl │ │ ├── matrix_query.hpp │ │ ├── matrix_query.inl │ │ ├── matrix_transform_2d.hpp │ │ ├── matrix_transform_2d.inl │ │ ├── mixed_product.hpp │ │ ├── mixed_product.inl │ │ ├── multiple.hpp │ │ ├── multiple.inl │ │ ├── noise.hpp │ │ ├── norm.hpp │ │ ├── norm.inl │ │ ├── normal.hpp │ │ ├── normal.inl │ │ ├── normalize_dot.hpp │ │ ├── normalize_dot.inl │ │ ├── number_precision.hpp │ │ ├── number_precision.inl │ │ ├── optimum_pow.hpp │ │ ├── optimum_pow.inl │ │ ├── orthonormalize.hpp │ │ ├── orthonormalize.inl │ │ ├── perpendicular.hpp │ │ ├── perpendicular.inl │ │ ├── polar_coordinates.hpp │ │ ├── polar_coordinates.inl │ │ ├── projection.hpp │ │ ├── projection.inl │ │ ├── quaternion.hpp │ │ ├── quaternion.inl │ │ ├── random.hpp │ │ ├── raw_data.hpp │ │ ├── raw_data.inl │ │ ├── reciprocal.hpp │ │ ├── rotate_normalized_axis.hpp │ │ ├── rotate_normalized_axis.inl │ │ ├── rotate_vector.hpp │ │ ├── rotate_vector.inl │ │ ├── scalar_relational.hpp │ │ ├── scalar_relational.inl │ │ ├── simd_mat4.hpp │ │ ├── simd_mat4.inl │ │ ├── simd_quat.hpp │ │ ├── simd_quat.inl │ │ ├── simd_vec4.hpp │ │ ├── simd_vec4.inl │ │ ├── spline.hpp │ │ ├── spline.inl │ │ ├── std_based_type.hpp │ │ ├── std_based_type.inl │ │ ├── string_cast.hpp │ │ ├── string_cast.inl │ │ ├── transform.hpp │ │ ├── transform.inl │ │ ├── transform2.hpp │ │ ├── transform2.inl │ │ ├── ulp.hpp │ │ ├── unsigned_int.hpp │ │ ├── unsigned_int.inl │ │ ├── vec1.hpp │ │ ├── vec1.inl │ │ ├── vector_angle.hpp │ │ ├── vector_angle.inl │ │ ├── vector_query.hpp │ │ ├── vector_query.inl │ │ ├── wrap.hpp │ │ └── wrap.inl │ ├── integer.hpp │ ├── mat2x2.hpp │ ├── mat2x3.hpp │ ├── mat2x4.hpp │ ├── mat3x2.hpp │ ├── mat3x3.hpp │ ├── mat3x4.hpp │ ├── mat4x2.hpp │ ├── mat4x3.hpp │ ├── mat4x4.hpp │ ├── matrix.hpp │ ├── packing.hpp │ ├── readme.txt │ ├── trigonometric.hpp │ ├── vec2.hpp │ ├── vec3.hpp │ ├── vec4.hpp │ └── vector_relational.hpp ├── OpenGL │ ├── gl_basic_typedefs.h │ ├── gl_core_4_4.cpp │ └── gl_core_4_4.hpp └── TinyOBJ │ ├── README.md │ ├── tiny_obj_loader.cc │ └── tiny_obj_loader.h ├── Libraries ├── glfw3.lib └── glfw3d.lib ├── RT ├── KdTree.h ├── KdTree.hpp ├── PhotonTracer.cpp ├── PhotonTracer.h ├── RTBase.cpp └── RTBase.h ├── Shaders ├── Combine.frag ├── GBuffer.frag ├── GBuffer.vert ├── Shade.vert ├── Shadow.frag ├── Shadow.geom ├── Shadow.vert ├── Surface.frag └── Volume.frag ├── UI ├── InputHandler.cpp ├── InputHandler.h ├── Window.cpp └── Window.h └── VPL ├── LightArray.h ├── LightArray.hpp ├── OmniShadowMap.cpp ├── OmniShadowMap.h ├── OmniShadowMap.hpp ├── PointLight.cpp ├── PointLight.h └── PointLight.hpp /.gitignore: -------------------------------------------------------------------------------- 1 | # git ignore file 2 | 3 | # Ignore all files, keep folders 4 | * 5 | !*/ 6 | Temp*/ 7 | 8 | # File exceptions 9 | !.gitignore 10 | !Makefile 11 | 12 | # Source files 13 | !*.h 14 | !*.hpp 15 | !*.inl 16 | !*.c 17 | !*.cc 18 | !*.cpp 19 | !*.cu 20 | 21 | # Shader files 22 | !*.vs 23 | !*.vert 24 | !*.gs 25 | !*.geom 26 | !*.tcs 27 | !*.tes 28 | !*.fs 29 | !*.frag 30 | !*.cs 31 | 32 | # Docs & info 33 | !*.txt 34 | !*.md 35 | 36 | # MSVC files 37 | !*.sln 38 | !*.vcxproj 39 | !*.vcxproj.filters 40 | 41 | # Libraries 42 | !*.lib 43 | !*.dll 44 | 45 | # Models 46 | !*.obj 47 | !*.mtl 48 | -------------------------------------------------------------------------------- /Assets/cornell_box.mtl: -------------------------------------------------------------------------------- 1 | newmtl white 2 | Kd 0.74 0.74 0.73 3 | Ks 0.0 0.0 0.0 4 | Ns 0.0 5 | Ke 0.0 0.0 0.0 6 | 7 | newmtl red 8 | Kd 0.46 0.04 0.05 9 | Ks 0.0 0.0 0.0 10 | Ns 0.0 11 | kE 0.0 0.0 0.0 12 | 13 | newmtl green 14 | Kd 0.1 0.4 0.08 15 | Ks 0.0 0.0 0.0 16 | Ns 0.0 17 | Ke 0.0 0.0 0.0 18 | 19 | newmtl light 20 | Kd 0.0 0.0 0.0 21 | Ks 0.0 0.0 0.0 22 | Ns 0.0 23 | Ke 17.0 11.4 2.9 24 | -------------------------------------------------------------------------------- /GIGL.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30501.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GIGL", "GIGL.vcxproj", "{F297FF13-5CC0-45E1-A720-9C5A57881BCB}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {F297FF13-5CC0-45E1-A720-9C5A57881BCB}.Debug|x64.ActiveCfg = Debug|x64 15 | {F297FF13-5CC0-45E1-A720-9C5A57881BCB}.Debug|x64.Build.0 = Debug|x64 16 | {F297FF13-5CC0-45E1-A720-9C5A57881BCB}.Release|x64.ActiveCfg = Release|x64 17 | {F297FF13-5CC0-45E1-A720-9C5A57881BCB}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 zalbard 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | GIGL - Tiny Global Illumination OpenGL Renderer 2 | 3 | ![scr_gi](https://cloud.githubusercontent.com/assets/2144122/9428790/411fcdbe-49ba-11e5-9a44-d2c1615184ab.jpg) 4 | 5 | ![scr_mult_scat](https://cloud.githubusercontent.com/assets/2144122/9428697/74b8a5c2-49b7-11e5-9f09-8601bd2423e4.jpg) 6 | 7 | DISCLAIMER: this is a work in progress! :-) 8 | 9 | Loosely based on the following papers: 10 | 11 | 1. Keller, "Instant radiosity"; 12 | 2. Engelhardt et al., "Instant multiple scattering for interactive rendering of heterogeneous participating media"; 13 | 3. Engelhardt et al., "Approximate bias compensation for rendering scenes with heterogeneous participating media". 14 | 15 | Requirements: 16 | 17 | 1. MSVC2013 redistributables (https://www.microsoft.com/en-us/download/details.aspx?id=40784); 18 | 2. graphics drivers with OpenGL 4.4 support. 19 | 20 | Notice: 21 | 22 | During the first start up, the renderer will procedurally generate volume density textures (64^3 in the world space, and 64x1024^2 precomputed in the camera space). This may take a few seconds. 23 | The subsequent program launches will be considerably faster, as the textures will be read from the disk. 24 | 25 | Controls: 26 | 27 | * Arrow keys move the primary light source; 28 | * Numpad + - control the volume density; 29 | * Numpad * / control the exposure time; 30 | * F toggle the fog; 31 | * G toggle global illumination; 32 | * M toggle the use of ray marching to compute transmittance along shadow rays; 33 | * SPACE reset all settings; 34 | * R reset the accumulation buffer (hold to temporarily disable it); 35 | * C toggle clamping and the primary light source; 36 | * 1 set the VPL count to 10; 37 | * 2 set the VPL count to 50; 38 | * 3 set the VPL count to 150; 39 | * ESC exit the application. 40 | -------------------------------------------------------------------------------- /Source/Common/BBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Definitions.h" 5 | 6 | namespace rt { class Ray; } 7 | 8 | /* Axis-aligned bounding box (AABB) */ 9 | class BBox { 10 | public: 11 | BBox(); 12 | RULE_OF_ZERO(BBox); 13 | // Constructor using specified bounds 14 | explicit BBox(const glm::vec3& min_pt, const glm::vec3& max_pt); 15 | // Returns an "empty" bounding box 16 | static BBox empty(); 17 | // Extend bounding box to contain a point 18 | void extend(const glm::vec3& p); 19 | // Extend the bounding box to contain another bounding box 20 | void extend(const BBox& bbox); 21 | // Check whether the point is located inside bounding box 22 | bool containsPoint(const glm::vec3& p) const; 23 | // Returns dimensions of bounding box 24 | glm::vec3 dimensions() const; 25 | // Computes normalized position within BBox from specified absolute position 26 | glm::vec3 computeNormPos(const glm::vec3& w_pos) const; 27 | // Computes surface area of bounding box 28 | float computeArea() const; 29 | // Returns axis of maximal extent 30 | int maxExtentAxis() const; 31 | // Returns the bottom near left bounding point 32 | const glm::vec3& minPt() const; 33 | // Returns the top far right bounding point 34 | const glm::vec3& maxPt() const; 35 | // Distances to entry and exit points of intersection with BBox 36 | // If there is no intersection, then the entry distance is FLT_MAX 37 | struct IntDist { 38 | IntDist(); 39 | explicit IntDist(const float t_entr, const float t_exit); 40 | operator bool() const; 41 | // Storage 42 | float entr, exit; 43 | }; 44 | // Williams et al. intersection algorithm (2005) 45 | // Returns entry and exit distances of ray with bounding box 46 | BBox::IntDist intersect(const rt::Ray& ray) const; 47 | private: 48 | glm::vec3 m_bound_pts[2]; // two points - min and max bounds 49 | }; 50 | -------------------------------------------------------------------------------- /Source/Common/Camera.cpp: -------------------------------------------------------------------------------- 1 | #include "Camera.h" 2 | #include 3 | #include 4 | #include "..\RT\RTBase.h" 5 | 6 | using glm::ivec2; 7 | using glm::vec3; 8 | using glm::mat3; 9 | using glm::mat4; 10 | using glm::cross; 11 | using glm::lookAt; 12 | using glm::normalize; 13 | using glm::perspective; 14 | 15 | PerspectiveCamera::PerspectiveCamera(const vec3& world_pos, const vec3& dir, const vec3& up, 16 | const float h_fov, const int res_x, const int res_y, 17 | const float t_near, const float t_far): 18 | m_res{res_x, res_y}, m_world_pos{world_pos} { 19 | const float aspect_ratio{static_cast(res_x) / static_cast(res_y)}; 20 | // Set up virtual sensor coordinate system 21 | const vec3 fwd_axis{normalize(dir)}; 22 | const vec3 right_axis{normalize(cross(fwd_axis, up))}; 23 | const vec3 up_axis{normalize(cross(right_axis, fwd_axis))}; 24 | const vec3 row_vec{2.0f * tan(0.5f * h_fov) * right_axis * aspect_ratio}; 25 | const vec3 col_vec{2.0f * tan(0.5f * h_fov) * up_axis}; 26 | m_bottom_left = fwd_axis - 0.5f * row_vec - 0.5f * col_vec; 27 | // Compute pixel/sensor_element dimension vectors 28 | m_step_x = row_vec / static_cast(res_x); 29 | m_step_y = col_vec / static_cast(res_y); 30 | // Compute the transformation matrices 31 | m_view_mat = lookAt(world_pos, world_pos + dir, up); 32 | m_proj_mat = perspective(h_fov, aspect_ratio, t_near, t_far); 33 | } 34 | 35 | const glm::ivec2& PerspectiveCamera::resolution() const { 36 | return m_res; 37 | } 38 | 39 | const vec3& PerspectiveCamera::worldPos() const { 40 | return m_world_pos; 41 | } 42 | 43 | const mat4& PerspectiveCamera::viewMat() const { 44 | return m_view_mat; 45 | } 46 | 47 | const mat4& PerspectiveCamera::projMat() const { 48 | return m_proj_mat; 49 | } 50 | 51 | mat4 PerspectiveCamera::computeModelView(const mat4& model_mat) const { 52 | return m_view_mat * model_mat; 53 | } 54 | 55 | mat4 PerspectiveCamera::computeMVP(const mat4& model_view) const { 56 | return m_proj_mat * model_view; 57 | } 58 | 59 | mat3 PerspectiveCamera::computeNormXForm(const mat4& m) { 60 | // Remove the translation component 61 | const mat3 m_no_transl = mat3{m}; 62 | return glm::inverseTranspose(m_no_transl); 63 | } 64 | 65 | rt::Ray PerspectiveCamera::getPrimaryRay(const float x, const float y) const { 66 | const vec3 dir{m_bottom_left + x * m_step_x + y * m_step_y}; 67 | return rt::Ray{m_world_pos, normalize(dir)}; 68 | } 69 | -------------------------------------------------------------------------------- /Source/Common/Camera.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "Definitions.h" 7 | 8 | namespace rt { class Ray; } 9 | 10 | /* Perspective camera class */ 11 | class PerspectiveCamera { 12 | public: 13 | PerspectiveCamera() = delete; 14 | RULE_OF_ZERO(PerspectiveCamera); 15 | // Constructs camera using specified world space position, direction (focal axis), up vector, 16 | // horizontal FoV, resolution, and distances to near and far planes 17 | explicit PerspectiveCamera(const glm::vec3& world_pos, const glm::vec3& dir, 18 | const glm::vec3& up, const float h_fov, 19 | const int res_x, const int res_y, 20 | const float t_near, const float t_far); 21 | // Returns sensor resolution 22 | const glm::ivec2& resolution() const; 23 | // Returns camera position in world space 24 | const glm::vec3& worldPos() const; 25 | // Returns matrix transforming from world to camera space 26 | const glm::mat4& viewMat() const; 27 | // Returns matrix transforming from camera to to homogeneous (projected) coordinates 28 | const glm::mat4& projMat() const; 29 | // Computes model-view matrix given model matrix 30 | glm::mat4 computeModelView(const glm::mat4& model_mat) const; 31 | // Computes model-view-projection matrix given model-view matrix 32 | glm::mat4 computeMVP(const glm::mat4& model_view) const; 33 | // Computes normal transformation matrix 34 | static glm::mat3 computeNormXForm(const glm::mat4& model_view); 35 | // Returns primary ray for specified screen space coordinates 36 | // No pixel center adjustments! 37 | rt::Ray getPrimaryRay(const float x, const float y) const; 38 | private: 39 | glm::ivec2 m_res; // Sensor resolution 40 | glm::vec3 m_world_pos; // Position in World space 41 | glm::vec3 m_bottom_left; // Bottom left corner of the virtual sensor 42 | glm::vec3 m_step_x; // Horizontal dimensions of virtual sensor element 43 | glm::vec3 m_step_y; // Vertical dimensions of virtual sensor element 44 | glm::mat4 m_view_mat; // World to Camera space transformation matrix 45 | glm::mat4 m_proj_mat; // Camera space to Homogeneous space transformation matrix 46 | }; 47 | -------------------------------------------------------------------------------- /Source/Common/Definitions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | using uint = unsigned int; 4 | 5 | #if __cplusplus <= 201103L 6 | /* No full C++ 11 support */ 7 | // Assume noexcept is not supported 8 | #define NOEXCEPT throw() 9 | // Assume constexpr is not supported 10 | #define CONSTEXPR static const 11 | // Assume [[ noreturn ]] is not supported 12 | #define NORETURN __declspec( noreturn ) 13 | // Assume that std::generate_canonical is broken 14 | #define BROKEN_STD_GENERATE_CANONICAL 15 | // Synthesizing default move CTORs and assignment OPs is not supported by MSVC 2013 16 | // MSVC will use copy CTORs and assignment OPs instead 17 | #define DEFAULT_MOVE(T) 18 | #else 19 | #define NOEXCEPT noexcept 20 | #define CONSTEXPR constexpr 21 | #define NORETURN [[ noreturn ]] 22 | #define DEFAULT_MOVE(T) T(T&&) NOEXCEPT = default; \ 23 | T& operator=(T&&) NOEXCEPT = default 24 | #endif 25 | 26 | // Declares -default- Dtor, copy/move Ctors and assignment Ops 27 | #define RULE_OF_ZERO(T) T(const T&) = default; \ 28 | T& operator=(const T&) = default; \ 29 | DEFAULT_MOVE(T); \ 30 | ~T() = default 31 | 32 | // Declares -explicit- Dtor, copy/move Ctors and assignment Ops 33 | #define RULE_OF_FIVE(T) T(const T&); \ 34 | T& operator=(const T&); \ 35 | T(T&&) NOEXCEPT; \ 36 | T& operator=(T&&) NOEXCEPT; \ 37 | ~T() 38 | 39 | // Declares -default- Dtor, move Ctor and assignment Op 40 | // Forbids copy construction and copy assignment 41 | #define RULE_OF_ZERO_NO_COPY(T) T(const T&) = delete; \ 42 | T& operator=(const T&) = delete; \ 43 | DEFAULT_MOVE(T); \ 44 | ~T() = default 45 | 46 | // Declares -explicit- Dtor, move Ctor and assignment Op 47 | // Forbids copy construction and copy assignment 48 | #define RULE_OF_FIVE_NO_COPY(T) T(const T&) = delete; \ 49 | T& operator=(const T&) = delete; \ 50 | T(T&&) NOEXCEPT; \ 51 | T& operator=(T&&) NOEXCEPT; \ 52 | ~T() 53 | 54 | // Use old-style vertex array binding; disable on Quadro 55 | #define OLD_STYLE_BINDING 56 | -------------------------------------------------------------------------------- /Source/Common/Halton.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /* Halton Sequence Generator */ 4 | namespace HaltonSG { 5 | // Generates Halton sequence with base B of size N 6 | template 7 | void generate(float (&seq)[N]) { 8 | for (int i = 0; i < N; ++i) { 9 | seq[i] = 0.0f; 10 | int den{B}, t{i + 1}; 11 | while (t > 0) { 12 | seq[i] += 1.0f / den * (t % B); 13 | t /= B; 14 | den *= B; 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Source/Common/Interpolation.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | template 4 | static inline T lerp1D(const T& p0, const T& p1, const float t) { 5 | return (1.0f - t) * p0 + t * p1; 6 | } 7 | 8 | template 9 | static inline T lerp2D(const T& p00, const T& p10, const T& p01, const T& p11, 10 | const float tx, const float ty) { 11 | const T i0 = lerp1D(p00, p10, tx); 12 | const T i1 = lerp1D(p01, p11, tx); 13 | return lerp1D(i0, i1, ty); 14 | } 15 | 16 | template 17 | static inline T lerp3D(const T& p000, const T& p100, const T& p010, const T& p110, 18 | const T& p001, const T& p101, const T& p011, const T& p111, 19 | const float tx, const float ty, const float tz) { 20 | const T i0 = lerp2D(p000, p100, p010, p110, tx, ty); 21 | const T i1 = lerp2D(p001, p101, p011, p111, tx, ty); 22 | return lerp1D(i0, i1, tz); 23 | } 24 | -------------------------------------------------------------------------------- /Source/Common/Random.cpp: -------------------------------------------------------------------------------- 1 | #include "Random.h" 2 | #include 3 | 4 | std::mt19937 UnitRNG::m_gen; 5 | 6 | void UnitRNG::init() { 7 | static std::random_device rd; 8 | m_gen = std::mt19937{rd()}; 9 | } 10 | 11 | float UnitRNG::generate() { 12 | #ifdef BROKEN_STD_GENERATE_CANONICAL 13 | static const std::uniform_real_distribution dis{0.0, 1.0}; 14 | return dis(m_gen); 15 | #else 16 | return std::generate_canonical::digits>(gen); 17 | #endif 18 | } 19 | -------------------------------------------------------------------------------- /Source/Common/Random.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Definitions.h" 4 | 5 | namespace std { 6 | template class mersenne_twister_engine; 10 | 11 | using mt19937 = mersenne_twister_engine; 13 | } 14 | 15 | /* Random Number Generator on unit interval: [0, 1) */ 16 | class UnitRNG { 17 | public: 18 | UnitRNG() = delete; 19 | RULE_OF_ZERO(UnitRNG); 20 | // Performs initialization 21 | static void init(); 22 | // Generates a random single-precision float on [0, 1) 23 | static float generate(); 24 | private: 25 | static std::mt19937 m_gen; // Mersenne Twister pseudorandom number generator 26 | }; 27 | -------------------------------------------------------------------------------- /Source/Common/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include "Timer.h" 2 | #include 3 | 4 | #ifdef min 5 | #undef min 6 | #endif 7 | 8 | #ifdef max 9 | #undef max 10 | #endif 11 | 12 | HighResTimer::time_point HighResTimer::now() { 13 | LARGE_INTEGER n_ticks, ticks_per_second; 14 | QueryPerformanceCounter(&n_ticks); 15 | QueryPerformanceFrequency(&ticks_per_second); 16 | // Avoid precision loss 17 | long long tmp = n_ticks.QuadPart * static_cast(period::den); 18 | // Return the number of microseconds 19 | return time_point(duration(tmp / ticks_per_second.QuadPart)); 20 | } 21 | 22 | uint HighResTimer::time_ms() { 23 | const auto time_now = now().time_since_epoch(); 24 | const auto ms_count = std::chrono::duration_cast(time_now).count(); 25 | return static_cast(ms_count); 26 | } 27 | -------------------------------------------------------------------------------- /Source/Common/Timer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Definitions.h" 5 | 6 | /* Static class representing high resolution timer on Windows */ 7 | class HighResTimer { 8 | public: 9 | HighResTimer() = delete; 10 | RULE_OF_ZERO(HighResTimer); 11 | using rep = long long; 12 | using period = std::micro; 13 | using duration = std::chrono::duration; 14 | using time_point = std::chrono::time_point; 15 | // Mark it as steady 16 | static const bool is_steady = true; 17 | // Retrieves the current value of the high resolution performance counter 18 | static time_point now(); 19 | // Returns the number of milliseconds since timer reset 20 | static uint time_ms(); 21 | }; 22 | -------------------------------------------------------------------------------- /Source/Common/Utility.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "Definitions.h" 8 | 9 | // Compute square of value 10 | template 11 | static inline T sq(const T v) { 12 | return v * v; 13 | } 14 | 15 | // Compute inverse square of value 16 | template 17 | static inline float invSq(const T v) { 18 | return 1.0f / (v * v); 19 | } 20 | 21 | // For internal use only 22 | static inline void printInternal(FILE* const stream, const char* const fmt, const va_list& args) { 23 | // Print timestamp 24 | time_t raw_time; 25 | struct tm time_info; 26 | time(&raw_time); 27 | localtime_s(&time_info, &raw_time); 28 | fprintf(stdout, "[%i:%i:%i] ", time_info.tm_hour, time_info.tm_min, time_info.tm_sec); 29 | // Print arguments 30 | vfprintf(stream, fmt, args); 31 | } 32 | 33 | // Print information to stdout (printf syntax) 34 | static inline void printInfo(const char* const fmt, ...) { 35 | va_list args; 36 | va_start(args, fmt); 37 | printInternal(stdout, fmt, args); 38 | va_end(args); 39 | fputs("\n", stdout); 40 | } 41 | 42 | // Print warnings/errors to stderr (printf syntax) 43 | static inline void printError(const char* const fmt, ...) { 44 | va_list args; 45 | va_start(args, fmt); 46 | printInternal(stderr, fmt, args); 47 | va_end(args); 48 | fputs("\n", stderr); 49 | } 50 | 51 | // For internal use only 52 | NORETURN static inline void panic(const char* const file, const int line) { 53 | fprintf(stderr, "Error location: %s : %i\n", file, line); 54 | abort(); 55 | } 56 | 57 | // Print fatal error location and terminate the program 58 | #define TERMINATE() panic(__FILE__, __LINE__) 59 | -------------------------------------------------------------------------------- /Source/Fog/DensityField.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "..\Common\BBox.h" 6 | 7 | class Scene; 8 | class PerspectiveCamera; 9 | 10 | /* Scalar-valued particle density field */ 11 | class DensityField { 12 | public: 13 | DensityField() = delete; 14 | RULE_OF_FIVE(DensityField); 15 | // Constructor that generates density field using simplex noise 16 | explicit DensityField(const BBox& bb, const int(&res)[3], const float freq, const float ampl, 17 | const PerspectiveCamera& cam, const Scene& scene); 18 | // Constructor that reads density field and preintegrated density values from .3dt files 19 | explicit DensityField(const BBox& bb, const char* const dens_file_name, 20 | const char* const pi_dens_file_name); 21 | // Returns bounding box/volume 22 | const BBox& bbox() const; 23 | // Returns bounding volume entry and exit distances 24 | BBox::IntDist intersect(const rt::Ray& ray) const; 25 | // Samples density at a given spatial position 26 | float sampleDensity(const glm::vec3& pos) const; 27 | private: 28 | // Returns a density sample 29 | float sample(const GLsizei x, const GLsizei y, const GLsizei z) const; 30 | // Reads density values from file 31 | void read(const char* const file_name); 32 | // Writes density values to file 33 | void write(const char* const file_name) const; 34 | // Returns the size of the field, e.i. the number of stored density values 35 | GLsizei size() const; 36 | // Creates a density texture in OpenGL 37 | void createTex(); 38 | // Computes a 3D-texture with preintegrated camera-space density values 39 | // Numerically valuate e ^ (Int{0..d}(density(t))dt) 40 | void computePiDensity(const PerspectiveCamera& cam, const Scene& scene); 41 | // Reads preintegrated density values from file 42 | void readPiDens(const char* const file_name); 43 | // Writes preintegrated density values to file 44 | void writePiDens(const char* const file_name) const; 45 | // Returns the size of preintegrated density data 46 | GLsizei piDensSize() const; 47 | // Creates a preintegrated density texture in OpenGL 48 | void createPiDensTex(); 49 | // Performs object destruction 50 | void destroy(); 51 | // Private data members 52 | BBox m_bbox; // Bounding box/volume 53 | glm::ivec3 m_res; // Resolution in X-Y-Z 54 | GLubyte* m_data; // Scalar density data 55 | GLuint m_tex_handle; // Density texture OpenGL handle 56 | glm::ivec3 m_pi_dens_res; // Resolution of preintegrated density in X-Y-Z 57 | GLfloat* m_pi_dens_data; // Preintegrated density data 58 | GLuint m_pi_dens_tex_handle; // Preintegrated density texture OpenGL handle 59 | }; 60 | -------------------------------------------------------------------------------- /Source/Fog/FogVolume.cpp: -------------------------------------------------------------------------------- 1 | #include "FogVolume.h" 2 | #include 3 | 4 | using glm::vec3; 5 | 6 | 7 | FogVolume::FogVolume(const BBox& bb, const int (&res)[3], const float freq, const float ampl, 8 | const float maj_ext_k, const float abs_k, const float sca_k, 9 | const PerspectiveCamera& cam, const Scene& scene): 10 | m_df{bb, res, freq, ampl, cam, scene}, m_abs_k{abs_k}, m_sca_k{sca_k}, 11 | m_maj_ext_k{maj_ext_k} {} 12 | 13 | FogVolume::FogVolume(DensityField&& df, const float maj_ext_k, const float abs_k, 14 | const float sca_k): m_df{std::forward(df)}, m_abs_k{abs_k}, m_sca_k{sca_k}, 15 | m_maj_ext_k{maj_ext_k} {} 16 | 17 | void FogVolume::setCoeffs(const float maj_ext_k, const float abs_k, 18 | const float sca_k) { 19 | m_maj_ext_k = maj_ext_k; 20 | m_abs_k = abs_k; 21 | m_sca_k = sca_k; 22 | } 23 | 24 | const BBox& FogVolume::bbox() const { 25 | return m_df.bbox(); 26 | } 27 | 28 | float FogVolume::getMajExtK() const { 29 | return m_maj_ext_k; 30 | } 31 | 32 | float FogVolume::sampleExtK(const vec3& pos) const { 33 | const float dens{m_df.sampleDensity(pos)}; 34 | const float ext_k{m_abs_k + m_sca_k}; 35 | return ext_k * dens; 36 | } 37 | 38 | float FogVolume::sampleScaK(const vec3& pos) const { 39 | const float dens{m_df.sampleDensity(pos)}; 40 | return m_sca_k * dens; 41 | } 42 | 43 | float FogVolume::getScaAlbedo() const { 44 | const float ext_k{m_abs_k + m_sca_k}; 45 | return m_sca_k / ext_k; 46 | } 47 | 48 | BBox::IntDist FogVolume::intersect(const rt::Ray& ray) const { 49 | return m_df.intersect(ray); 50 | } 51 | -------------------------------------------------------------------------------- /Source/Fog/FogVolume.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "DensityField.h" 4 | 5 | class Scene; 6 | 7 | /* Scalar-valued fog bounded by a rectangular parallelepiped (AABB) */ 8 | class FogVolume { 9 | public: 10 | FogVolume() = delete; 11 | RULE_OF_ZERO(FogVolume); 12 | // Constructor, computes the values of density field 13 | explicit FogVolume(const BBox& bb, const int(&res)[3], const float freq, const float ampl, 14 | const float maj_ext_k, const float abs_k, 15 | const float sca_k, const PerspectiveCamera& cam, const Scene& scene); 16 | // Constructor, uses the supplied density field 17 | explicit FogVolume(DensityField&& df, const float maj_ext_k, 18 | const float abs_k, const float sca_k); 19 | // Modifies absorption, scattering and extinction coefficients 20 | void setCoeffs(const float maj_ext_k, const float abs_k, const float sca_k); 21 | // Returns bounding box of fog volume 22 | const BBox& bbox() const; 23 | // Returns majorant extinction coefficient 24 | float getMajExtK() const; 25 | // Samples extinction coefficient at a given position 26 | float sampleExtK(const glm::vec3& pos) const; 27 | // Samples scattering coefficient at a given position 28 | float sampleScaK(const glm::vec3& pos) const; 29 | // Returns scattering albedo (constant across the entire volume) 30 | float getScaAlbedo() const; 31 | // Returns volume entry and exit distances 32 | BBox::IntDist intersect(const rt::Ray& ray) const; 33 | private: 34 | // Private data members 35 | DensityField m_df; // Scalar-valued particle density field 36 | float m_abs_k; // Absorption coefficient per unit density 37 | float m_sca_k; // Scattering coefficient per unit density 38 | float m_maj_ext_k; // Max. extinction coefficient present in volume 39 | }; 40 | -------------------------------------------------------------------------------- /Source/GL/GLElementBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "..\Common\Definitions.h" 6 | 7 | class GLVertArray; 8 | 9 | /* OpenGL element (index) buffer */ 10 | class GLElementBuffer { 11 | public: 12 | GLElementBuffer(); 13 | RULE_OF_FIVE(GLElementBuffer); 14 | // Copies preloaded data to GPU 15 | void buffer(); 16 | // Load indexing information from std::vector 17 | void loadData(const std::vector& data_vec, const GLuint offset); 18 | // Load indexing information from an array 19 | void loadData(const size_t n_elems, const GLuint* const data, const GLuint offset); 20 | // Draws indexed vertex array 21 | void draw(const GLVertArray& va) const; 22 | private: 23 | GLuint m_handle; // OpenGL handle 24 | GLuint m_min_idx, m_max_idx; // Minimal and maximal indices 25 | bool m_is_buffered; // Flag indicating whether data is buffered on GPU 26 | std::vector m_data_vec; // Storage 27 | }; 28 | -------------------------------------------------------------------------------- /Source/GL/GLPersistentBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "..\Common\Definitions.h" 5 | 6 | /* Implements persistent OpenGL buffer with EXPLICIT layout, e.g. 7 | (std140) uniform buffers or (std430) shader storage buffers */ 8 | template 9 | class GLPersistentBuffer { 10 | public: 11 | GLPersistentBuffer() = delete; 12 | RULE_OF_FIVE(GLPersistentBuffer); 13 | // Creates a persistent buffer of specified size 14 | explicit GLPersistentBuffer(const size_t byte_sz); 15 | // Returns the pointer to the beginning of the buffer 16 | void* data(); 17 | // Returns the pointer to the beginning of the buffer (read-only) 18 | const void* data() const; 19 | // Binds buffer to buffer binding point 20 | void bind(const GLuint bind_idx) const; 21 | private: 22 | // Performs buffer initialization 23 | void init(); 24 | // Performs buffer destruction 25 | void destroy(); 26 | // Private data members 27 | void* m_buffer; // Pointer used to write to the buffer 28 | size_t m_byte_sz; // Buffer size in bytes 29 | GLuint m_handle; // OpenGL handle 30 | }; 31 | 32 | using GLPUB140 = GLPersistentBuffer; 33 | using GLPSB430 = GLPersistentBuffer; 34 | -------------------------------------------------------------------------------- /Source/GL/GLRTBLockMngr.cpp: -------------------------------------------------------------------------------- 1 | #include "GLRTBLockMngr.h" 2 | #include 3 | #include 4 | 5 | GLRTBLockMngr::GLRingTripleBufferLockManager(): m_buf_idx{0}, m_fences{} {} 6 | 7 | GLRTBLockMngr::GLRingTripleBufferLockManager(GLRTBLockMngr&& rtb_lock_mngr): 8 | m_buf_idx{rtb_lock_mngr.m_buf_idx}, m_fences(std::move(rtb_lock_mngr.m_fences)) { 9 | // Mark as moved 10 | rtb_lock_mngr.m_buf_idx = -1; 11 | } 12 | 13 | GLRTBLockMngr& GLRTBLockMngr::operator=(GLRTBLockMngr&& rtb_lock_mngr) { 14 | assert(this != &rtb_lock_mngr); 15 | // Remove the old fences if needed 16 | for (int i = 0; i < 3; ++i) { 17 | gl::DeleteSync(m_fences[i]); 18 | } 19 | // Now copy the data 20 | memcpy(this, &rtb_lock_mngr, sizeof(*this)); 21 | // Mark as moved 22 | rtb_lock_mngr.m_buf_idx = -1; 23 | return *this; 24 | } 25 | 26 | GLRTBLockMngr::~GLRingTripleBufferLockManager() { 27 | // Check if it was moved 28 | if (m_buf_idx >= 0) { 29 | for (int i = 0; i < 3; ++i) { 30 | gl::DeleteSync(m_fences[i]); 31 | } 32 | } 33 | } 34 | 35 | void GLRTBLockMngr::lockBuffer() { 36 | auto& curr_fence = m_fences[m_buf_idx]; 37 | if (curr_fence) { 38 | // Release memory 39 | gl::DeleteSync(curr_fence); 40 | } 41 | // Insert a new fence 42 | curr_fence = gl::FenceSync(gl::SYNC_GPU_COMMANDS_COMPLETE, 0); 43 | // Prepare the next fence 44 | m_buf_idx = (m_buf_idx + 1) % 3; 45 | } 46 | 47 | void GLRTBLockMngr::waitForLockExpiration() { 48 | const auto& curr_fence = m_fences[m_buf_idx]; 49 | if (curr_fence) { 50 | GLbitfield wait_flags = 0; 51 | GLuint64 wait_nanosec = 0; 52 | GLenum wait_status; 53 | do { 54 | wait_status = gl::ClientWaitSync(curr_fence, wait_flags, wait_nanosec); 55 | // If wait_status is no good, we have to flush the command buffer 56 | wait_flags = gl::SYNC_FLUSH_COMMANDS_BIT; 57 | wait_nanosec = 1000; 58 | } while (wait_status != gl::ALREADY_SIGNALED && 59 | wait_status != gl::CONDITION_SATISFIED); 60 | } 61 | } 62 | 63 | int GLRTBLockMngr::getActiveBufIdx() const { 64 | return m_buf_idx; 65 | } 66 | -------------------------------------------------------------------------------- /Source/GL/GLRTBLockMngr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "..\Common\Definitions.h" 6 | 7 | /* Implements synchronization for ring-triple-buffers */ 8 | class GLRingTripleBufferLockManager { 9 | public: 10 | GLRingTripleBufferLockManager(); 11 | RULE_OF_FIVE_NO_COPY(GLRingTripleBufferLockManager); 12 | // Prevents writing to buffer (1/3) until GPU commands pipeleine finishes execution 13 | void lockBuffer(); 14 | // Waits for fence removal (write access) 15 | void waitForLockExpiration(); 16 | // Returns the active ring buffer index: [0..2] 17 | int getActiveBufIdx() const; 18 | private: 19 | std::array m_fences; // Synchronization for ring-triple-buffer 20 | int m_buf_idx; // Active ring buffer index: [0..2] 21 | }; 22 | 23 | using GLRTBLockMngr = GLRingTripleBufferLockManager; 24 | -------------------------------------------------------------------------------- /Source/GL/GLShader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "..\Common\Definitions.h" 7 | 8 | /* Class representing GLSL program */ 9 | class GLSLProgram { 10 | public: 11 | GLSLProgram(); 12 | RULE_OF_FIVE(GLSLProgram); 13 | // Loads shader from disk 14 | void loadShader(const char* const file_name); 15 | // Links GLSL program 16 | void link(); 17 | // Activates GSLS program 18 | void use() const; 19 | // Returns program's OpenGL handle 20 | GLuint id() const; 21 | // Returns true if program status is OK 22 | bool isValid() const; 23 | // Returns location assigned to a uniform variable 24 | GLint getUniformLocation(const char* const name) const; 25 | // Sets named uniform variable to specified value 26 | template 27 | void setUniformValue(const char* const name, const T& v) const; 28 | // Sets uniform variable to specified value using its location 29 | static void setUniformValue(const GLint loc, const GLboolean& v); 30 | static void setUniformValue(const GLint loc, const GLint& v); 31 | static void setUniformValue(const GLint loc, const GLuint& v); 32 | static void setUniformValue(const GLint loc, const GLfloat& v); 33 | static void setUniformValue(const GLint loc, const glm::vec3& v); 34 | static void setUniformValue(const GLint loc, const glm::vec4& v); 35 | static void setUniformValue(const GLint loc, const glm::mat3& m); 36 | static void setUniformValue(const GLint loc, const glm::mat4& m); 37 | private: 38 | /* Class representing GLSL shader */ 39 | class GLSLShader { 40 | public: 41 | GLSLShader() = delete; 42 | RULE_OF_FIVE(GLSLShader); 43 | // Creates a shader from a file on disk 44 | explicit GLSLShader(const char* const file_name); 45 | // Returns shader's OpenGL handle 46 | GLuint id() const; 47 | // Returns true if shader status is OK 48 | bool isValid() const; 49 | private: 50 | // Reads shader from file on disk; also returns length of shader code 51 | const char* loadShaderFromFile(const char* const file_name, GLint& code_len); 52 | // Performs shader compilation 53 | void compile(); 54 | // Private data members 55 | GLuint m_handle; // OpenGL handle 56 | bool m_is_ok; // Status 57 | }; 58 | // Attaches (valid) shader to the shader program 59 | void attachShader(const GLSLShader& sh); 60 | // Private data members 61 | GLuint m_handle; // OpenGL handle 62 | bool m_is_ok; // Status 63 | bool m_is_linked; // Program linking status 64 | std::vector m_shaders; // Attached shaders 65 | }; 66 | -------------------------------------------------------------------------------- /Source/GL/GLShader.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GLShader.h" 4 | 5 | template 6 | void GLSLProgram::setUniformValue(const char* const name, const T& v) const { 7 | const GLint loc{getUniformLocation(name)}; 8 | setUniformValue(loc, v); 9 | } 10 | -------------------------------------------------------------------------------- /Source/GL/GLTexture2D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "..\Common\Definitions.h" 4 | 5 | /* Implements 2D OpenGL texture of the specified Sized Internal Format */ 6 | template 7 | class GLTexture2D { 8 | public: 9 | GLTexture2D() = delete; 10 | RULE_OF_FIVE_NO_COPY(GLTexture2D); 11 | // Creates a texture of specified width and height bound to the specified tex. unit 12 | // Can use MIP-maps and linear texture filering if desired 13 | explicit GLTexture2D(const GLenum tex_unit, const GLsizei width, const GLsizei height, 14 | const bool use_mipmaps, const bool use_lin_filter); 15 | // Returns texture's OpenGL handle 16 | GLuint id() const; 17 | private: 18 | GLuint m_handle; // OpenGL handle 19 | }; 20 | 21 | using GLTex2D_3x8 = GLTexture2D; 22 | using GLTex2D_1x8UI = GLTexture2D; 23 | using GLTex2D_1x32F = GLTexture2D; 24 | using GLTex2D_2x32F = GLTexture2D; 25 | using GLTex2D_3x32F = GLTexture2D; 26 | using GLTex2D_4x32F = GLTexture2D; 27 | using GLTex2D_Depth = GLTexture2D; 28 | -------------------------------------------------------------------------------- /Source/GL/GLTexture2D.hpp: -------------------------------------------------------------------------------- 1 | #include "GLTexture2D.h" 2 | #include 3 | 4 | // Computes the number of MIP-map levels given the texture dimensions 5 | static inline GLsizei computeMipLvlCnt(const GLsizei width, const GLsizei height) { 6 | return static_cast(floor(log2(glm::max(width, height))) + 1); 7 | } 8 | 9 | template 10 | GLTexture2D::GLTexture2D(const GLenum tex_unit, const GLsizei width, const GLsizei height, 11 | const bool use_mipmaps, const bool use_lin_filter) { 12 | // Aquire a texture handle 13 | gl::ActiveTexture(gl::TEXTURE0 + tex_unit); 14 | gl::GenTextures(1, &m_handle); 15 | gl::BindTexture(gl::TEXTURE_2D, m_handle); 16 | // Compute the number of MIP-map levels 17 | const GLsizei levels{use_mipmaps ? computeMipLvlCnt(width, height) : 1}; 18 | // Allocate storage 19 | gl::TexStorage2D(gl::TEXTURE_2D, levels, SIF, width, height); 20 | // Set texture filering 21 | const GLint mag_filter{use_lin_filter ? gl::LINEAR : gl::NEAREST}; 22 | gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MAG_FILTER, mag_filter); 23 | const GLint min_filter{[=](){ 24 | if (use_mipmaps) { 25 | return use_lin_filter ? gl::LINEAR_MIPMAP_LINEAR : gl::NEAREST_MIPMAP_NEAREST; 26 | } else { 27 | return use_lin_filter ? gl::LINEAR : gl::NEAREST; 28 | } 29 | }()}; 30 | gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_MIN_FILTER, min_filter); 31 | // Use border-clamping for both dimensions 32 | gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_WRAP_S, gl::CLAMP_TO_BORDER); 33 | gl::TexParameteri(gl::TEXTURE_2D, gl::TEXTURE_WRAP_T, gl::CLAMP_TO_BORDER); 34 | } 35 | 36 | template 37 | GLTexture2D::GLTexture2D(GLTexture2D&& tex): m_handle{tex.m_handle} { 38 | // Mark as moved 39 | tex.m_handle = 0; 40 | } 41 | 42 | template 43 | GLTexture2D& GLTexture2D::operator=(GLTexture2D&& tex) { 44 | assert(this != &tex); 45 | // Delete the old texture 46 | gl::DeleteTextures(1, &m_handle); 47 | // Now copy the data 48 | memcpy(this, &tex, sizeof(*this)); 49 | // Mark as moved 50 | tex.m_handle = 0; 51 | return *this; 52 | } 53 | 54 | template 55 | GLTexture2D::~GLTexture2D() { 56 | // Check if it was moved 57 | if (m_handle) { 58 | gl::DeleteTextures(1, &m_handle); 59 | } 60 | } 61 | 62 | template 63 | GLuint GLTexture2D::id() const { 64 | return m_handle; 65 | } 66 | -------------------------------------------------------------------------------- /Source/GL/GLTextureBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "GLTextureBuffer.h" 2 | #include 3 | #include 4 | 5 | GLTextureBuffer::GLTextureBuffer(const GLsizeiptr byte_sz, const GLenum tex_unit, 6 | const GLenum tex_intern_fmt): m_byte_sz{byte_sz}{ 7 | // Generate buffer 8 | gl::GenBuffers(1, &m_handle); 9 | gl::BindBuffer(gl::TEXTURE_BUFFER, m_handle); 10 | gl::BufferData(gl::TEXTURE_BUFFER, m_byte_sz, nullptr, gl::STATIC_DRAW); 11 | // Create texture 12 | gl::ActiveTexture(gl::TEXTURE0 + tex_unit); 13 | gl::GenTextures(1, &m_tex_handle); 14 | gl::BindTexture(gl::TEXTURE_BUFFER, m_tex_handle); 15 | // Link the two together 16 | gl::TexBuffer(gl::TEXTURE_BUFFER, tex_intern_fmt, m_handle); 17 | } 18 | 19 | GLTextureBuffer::GLTextureBuffer(GLTextureBuffer&& tbo): m_handle{tbo.m_handle}, 20 | m_tex_handle{tbo.m_tex_handle} { 21 | // Mark as moved 22 | tbo.m_handle = 0; 23 | } 24 | 25 | GLTextureBuffer& GLTextureBuffer::operator=(GLTextureBuffer&& tbo) { 26 | // Destroy the old buffer 27 | gl::DeleteTextures(1, &m_tex_handle); 28 | gl::DeleteBuffers(1, &m_handle); 29 | // Now copy the data 30 | memcpy(this, &tbo, sizeof(*this)); 31 | // Mark as moved 32 | tbo.m_handle = 0; 33 | return *this; 34 | } 35 | 36 | GLTextureBuffer::~GLTextureBuffer() { 37 | // Check if it was moved 38 | if (m_handle) { 39 | gl::DeleteTextures(1, &m_tex_handle); 40 | gl::DeleteBuffers(1, &m_handle); 41 | } 42 | } 43 | 44 | void GLTextureBuffer::bufferData(const GLsizeiptr byte_sz, const void* const data) { 45 | assert(byte_sz <= m_byte_sz); 46 | gl::BindBuffer(gl::TEXTURE_BUFFER, m_handle); 47 | gl::BufferSubData(gl::TEXTURE_BUFFER, 0, byte_sz, data); 48 | } 49 | -------------------------------------------------------------------------------- /Source/GL/GLTextureBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "..\Common\Definitions.h" 5 | 6 | /* Implements OpenGL texture buffers */ 7 | class GLTextureBuffer { 8 | public: 9 | GLTextureBuffer() = delete; 10 | RULE_OF_FIVE_NO_COPY(GLTextureBuffer); 11 | // Creates a texture buffer of the specified size and the specified internal format 12 | explicit GLTextureBuffer(const GLsizeiptr byte_sz, const GLenum tex_unit, 13 | const GLenum tex_intern_fmt); 14 | // Copies the data of the specified size to the GPU 15 | void bufferData(const GLsizeiptr byte_sz, const void* const data); 16 | private: 17 | GLuint m_handle; // OpenGL buffer handle 18 | GLuint m_tex_handle; // OpenGL texture handle 19 | GLsizeiptr m_byte_sz; // Buffer size in bytes 20 | }; 21 | -------------------------------------------------------------------------------- /Source/GL/GLUniformBuffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "..\Common\Definitions.h" 5 | 6 | /* Implements OpenGL uniform buffers of non-std layout */ 7 | class GLUniformBuffer { 8 | public: 9 | GLUniformBuffer() = delete; 10 | RULE_OF_FIVE(GLUniformBuffer); 11 | // Constructs an UBO for a (named) block with specified storage members 12 | explicit GLUniformBuffer(const char* const block_name, const GLuint n_members, 13 | const char** const member_names, const GLuint prog_handle); 14 | // Computes stride (step size in bytes) of array of structs 15 | GLint calcStructStride(const GLint init_struct_cnt) const; 16 | // Loads single struct into array of structs 17 | void loadStructToArray(const GLint index, const GLint stride, const GLuint* const elem_byte_sz, 18 | const void* const data); 19 | // Make a local copy of data, and then copy it to GPU 20 | // Requires size in bytes specified for each element (member) 21 | void buffer(const GLuint* const elem_byte_sz, const void* const data); 22 | // Makes a local copy of data, and then copies it to GPU 23 | // Copies the whole block of data, ignoring offsets. Useful for std140 layout 24 | void buffer(const GLuint data_byte_sz, const void* const data); 25 | // Copies preloaded data to GPU 26 | void buffer(); 27 | // Binds uniform buffer object to to uniform buffer binding point 28 | void bind(const GLuint bind_idx) const; 29 | private: 30 | // Performs buffer destruction 31 | void destroy(); 32 | // Private data members 33 | GLuint m_handle; // OpenGL handle 34 | GLuint m_n_members; // Number of buffer data members 35 | GLuint m_block_sz; // Uniform block size in bytes 36 | GLubyte* m_block_buffer; // Block buffer contents 37 | GLint* m_offsets; // Offset to each data member in bytes 38 | bool m_is_buffered; // Flag indicating whether data is buffered on GPU 39 | }; 40 | -------------------------------------------------------------------------------- /Source/GL/GLUniformManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class GLSLProgram; 7 | 8 | /* OpenGL uniform manager class for N uniforms */ 9 | template 10 | class GLUniformManager { 11 | public: 12 | GLUniformManager() = default; 13 | RULE_OF_ZERO(GLUniformManager); 14 | // Constructor, takes an GLSL program's reference and a list of uniform names as arguments 15 | GLUniformManager(const GLSLProgram& sp, std::initializer_list names); 16 | // Initializes the list of the uniforms to be managed 17 | void setManagedUniforms(const GLSLProgram& sp, std::initializer_list names); 18 | // Sets uniform values; use THE SAME order as during initialization! 19 | template 20 | void setUniformValues(const Args&... vals) const; 21 | private: 22 | // Recursively sets uniform values using m_uni_locs[I] 23 | template 24 | void setUniforms(const T& first, const Args&... vals) const; 25 | // Sets the last uniform value using m_uni_locs[N - 1] 26 | template 27 | void setUniforms(const T& last) const; 28 | // Private data members 29 | std::array m_uni_locs; // Uniform locations 30 | }; 31 | -------------------------------------------------------------------------------- /Source/GL/GLUniformManager.hpp: -------------------------------------------------------------------------------- 1 | #include "GLUniformManager.h" 2 | #include "GLShader.h" 3 | 4 | template 5 | GLUniformManager::GLUniformManager(const GLSLProgram& sp, 6 | std::initializer_list names) { 7 | setManagedUniforms(sp, names); 8 | } 9 | 10 | template 11 | void GLUniformManager::setManagedUniforms(const GLSLProgram& sp, 12 | std::initializer_list names) { 13 | #if __cplusplus <= 201103L 14 | // No constexpr support 15 | assert(names.size() == N); 16 | #else 17 | static_assert(names.size() == N, "Mismatch between the number of uniforms N and " 18 | "the number of function arguments."); 19 | #endif 20 | // Query for locations 21 | int i = 0; 22 | for (const auto name : names) { 23 | m_uni_locs[i++] = sp.getUniformLocation(name); 24 | } 25 | } 26 | 27 | template 28 | template 29 | void GLUniformManager::setUniformValues(const Args&... vals) const { 30 | setUniforms<0>(vals...); 31 | } 32 | 33 | template 34 | template 35 | void GLUniformManager::setUniforms(const T& first, const Args&... vals) const { 36 | static_assert(I <= N - 1, "Invalid number of function arguments."); 37 | GLSLProgram::setUniformValue(m_uni_locs[I], first); 38 | setUniforms(vals...); 39 | } 40 | 41 | template 42 | template 43 | void GLUniformManager::setUniforms(const T& last) const { 44 | static_assert(I == N - 1, "Invalid number of function arguments."); 45 | GLSLProgram::setUniformValue(m_uni_locs[I], last); 46 | } 47 | -------------------------------------------------------------------------------- /Source/GL/GLVertArray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "..\Common\Definitions.h" 6 | 7 | class GLElementBuffer; 8 | 9 | /* Class representing OpenGL vertex array */ 10 | class GLVertArray { 11 | public: 12 | GLVertArray() = delete; 13 | RULE_OF_FIVE(GLVertArray); 14 | // Constructs a vertex array with specified attributes 15 | explicit GLVertArray(const GLsizei n_attr, const GLsizei* const component_counts); 16 | // Returns vertex array's OpenGL handle 17 | GLuint id() const; 18 | // Loads data for specified attribute from std::vector 19 | void loadData(const GLuint attr_id, const std::vector& data_vec); 20 | // Loads data for specified attribute from an array 21 | void loadData(const GLuint attr_id, const size_t n_elems, const GLfloat* const data); 22 | // Copies preloaded data to GPU 23 | void buffer(); 24 | // Draws vertex array in specified a mode (such as gl::TRIANGLES) 25 | void draw(const GLenum mode) const; 26 | private: 27 | /* Vertex Buffer Object */ 28 | struct VertBuffer { 29 | VertBuffer() = default; 30 | RULE_OF_ZERO(VertBuffer); 31 | GLuint handle; // OpenGL handle 32 | GLsizei n_components; // Number of FP components per element 33 | std::vector data_vec; // Storage 34 | }; 35 | // Performs array destruction 36 | void destroy(); 37 | // Private data members 38 | GLuint m_handle; // OpenGL handle 39 | GLsizei m_n_vbos; // Number of Vertex Buffer Objects (VBOs) 40 | VertBuffer* m_vbos; // Array of Vertex Buffer Objects (VBOs) 41 | bool m_is_buffered; // Flag indicating whether data is buffered on GPU 42 | }; 43 | -------------------------------------------------------------------------------- /Source/Include/GLFW/COPYING.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2002-2006 Marcus Geelnard 2 | Copyright (c) 2006-2010 Camilla Berglund 3 | 4 | This software is provided 'as-is', without any express or implied 5 | warranty. In no event will the authors be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this software must not be misrepresented; you must not 13 | claim that you wrote the original software. If you use this software 14 | in a product, an acknowledgment in the product documentation would 15 | be appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and must not 18 | be misrepresented as being the original software. 19 | 20 | 3. This notice may not be removed or altered from any source 21 | distribution. 22 | 23 | -------------------------------------------------------------------------------- /Source/Include/GLM/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(NAME glm_dummy) 2 | 3 | file(GLOB ROOT_SOURCE *.cpp) 4 | file(GLOB ROOT_INLINE *.inl) 5 | file(GLOB ROOT_HEADER *.hpp) 6 | file(GLOB ROOT_TEXT ../*.txt) 7 | 8 | file(GLOB_RECURSE CORE_SOURCE ./detail/*.cpp) 9 | file(GLOB_RECURSE CORE_INLINE ./detail/*.inl) 10 | file(GLOB_RECURSE CORE_HEADER ./detail/*.hpp) 11 | 12 | file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp) 13 | file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl) 14 | file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp) 15 | 16 | file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp) 17 | file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl) 18 | file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp) 19 | 20 | source_group("Text Files" FILES ${ROOT_TEXT}) 21 | source_group("Core Files" FILES ${CORE_SOURCE}) 22 | source_group("Core Files" FILES ${CORE_INLINE}) 23 | source_group("Core Files" FILES ${CORE_HEADER}) 24 | source_group("GTC Files" FILES ${GTC_SOURCE}) 25 | source_group("GTC Files" FILES ${GTC_INLINE}) 26 | source_group("GTC Files" FILES ${GTC_HEADER}) 27 | source_group("GTX Files" FILES ${GTX_SOURCE}) 28 | source_group("GTX Files" FILES ${GTX_INLINE}) 29 | source_group("GTX Files" FILES ${GTX_HEADER}) 30 | 31 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) 32 | 33 | if(GLM_TEST_ENABLE) 34 | add_executable(${NAME} ${ROOT_TEXT} 35 | ${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER} 36 | ${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER} 37 | ${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER} 38 | ${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}) 39 | endif(GLM_TEST_ENABLE) 40 | 41 | #add_library(glm STATIC glm.cpp) 42 | #add_library(glm_shared SHARED glm.cpp) 43 | -------------------------------------------------------------------------------- /Source/Include/GLM/common.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/common.hpp 25 | /// @date 2013-12-24 / 2013-12-24 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_COMMON_INCLUDED 30 | #define GLM_COMMON_INCLUDED 31 | 32 | #include "detail/func_common.hpp" 33 | 34 | #endif//GLM_COMMON_INCLUDED 35 | -------------------------------------------------------------------------------- /Source/Include/GLM/copying.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2005 - 2013 G-Truc Creation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/_fixes.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/_fixes.hpp 25 | /// @date 2011-02-21 / 2011-11-22 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #include 30 | 31 | //! Workaround for compatibility with other libraries 32 | #ifdef max 33 | #undef max 34 | #endif 35 | 36 | //! Workaround for compatibility with other libraries 37 | #ifdef min 38 | #undef min 39 | #endif 40 | 41 | //! Workaround for Android 42 | #ifdef isnan 43 | #undef isnan 44 | #endif 45 | 46 | //! Workaround for Android 47 | #ifdef isinf 48 | #undef isinf 49 | #endif 50 | 51 | //! Workaround for Chrone Native Client 52 | #ifdef log2 53 | #undef log2 54 | #endif 55 | 56 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/_literals.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/_literals.hpp 25 | /// @date 2013-05-06 / 2013-05-06 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_core_literals 30 | #define glm_core_literals 31 | 32 | namespace glm 33 | { 34 | #define GLM_CXX11_USER_LITERALS 35 | #ifdef GLM_CXX11_USER_LITERALS 36 | /* 37 | GLM_FUNC_QUALIFIER detail::half operator "" _h(long double const s) 38 | { 39 | return detail::half(s); 40 | } 41 | 42 | GLM_FUNC_QUALIFIER float operator "" _f(long double const s) 43 | { 44 | return static_cast(s); 45 | } 46 | */ 47 | #endif//GLM_CXX11_USER_LITERALS 48 | 49 | }//namespace glm 50 | 51 | #endif//glm_core_literals 52 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/hint.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/hint.hpp 25 | /// @date 2008-08-14 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_core_type 30 | #define glm_core_type 31 | 32 | namespace glm 33 | { 34 | // Use dont_care, nicest and fastest to optimize implementations. 35 | class dont_care {}; 36 | class nicest {}; 37 | class fastest {}; 38 | }//namespace glm 39 | 40 | #endif//glm_core_type 41 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/intrinsic_exponential.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_exponential.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/intrinsic_geometric.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_geometric.hpp 25 | /// @date 2009-05-08 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_core_intrinsic_geometric 30 | #define glm_core_intrinsic_geometric 31 | 32 | #include "setup.hpp" 33 | 34 | #if(!(GLM_ARCH & GLM_ARCH_SSE2)) 35 | # error "SSE2 instructions not supported or enabled" 36 | #else 37 | 38 | #include "intrinsic_common.hpp" 39 | 40 | namespace glm{ 41 | namespace detail 42 | { 43 | //length 44 | __m128 sse_len_ps(__m128 x); 45 | 46 | //distance 47 | __m128 sse_dst_ps(__m128 p0, __m128 p1); 48 | 49 | //dot 50 | __m128 sse_dot_ps(__m128 v1, __m128 v2); 51 | 52 | // SSE1 53 | __m128 sse_dot_ss(__m128 v1, __m128 v2); 54 | 55 | //cross 56 | __m128 sse_xpd_ps(__m128 v1, __m128 v2); 57 | 58 | //normalize 59 | __m128 sse_nrm_ps(__m128 v); 60 | 61 | //faceforward 62 | __m128 sse_ffd_ps(__m128 N, __m128 I, __m128 Nref); 63 | 64 | //reflect 65 | __m128 sse_rfe_ps(__m128 I, __m128 N); 66 | 67 | //refract 68 | __m128 sse_rfa_ps(__m128 I, __m128 N, __m128 eta); 69 | 70 | }//namespace detail 71 | }//namespace glm 72 | 73 | #include "intrinsic_geometric.inl" 74 | 75 | #endif//GLM_ARCH 76 | #endif//glm_core_intrinsic_geometric 77 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/intrinsic_integer.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_integer.hpp 25 | /// @date 2009-05-11 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_detail_intrinsic_integer 30 | #define glm_detail_intrinsic_integer 31 | 32 | #include "glm/glm.hpp" 33 | 34 | #if(!(GLM_ARCH & GLM_ARCH_SSE2)) 35 | # error "SSE2 instructions not supported or enabled" 36 | #else 37 | 38 | namespace glm{ 39 | namespace detail 40 | { 41 | __m128i _mm_bit_interleave_si128(__m128i x); 42 | __m128i _mm_bit_interleave_si128(__m128i x, __m128i y); 43 | 44 | }//namespace detail 45 | }//namespace glm 46 | 47 | #include "intrinsic_integer.inl" 48 | 49 | #endif//GLM_ARCH 50 | #endif//glm_detail_intrinsic_integer 51 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/intrinsic_matrix.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_common.hpp 25 | /// @date 2009-06-05 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_detail_intrinsic_matrix 30 | #define glm_detail_intrinsic_matrix 31 | 32 | #include "setup.hpp" 33 | 34 | #if(!(GLM_ARCH & GLM_ARCH_SSE2)) 35 | # error "SSE2 instructions not supported or enabled" 36 | #else 37 | 38 | #include "intrinsic_geometric.hpp" 39 | 40 | namespace glm{ 41 | namespace detail 42 | { 43 | void sse_add_ps(__m128 in1[4], __m128 in2[4], __m128 out[4]); 44 | 45 | void sse_sub_ps(__m128 in1[4], __m128 in2[4], __m128 out[4]); 46 | 47 | __m128 sse_mul_ps(__m128 m[4], __m128 v); 48 | 49 | __m128 sse_mul_ps(__m128 v, __m128 m[4]); 50 | 51 | void sse_mul_ps(__m128 const in1[4], __m128 const in2[4], __m128 out[4]); 52 | 53 | void sse_transpose_ps(__m128 const in[4], __m128 out[4]); 54 | 55 | void sse_inverse_ps(__m128 const in[4], __m128 out[4]); 56 | 57 | void sse_rotate_ps(__m128 const in[4], float Angle, float const v[3], __m128 out[4]); 58 | 59 | __m128 sse_det_ps(__m128 const m[4]); 60 | 61 | __m128 sse_slow_det_ps(__m128 const m[4]); 62 | 63 | }//namespace detail 64 | }//namespace glm 65 | 66 | #include "intrinsic_matrix.inl" 67 | 68 | #endif//GLM_ARCH 69 | #endif//glm_detail_intrinsic_matrix 70 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/intrinsic_trigonometric.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_trigonometric.hpp 25 | /// @date 2009-06-09 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_detail_intrinsic_trigonometric 30 | #define glm_detail_intrinsic_trigonometric 31 | 32 | #include "setup.hpp" 33 | 34 | #if(!(GLM_ARCH & GLM_ARCH_SSE2)) 35 | # error "SSE2 instructions not supported or enabled" 36 | #else 37 | 38 | namespace glm{ 39 | namespace detail 40 | { 41 | 42 | }//namespace detail 43 | }//namespace glm 44 | 45 | #include "intrinsic_trigonometric.inl" 46 | 47 | #endif//GLM_ARCH 48 | #endif//glm_detail_intrinsic_trigonometric 49 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/intrinsic_trigonometric.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_trigonometric.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/intrinsic_vector_relational.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/intrinsic_vector_relational.hpp 25 | /// @date 2009-06-09 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_detail_intrinsic_vector_relational 30 | #define glm_detail_intrinsic_vector_relational 31 | 32 | #include "setup.hpp" 33 | 34 | #if(!(GLM_ARCH & GLM_ARCH_SSE2)) 35 | # error "SSE2 instructions not supported or enabled" 36 | #else 37 | 38 | namespace glm{ 39 | namespace detail 40 | { 41 | 42 | }//namespace detail 43 | }//namespace glm 44 | 45 | #include "intrinsic_vector_relational.inl" 46 | 47 | #endif//GLM_ARCH 48 | #endif//glm_detail_intrinsic_vector_relational 49 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/precision.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/precision.hpp 25 | /// @date 2013-04-01 / 2013-04-01 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_CORE_PRECISION_INCLUDED 30 | #define GLM_CORE_PRECISION_INCLUDED 31 | 32 | namespace glm 33 | { 34 | enum precision 35 | { 36 | highp, 37 | mediump, 38 | lowp, 39 | defaultp = highp 40 | }; 41 | }//namespace glm 42 | 43 | #endif//GLM_CORE_PRECISION_INCLUDED 44 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/precision.inl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zero-radiance/GIGL/1917c51c883bbe0bbd457abcf95aecf89ab05010/Source/Include/GLM/detail/precision.inl -------------------------------------------------------------------------------- /Source/Include/GLM/detail/type_half.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/type_half.hpp 25 | /// @date 2008-08-17 / 2011-09-20 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef glm_core_type_half 30 | #define glm_core_type_half 31 | 32 | #include "setup.hpp" 33 | 34 | namespace glm{ 35 | namespace detail 36 | { 37 | typedef short hdata; 38 | 39 | GLM_FUNC_DECL float toFloat32(hdata value); 40 | GLM_FUNC_DECL hdata toFloat16(float const & value); 41 | 42 | }//namespace detail 43 | 44 | /// half-precision floating-point numbers. 45 | //typedef detail::hdata half; 46 | 47 | }//namespace glm 48 | 49 | #include "type_half.inl" 50 | 51 | #endif//glm_core_type_half 52 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/type_mat.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/type_mat.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /Source/Include/GLM/detail/type_vec.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/core/type_vec.inl 25 | /// @date 2011-06-15 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /Source/Include/GLM/exponential.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/exponential.hpp 25 | /// @date 2013-12-24 / 2013-12-24 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_EXPONENTIAL_INCLUDED 30 | #define GLM_EXPONENTIAL_INCLUDED 31 | 32 | #include "detail/func_exponential.hpp" 33 | 34 | #endif//GLM_EXPONENTIAL_INCLUDED 35 | -------------------------------------------------------------------------------- /Source/Include/GLM/geometric.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/geometric.hpp 25 | /// @date 2013-12-24 / 2013-12-24 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_GEOMETRIC_INCLUDED 30 | #define GLM_GEOMETRIC_INCLUDED 31 | 32 | #include "detail/func_geometric.hpp" 33 | 34 | #endif//GLM_GEOMETRIC_INCLUDED 35 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtc/type_precision.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtc_swizzle 24 | /// @file glm/gtc/swizzle.inl 25 | /// @date 2009-06-14 / 2011-06-15 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | namespace glm 30 | { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/closest_point.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_bit 24 | /// @file glm/gtx/bit.hpp 25 | /// @date 2005-12-30 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_closest_point GLM_GTX_closest_point 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Find the point on a straight line which is the closet of a point. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_closest_point 39 | #define GLM_GTX_closest_point 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 45 | # pragma message("GLM: GLM_GTX_closest_point extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_closest_point 51 | /// @{ 52 | 53 | /// Find the point on a straight line which is the closet of a point. 54 | /// @see gtx_closest_point 55 | template 56 | GLM_FUNC_DECL detail::tvec3 closestPointOnLine( 57 | detail::tvec3 const & point, 58 | detail::tvec3 const & a, 59 | detail::tvec3 const & b); 60 | 61 | /// @} 62 | }// namespace glm 63 | 64 | #include "closest_point.inl" 65 | 66 | #endif//GLM_GTX_closest_point 67 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/closest_point.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-30 5 | // Updated : 2008-10-05 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/closest_point.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | #ifndef glm_gtx_closest_point 11 | #define glm_gtx_closest_point 12 | 13 | namespace glm 14 | { 15 | template 16 | GLM_FUNC_QUALIFIER detail::tvec3 closestPointOnLine 17 | ( 18 | detail::tvec3 const & point, 19 | detail::tvec3 const & a, 20 | detail::tvec3 const & b 21 | ) 22 | { 23 | T LineLength = distance(a, b); 24 | detail::tvec3 Vector = point - a; 25 | detail::tvec3 LineDirection = (b - a) / LineLength; 26 | 27 | // Project Vector to LineDirection to get the distance of point from a 28 | T Distance = dot(Vector, LineDirection); 29 | 30 | if(Distance <= T(0)) return a; 31 | if(Distance >= LineLength) return b; 32 | return a + LineDirection * Distance; 33 | } 34 | }//namespace glm 35 | 36 | #endif//glm_gtx_closest_point 37 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/color_space_YCoCg.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2008-10-28 5 | // Updated : 2008-10-28 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/color_space_YCoCg.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tvec3 rgb2YCoCg 14 | ( 15 | detail::tvec3 const & rgbColor 16 | ) 17 | { 18 | detail::tvec3 result; 19 | result.x/*Y */ = rgbColor.r / T(4) + rgbColor.g / T(2) + rgbColor.b / T(4); 20 | result.y/*Co*/ = rgbColor.r / T(2) + rgbColor.g * T(0) - rgbColor.b / T(2); 21 | result.z/*Cg*/ = - rgbColor.r / T(4) + rgbColor.g / T(2) - rgbColor.b / T(4); 22 | return result; 23 | } 24 | 25 | template 26 | GLM_FUNC_QUALIFIER detail::tvec3 rgb2YCoCgR 27 | ( 28 | detail::tvec3 const & rgbColor 29 | ) 30 | { 31 | detail::tvec3 result; 32 | result.x/*Y */ = rgbColor.g / T(2) + (rgbColor.r + rgbColor.b) / T(4); 33 | result.y/*Co*/ = rgbColor.r - rgbColor.b; 34 | result.z/*Cg*/ = rgbColor.g - (rgbColor.r + rgbColor.b) / T(2); 35 | return result; 36 | } 37 | 38 | template 39 | GLM_FUNC_QUALIFIER detail::tvec3 YCoCg2rgb 40 | ( 41 | detail::tvec3 const & YCoCgColor 42 | ) 43 | { 44 | detail::tvec3 result; 45 | result.r = YCoCgColor.x + YCoCgColor.y - YCoCgColor.z; 46 | result.g = YCoCgColor.x + YCoCgColor.z; 47 | result.b = YCoCgColor.x - YCoCgColor.y - YCoCgColor.z; 48 | return result; 49 | } 50 | 51 | template 52 | GLM_FUNC_QUALIFIER detail::tvec3 YCoCgR2rgb 53 | ( 54 | detail::tvec3 const & YCoCgRColor 55 | ) 56 | { 57 | detail::tvec3 result; 58 | T tmp = YCoCgRColor.x - (YCoCgRColor.z / T(2)); 59 | result.g = YCoCgRColor.z + tmp; 60 | result.b = tmp - (YCoCgRColor.y / T(2)); 61 | result.r = result.b + YCoCgRColor.y; 62 | return result; 63 | } 64 | }//namespace glm 65 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/compatibility.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-03-16 5 | // Updated : 2008-10-24 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/compatibility.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | // isfinite 13 | template 14 | GLM_FUNC_QUALIFIER bool isfinite( 15 | genType const & x) 16 | { 17 | # if(GLM_LANG & GLM_LANG_CXX11_FLAG) 18 | return std::isfinite(x) != 0; 19 | # elif(GLM_COMPILER & GLM_COMPILER_VC) 20 | return _finite(x); 21 | # elif(GLM_COMPILER & GLM_COMPILER_GCC && GLM_PLATFORM & GLM_PLATFORM_ANDROID) 22 | return _isfinite(x) != 0; 23 | # else 24 | return isfinite(x) != 0; 25 | # endif 26 | } 27 | 28 | template 29 | GLM_FUNC_QUALIFIER detail::tvec2 isfinite( 30 | detail::tvec2 const & x) 31 | { 32 | return detail::tvec2( 33 | isfinite(x.x), 34 | isfinite(x.y)); 35 | } 36 | 37 | template 38 | GLM_FUNC_QUALIFIER detail::tvec3 isfinite( 39 | detail::tvec3 const & x) 40 | { 41 | return detail::tvec3( 42 | isfinite(x.x), 43 | isfinite(x.y), 44 | isfinite(x.z)); 45 | } 46 | 47 | template 48 | GLM_FUNC_QUALIFIER detail::tvec4 isfinite( 49 | detail::tvec4 const & x) 50 | { 51 | return detail::tvec4( 52 | isfinite(x.x), 53 | isfinite(x.y), 54 | isfinite(x.z), 55 | isfinite(x.w)); 56 | } 57 | 58 | }//namespace glm 59 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/component_wise.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-05-21 5 | // Updated : 2010-02-12 6 | // Licence : This source is under MIT License 7 | // File : gtx_component_wise.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template class vecType> 13 | GLM_FUNC_QUALIFIER T compAdd(vecType const & v) 14 | { 15 | T result(0); 16 | for(length_t i = 0; i < v.length(); ++i) 17 | result += v[i]; 18 | return result; 19 | } 20 | 21 | template class vecType> 22 | GLM_FUNC_QUALIFIER T compMul(vecType const & v) 23 | { 24 | T result(1); 25 | for(length_t i = 0; i < v.length(); ++i) 26 | result *= v[i]; 27 | return result; 28 | } 29 | 30 | template class vecType> 31 | GLM_FUNC_QUALIFIER T compMin(vecType const & v) 32 | { 33 | T result(v[0]); 34 | for(length_t i = 1; i < v.length(); ++i) 35 | result = min(result, v[i]); 36 | return result; 37 | } 38 | 39 | template class vecType> 40 | GLM_FUNC_QUALIFIER T compMax(vecType const & v) 41 | { 42 | T result(v[0]); 43 | for(length_t i = 1; i < v.length(); ++i) 44 | result = max(result, v[i]); 45 | return result; 46 | } 47 | }//namespace glm 48 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/constants.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /////////////////////////////////////////////////////////////////////////////////// 23 | 24 | #ifndef GLM_GTX_constants 25 | #define GLM_GTX_constants 26 | 27 | #include "../gtc/constants.hpp" 28 | 29 | #if(defined(GLM_MESSAGES)) 30 | # pragma message("GLM: GLM_GTX_constants extension is deprecated, include GLM_GTC_constants (glm/gtc/constants.hpp) instead") 31 | #endif 32 | 33 | #endif//GLM_GTX_constants 34 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/epsilon.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /////////////////////////////////////////////////////////////////////////////////// 23 | 24 | #if(defined(GLM_MESSAGES)) 25 | # pragma message("GLM: GLM_GTX_epsilon extension is deprecated, include GLM_GTC_epsilon (glm/gtc/epsilon) instead") 26 | #endif 27 | 28 | // Promoted: 29 | #include "../gtc/epsilon.hpp" 30 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/extend.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_extend 24 | /// @file glm/gtx/extend.hpp 25 | /// @date 2006-01-07 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_extend GLM_GTX_extend 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Extend a position from a source to a position at a defined length. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_extend 39 | #define GLM_GTX_extend 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 45 | # pragma message("GLM: GLM_GTX_extend extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_extend 51 | /// @{ 52 | 53 | /// Extends of Length the Origin position using the (Source - Origin) direction. 54 | /// @see gtx_extend 55 | template 56 | GLM_FUNC_DECL genType extend( 57 | genType const & Origin, 58 | genType const & Source, 59 | typename genType::value_type const Length); 60 | 61 | /// @} 62 | }//namespace glm 63 | 64 | #include "extend.inl" 65 | 66 | #endif//GLM_GTX_extend 67 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/extend.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2006-01-07 5 | // Updated : 2008-10-05 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/extend.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER genType extend 14 | ( 15 | genType const & Origin, 16 | genType const & Source, 17 | genType const & Distance 18 | ) 19 | { 20 | return Origin + (Source - Origin) * Distance; 21 | } 22 | 23 | template 24 | GLM_FUNC_QUALIFIER detail::tvec2 extend 25 | ( 26 | detail::tvec2 const & Origin, 27 | detail::tvec2 const & Source, 28 | T const & Distance 29 | ) 30 | { 31 | return Origin + (Source - Origin) * Distance; 32 | } 33 | 34 | template 35 | GLM_FUNC_QUALIFIER detail::tvec3 extend 36 | ( 37 | detail::tvec3 const & Origin, 38 | detail::tvec3 const & Source, 39 | T const & Distance 40 | ) 41 | { 42 | return Origin + (Source - Origin) * Distance; 43 | } 44 | 45 | template 46 | GLM_FUNC_QUALIFIER detail::tvec4 extend 47 | ( 48 | detail::tvec4 const & Origin, 49 | detail::tvec4 const & Source, 50 | T const & Distance 51 | ) 52 | { 53 | return Origin + (Source - Origin) * Distance; 54 | } 55 | }//namespace glm 56 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/fast_trigonometry.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2006-01-08 5 | // Updated : 2011-10-14 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/fast_trigonometry.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | // sin 13 | template 14 | GLM_FUNC_QUALIFIER T fastSin(T const & x) 15 | { 16 | return x - ((x * x * x) / T(6)) + ((x * x * x * x * x) / T(120)) - ((x * x * x * x * x * x * x) / T(5040)); 17 | } 18 | 19 | VECTORIZE_VEC(fastSin) 20 | 21 | // cos 22 | template 23 | GLM_FUNC_QUALIFIER T fastCos(T const & x) 24 | { 25 | return T(1) - (x * x * T(0.5)) + (x * x * x * x * T(0.041666666666)) - (x * x * x * x * x * x * T(0.00138888888888)); 26 | } 27 | 28 | VECTORIZE_VEC(fastCos) 29 | 30 | // tan 31 | template 32 | GLM_FUNC_QUALIFIER T fastTan(T const & x) 33 | { 34 | return x + (x * x * x * T(0.3333333333)) + (x * x * x * x * x * T(0.1333333333333)) + (x * x * x * x * x * x * x * T(0.0539682539)); 35 | } 36 | 37 | VECTORIZE_VEC(fastTan) 38 | 39 | // asin 40 | template 41 | GLM_FUNC_QUALIFIER T fastAsin(T const & x) 42 | { 43 | return x + (x * x * x * T(0.166666667)) + (x * x * x * x * x * T(0.075)) + (x * x * x * x * x * x * x * T(0.0446428571)) + (x * x * x * x * x * x * x * x * x * T(0.0303819444));// + (x * x * x * x * x * x * x * x * x * x * x * T(0.022372159)); 44 | } 45 | 46 | VECTORIZE_VEC(fastAsin) 47 | 48 | // acos 49 | template 50 | GLM_FUNC_QUALIFIER T fastAcos(T const & x) 51 | { 52 | return T(1.5707963267948966192313216916398) - fastAsin(x); //(PI / 2) 53 | } 54 | 55 | VECTORIZE_VEC(fastAcos) 56 | 57 | // atan 58 | template 59 | GLM_FUNC_QUALIFIER T fastAtan(T const & y, T const & x) 60 | { 61 | T sgn = sign(y) * sign(x); 62 | return abs(fastAtan(y / x)) * sgn; 63 | } 64 | 65 | VECTORIZE_VEC_VEC(fastAtan) 66 | 67 | template 68 | GLM_FUNC_QUALIFIER T fastAtan(T const & x) 69 | { 70 | return x - (x * x * x * T(0.333333333333)) + (x * x * x * x * x * T(0.2)) - (x * x * x * x * x * x * x * T(0.1428571429)) + (x * x * x * x * x * x * x * x * x * T(0.111111111111)) - (x * x * x * x * x * x * x * x * x * x * x * T(0.0909090909)); 71 | } 72 | 73 | VECTORIZE_VEC(fastAtan) 74 | 75 | }//namespace glm 76 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/gradient_paint.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2009-03-06 5 | // Updated : 2013-04-09 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/gradient_paint.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER T radialGradient 14 | ( 15 | detail::tvec2 const & Center, 16 | T const & Radius, 17 | detail::tvec2 const & Focal, 18 | detail::tvec2 const & Position 19 | ) 20 | { 21 | detail::tvec2 F = Focal - Center; 22 | detail::tvec2 D = Position - Focal; 23 | T Radius2 = pow2(Radius); 24 | T Fx2 = pow2(F.x); 25 | T Fy2 = pow2(F.y); 26 | 27 | T Numerator = (D.x * F.x + D.y * F.y) + sqrt(Radius2 * (pow2(D.x) + pow2(D.y)) - pow2(D.x * F.y - D.y * F.x)); 28 | T Denominator = Radius2 - (Fx2 + Fy2); 29 | return Numerator / Denominator; 30 | } 31 | 32 | template 33 | GLM_FUNC_QUALIFIER T linearGradient 34 | ( 35 | detail::tvec2 const & Point0, 36 | detail::tvec2 const & Point1, 37 | detail::tvec2 const & Position 38 | ) 39 | { 40 | detail::tvec2 Dist = Point1 - Point0; 41 | return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist); 42 | } 43 | }//namespace glm 44 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/handed_coordinate_space.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2009-02-19 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/handed_coordinate_space.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER bool rightHanded 14 | ( 15 | detail::tvec3 const & tangent, 16 | detail::tvec3 const & binormal, 17 | detail::tvec3 const & normal 18 | ) 19 | { 20 | return dot(cross(normal, tangent), binormal) > T(0); 21 | } 22 | 23 | template 24 | GLM_FUNC_QUALIFIER bool leftHanded 25 | ( 26 | detail::tvec3 const & tangent, 27 | detail::tvec3 const & binormal, 28 | detail::tvec3 const & normal 29 | ) 30 | { 31 | return dot(cross(normal, tangent), binormal) < T(0); 32 | } 33 | }//namespace glm 34 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/int_10_10_10_2.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /////////////////////////////////////////////////////////////////////////////////// 23 | 24 | #ifndef GLM_GTX_int_10_10_10_2 25 | #define GLM_GTX_int_10_10_10_2 26 | 27 | // Dependency: 28 | #include "../glm.hpp" 29 | #include "../gtx/raw_data.hpp" 30 | 31 | #if(defined(GLM_MESSAGES)) 32 | # pragma message("GLM: GLM_GTX_int_10_10_10_2 extension is deprecated, include GLM_GTC_packing (glm/gtc/packing.hpp) instead") 33 | #endif 34 | 35 | namespace glm 36 | { 37 | //! Deprecated, use packUnorm3x10_1x2 instead. 38 | GLM_DEPRECATED GLM_FUNC_DECL dword uint10_10_10_2_cast(glm::vec4 const & v); 39 | 40 | }//namespace glm 41 | 42 | #include "int_10_10_10_2.inl" 43 | 44 | #endif//GLM_GTX_int_10_10_10_2 45 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/int_10_10_10_2.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /////////////////////////////////////////////////////////////////////////////////// 23 | 24 | namespace glm 25 | { 26 | GLM_FUNC_QUALIFIER dword uint10_10_10_2_cast 27 | ( 28 | glm::vec4 const & v 29 | ) 30 | { 31 | return dword(uint(v.x * 2047.f) << 0 | uint(v.y * 2047.f) << 10 | uint(v.z * 2047.f) << 20 | uint(v.w * 3.f) << 30); 32 | } 33 | }//namespace glm 34 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/log_base.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_log_base 24 | /// @file glm/gtx/log_base.hpp 25 | /// @date 2008-10-24 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_log_base GLM_GTX_log_base 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Logarithm for any base. base can be a vector or a scalar. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_log_base 39 | #define GLM_GTX_log_base 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 45 | # pragma message("GLM: GLM_GTX_log_base extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_log_base 51 | /// @{ 52 | 53 | //! Logarithm for any base. 54 | //! From GLM_GTX_log_base. 55 | template 56 | GLM_FUNC_DECL genType log( 57 | genType const & x, 58 | genType const & base); 59 | 60 | /// @} 61 | }//namespace glm 62 | 63 | #include "log_base.inl" 64 | 65 | #endif//GLM_GTX_log_base 66 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/log_base.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2008-10-24 5 | // Updated : 2008-10-24 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/log_base.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER genType log( 14 | genType const & x, 15 | genType const & base) 16 | { 17 | assert(x != genType(0)); 18 | 19 | return glm::log(x) / glm::log(base); 20 | } 21 | 22 | VECTORIZE_VEC_SCA(log) 23 | VECTORIZE_VEC_VEC(log) 24 | }//namespace glm 25 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/matrix_cross_product.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_matrix_cross_product 24 | /// @file glm/gtx/matrix_cross_product.hpp 25 | /// @date 2005-12-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_extented_min_max (dependence) 30 | /// 31 | /// @defgroup gtx_matrix_cross_product GLM_GTX_matrix_cross_product 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Build cross product matrices 35 | /// 36 | /// need to be included to use these functionalities. 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | #ifndef GLM_GTX_matrix_cross_product 40 | #define GLM_GTX_matrix_cross_product 41 | 42 | // Dependency: 43 | #include "../glm.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 46 | # pragma message("GLM: GLM_GTX_matrix_cross_product extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_matrix_cross_product 52 | /// @{ 53 | 54 | //! Build a cross product matrix. 55 | //! From GLM_GTX_matrix_cross_product extension. 56 | template 57 | GLM_FUNC_DECL detail::tmat3x3 matrixCross3( 58 | detail::tvec3 const & x); 59 | 60 | //! Build a cross product matrix. 61 | //! From GLM_GTX_matrix_cross_product extension. 62 | template 63 | GLM_FUNC_DECL detail::tmat4x4 matrixCross4( 64 | detail::tvec3 const & x); 65 | 66 | /// @} 67 | }//namespace glm 68 | 69 | #include "matrix_cross_product.inl" 70 | 71 | #endif//GLM_GTX_matrix_cross_product 72 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/matrix_cross_product.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2005-12-21 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/matrix_cross_product.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tmat3x3 matrixCross3 14 | ( 15 | detail::tvec3 const & x 16 | ) 17 | { 18 | detail::tmat3x3 Result(T(0)); 19 | Result[0][1] = x.z; 20 | Result[1][0] = -x.z; 21 | Result[0][2] = -x.y; 22 | Result[2][0] = x.y; 23 | Result[1][2] = x.x; 24 | Result[2][1] = -x.x; 25 | return Result; 26 | } 27 | 28 | template 29 | GLM_FUNC_QUALIFIER detail::tmat4x4 matrixCross4 30 | ( 31 | detail::tvec3 const & x 32 | ) 33 | { 34 | detail::tmat4x4 Result(T(0)); 35 | Result[0][1] = x.z; 36 | Result[1][0] = -x.z; 37 | Result[0][2] = -x.y; 38 | Result[2][0] = x.y; 39 | Result[1][2] = x.x; 40 | Result[2][1] = -x.x; 41 | return Result; 42 | } 43 | 44 | }//namespace glm 45 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/mixed_product.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_mixed_product 24 | /// @file glm/gtx/mixed_product.hpp 25 | /// @date 2007-04-03 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_mixed_product GLM_GTX_mixed_producte 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Mixed product of 3 vectors. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_mixed_product 39 | #define GLM_GTX_mixed_product 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 45 | # pragma message("GLM: GLM_GTX_mixed_product extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_mixed_product 51 | /// @{ 52 | 53 | /// @brief Mixed product of 3 vectors (from GLM_GTX_mixed_product extension) 54 | template 55 | GLM_FUNC_DECL T mixedProduct( 56 | detail::tvec3 const & v1, 57 | detail::tvec3 const & v2, 58 | detail::tvec3 const & v3); 59 | 60 | /// @} 61 | }// namespace glm 62 | 63 | #include "mixed_product.inl" 64 | 65 | #endif//GLM_GTX_mixed_product 66 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/mixed_product.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-04-03 5 | // Updated : 2008-09-17 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/mixed_product.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER T mixedProduct 14 | ( 15 | detail::tvec3 const & v1, 16 | detail::tvec3 const & v2, 17 | detail::tvec3 const & v3 18 | ) 19 | { 20 | return dot(cross(v1, v2), v3); 21 | } 22 | }//namespace glm 23 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/noise.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /////////////////////////////////////////////////////////////////////////////////// 23 | 24 | #if(defined(GLM_MESSAGES)) 25 | # pragma message("GLM: GLM_GTX_random extension is deprecated, include GLM_GTC_random (glm/gtc/noise.hpp) instead") 26 | #endif 27 | 28 | // Promoted: 29 | #include "../gtc/noise.hpp" 30 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/normal.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_normal 24 | /// @file glm/gtx/normal.hpp 25 | /// @date 2005-12-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_extented_min_max (dependence) 30 | /// 31 | /// @defgroup gtx_normal GLM_GTX_normal 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Compute the normal of a triangle. 35 | /// 36 | /// need to be included to use these functionalities. 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | #ifndef GLM_GTX_normal 40 | #define GLM_GTX_normal 41 | 42 | // Dependency: 43 | #include "../glm.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 46 | # pragma message("GLM: GLM_GTX_normal extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_normal 52 | /// @{ 53 | 54 | //! Computes triangle normal from triangle points. 55 | //! From GLM_GTX_normal extension. 56 | template 57 | GLM_FUNC_DECL detail::tvec3 triangleNormal( 58 | detail::tvec3 const & p1, 59 | detail::tvec3 const & p2, 60 | detail::tvec3 const & p3); 61 | 62 | /// @} 63 | }//namespace glm 64 | 65 | #include "normal.inl" 66 | 67 | #endif//GLM_GTX_normal 68 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/normal.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2011-06-07 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/normal.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tvec3 triangleNormal 14 | ( 15 | detail::tvec3 const & p1, 16 | detail::tvec3 const & p2, 17 | detail::tvec3 const & p3 18 | ) 19 | { 20 | return normalize(cross(p1 - p2, p1 - p3)); 21 | } 22 | }//namespace glm 23 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/normalize_dot.inl: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | ////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-09-28 5 | // Updated : 2008-10-07 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/normalize_dot.inl 8 | ////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER genType normalizeDot 14 | ( 15 | genType const & x, 16 | genType const & y 17 | ) 18 | { 19 | return 20 | glm::dot(x, y) * 21 | glm::inversesqrt(glm::dot(x, x) * 22 | glm::dot(y, y)); 23 | } 24 | 25 | template 26 | GLM_FUNC_QUALIFIER T normalizeDot 27 | ( 28 | detail::tvec2 const & x, 29 | detail::tvec2 const & y 30 | ) 31 | { 32 | return 33 | glm::dot(x, y) * 34 | glm::inversesqrt(glm::dot(x, x) * 35 | glm::dot(y, y)); 36 | } 37 | 38 | template 39 | GLM_FUNC_QUALIFIER T normalizeDot 40 | ( 41 | detail::tvec3 const & x, 42 | detail::tvec3 const & y 43 | ) 44 | { 45 | return 46 | glm::dot(x, y) * 47 | glm::inversesqrt(glm::dot(x, x) * 48 | glm::dot(y, y)); 49 | } 50 | 51 | template 52 | GLM_FUNC_QUALIFIER T normalizeDot 53 | ( 54 | detail::tvec4 const & x, 55 | detail::tvec4 const & y 56 | ) 57 | { 58 | return 59 | glm::dot(x, y) * 60 | glm::inversesqrt(glm::dot(x, x) * 61 | glm::dot(y, y)); 62 | } 63 | 64 | template 65 | GLM_FUNC_QUALIFIER genType fastNormalizeDot 66 | ( 67 | genType const & x, 68 | genType const & y 69 | ) 70 | { 71 | return 72 | glm::dot(x, y) * 73 | fastInverseSqrt(glm::dot(x, x) * 74 | glm::dot(y, y)); 75 | } 76 | 77 | template 78 | GLM_FUNC_QUALIFIER T fastNormalizeDot 79 | ( 80 | detail::tvec2 const & x, 81 | detail::tvec2 const & y 82 | ) 83 | { 84 | return 85 | glm::dot(x, y) * 86 | fastInverseSqrt(glm::dot(x, x) * 87 | glm::dot(y, y)); 88 | } 89 | 90 | template 91 | GLM_FUNC_QUALIFIER T fastNormalizeDot 92 | ( 93 | detail::tvec3 const & x, 94 | detail::tvec3 const & y 95 | ) 96 | { 97 | return 98 | glm::dot(x, y) * 99 | fastInverseSqrt(glm::dot(x, x) * 100 | glm::dot(y, y)); 101 | } 102 | 103 | template 104 | GLM_FUNC_QUALIFIER T fastNormalizeDot 105 | ( 106 | detail::tvec4 const & x, 107 | detail::tvec4 const & y 108 | ) 109 | { 110 | return 111 | glm::dot(x, y) * 112 | fastInverseSqrt(glm::dot(x, x) * 113 | glm::dot(y, y)); 114 | } 115 | }//namespace glm 116 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/number_precision.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-05-10 5 | // Updated : 2007-05-10 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/number_precision.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/optimum_pow.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2005-12-27 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/optimum_pow.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER genType pow2(genType const & x) 14 | { 15 | return x * x; 16 | } 17 | 18 | template 19 | GLM_FUNC_QUALIFIER genType pow3(genType const & x) 20 | { 21 | return x * x * x; 22 | } 23 | 24 | template 25 | GLM_FUNC_QUALIFIER genType pow4(genType const & x) 26 | { 27 | return (x * x) * (x * x); 28 | } 29 | 30 | GLM_FUNC_QUALIFIER bool powOfTwo(int x) 31 | { 32 | return !(x & (x - 1)); 33 | } 34 | 35 | template 36 | GLM_FUNC_QUALIFIER detail::tvec2 powOfTwo(detail::tvec2 const & x) 37 | { 38 | return detail::tvec2( 39 | powOfTwo(x.x), 40 | powOfTwo(x.y)); 41 | } 42 | 43 | template 44 | GLM_FUNC_QUALIFIER detail::tvec3 powOfTwo(detail::tvec3 const & x) 45 | { 46 | return detail::tvec3( 47 | powOfTwo(x.x), 48 | powOfTwo(x.y), 49 | powOfTwo(x.z)); 50 | } 51 | 52 | template 53 | GLM_FUNC_QUALIFIER detail::tvec4 powOfTwo(detail::tvec4 const & x) 54 | { 55 | return detail::tvec4( 56 | powOfTwo(x.x), 57 | powOfTwo(x.y), 58 | powOfTwo(x.z), 59 | powOfTwo(x.w)); 60 | } 61 | }//namespace glm 62 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/orthonormalize.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_orthonormalize 24 | /// @file glm/gtx/orthonormalize.hpp 25 | /// @date 2005-12-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_extented_min_max (dependence) 30 | /// 31 | /// @defgroup gtx_orthonormalize GLM_GTX_orthonormalize 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Orthonormalize matrices. 35 | /// 36 | /// need to be included to use these functionalities. 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | #ifndef GLM_GTX_orthonormalize 40 | #define GLM_GTX_orthonormalize 41 | 42 | // Dependency: 43 | #include "../glm.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 46 | # pragma message("GLM: GLM_GTX_orthonormalize extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_orthonormalize 52 | /// @{ 53 | 54 | //! Returns the orthonormalized matrix of m. 55 | //! From GLM_GTX_orthonormalize extension. 56 | template 57 | GLM_FUNC_DECL detail::tmat3x3 orthonormalize( 58 | const detail::tmat3x3& m); 59 | 60 | //! Orthonormalizes x according y. 61 | //! From GLM_GTX_orthonormalize extension. 62 | template 63 | GLM_FUNC_DECL detail::tvec3 orthonormalize( 64 | const detail::tvec3& x, 65 | const detail::tvec3& y); 66 | 67 | /// @} 68 | }//namespace glm 69 | 70 | #include "orthonormalize.inl" 71 | 72 | #endif//GLM_GTX_orthonormalize 73 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/orthonormalize.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2005-12-21 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/orthonormalize.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tmat3x3 orthonormalize 14 | ( 15 | const detail::tmat3x3& m 16 | ) 17 | { 18 | detail::tmat3x3 r = m; 19 | 20 | r[0] = normalize(r[0]); 21 | 22 | float d0 = dot(r[0], r[1]); 23 | r[1] -= r[0] * d0; 24 | r[1] = normalize(r[1]); 25 | 26 | float d1 = dot(r[1], r[2]); 27 | d0 = dot(r[0], r[2]); 28 | r[2] -= r[0] * d0 + r[1] * d1; 29 | r[2] = normalize(r[2]); 30 | 31 | return r; 32 | } 33 | 34 | template 35 | GLM_FUNC_QUALIFIER detail::tvec3 orthonormalize 36 | ( 37 | const detail::tvec3& x, 38 | const detail::tvec3& y 39 | ) 40 | { 41 | return normalize(x - y * dot(y, x)); 42 | } 43 | }//namespace glm 44 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/perpendicular.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_perpendicular 24 | /// @file glm/gtx/perpendicular.hpp 25 | /// @date 2005-12-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtx_projection (dependence) 30 | /// 31 | /// @defgroup gtx_perpendicular GLM_GTX_perpendicular 32 | /// @ingroup gtx 33 | /// 34 | /// @brief Perpendicular of a vector from other one 35 | /// 36 | /// need to be included to use these functionalities. 37 | /////////////////////////////////////////////////////////////////////////////////// 38 | 39 | #ifndef GLM_GTX_perpendicular 40 | #define GLM_GTX_perpendicular 41 | 42 | // Dependency: 43 | #include "../glm.hpp" 44 | #include "../gtx/projection.hpp" 45 | 46 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 47 | # pragma message("GLM: GLM_GTX_perpendicular extension included") 48 | #endif 49 | 50 | namespace glm 51 | { 52 | /// @addtogroup gtx_perpendicular 53 | /// @{ 54 | 55 | //! Projects x a perpendicular axis of Normal. 56 | //! From GLM_GTX_perpendicular extension. 57 | template 58 | GLM_FUNC_DECL vecType perp( 59 | vecType const & x, 60 | vecType const & Normal); 61 | 62 | /// @} 63 | }//namespace glm 64 | 65 | #include "perpendicular.inl" 66 | 67 | #endif//GLM_GTX_perpendicular 68 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/perpendicular.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2009-03-06 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/perpendicular.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER vecType perp 14 | ( 15 | vecType const & x, 16 | vecType const & Normal 17 | ) 18 | { 19 | return x - proj(x, Normal); 20 | } 21 | }//namespace glm 22 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/polar_coordinates.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_polar_coordinates 24 | /// @file glm/gtx/polar_coordinates.hpp 25 | /// @date 2007-03-06 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_polar_coordinates GLM_GTX_polar_coordinates 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Conversion from Euclidean space to polar space and revert. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_polar_coordinates 39 | #define GLM_GTX_polar_coordinates 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 45 | # pragma message("GLM: GLM_GTX_polar_coordinates extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_polar_coordinates 51 | /// @{ 52 | 53 | /// Convert Euclidean to Polar coordinates, x is the xz distance, y, the latitude and z the longitude. 54 | /// 55 | /// @see gtx_polar_coordinates 56 | template 57 | GLM_FUNC_DECL detail::tvec3 polar( 58 | detail::tvec3 const & euclidean); 59 | 60 | /// Convert Polar to Euclidean coordinates. 61 | /// 62 | /// @see gtx_polar_coordinates 63 | template 64 | GLM_FUNC_DECL detail::tvec3 euclidean( 65 | detail::tvec2 const & polar); 66 | 67 | /// @} 68 | }//namespace glm 69 | 70 | #include "polar_coordinates.inl" 71 | 72 | #endif//GLM_GTX_polar_coordinates 73 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/polar_coordinates.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-03-06 5 | // Updated : 2009-05-01 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/polar_coordinates.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tvec3 polar 14 | ( 15 | detail::tvec3 const & euclidean 16 | ) 17 | { 18 | T const Length(length(euclidean)); 19 | detail::tvec3 const tmp(euclidean / Length); 20 | T const xz_dist(sqrt(tmp.x * tmp.x + tmp.z * tmp.z)); 21 | 22 | #ifdef GLM_FORCE_RADIANS 23 | return detail::tvec3( 24 | atan(xz_dist, tmp.y), // latitude 25 | atan(tmp.x, tmp.z), // longitude 26 | xz_dist); // xz distance 27 | #else 28 | # pragma message("GLM: polar function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.") 29 | return detail::tvec3( 30 | degrees(atan(xz_dist, tmp.y)), // latitude 31 | degrees(atan(tmp.x, tmp.z)), // longitude 32 | xz_dist); // xz distance 33 | #endif 34 | } 35 | 36 | template 37 | GLM_FUNC_QUALIFIER detail::tvec3 euclidean 38 | ( 39 | detail::tvec2 const & polar 40 | ) 41 | { 42 | #ifdef GLM_FORCE_RADIANS 43 | T const latitude(polar.x); 44 | T const longitude(polar.y); 45 | #else 46 | # pragma message("GLM: euclidean function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.") 47 | T const latitude(radians(polar.x)); 48 | T const longitude(radians(polar.y)); 49 | #endif 50 | 51 | return detail::tvec3( 52 | cos(latitude) * sin(longitude), 53 | sin(latitude), 54 | cos(latitude) * cos(longitude)); 55 | } 56 | 57 | }//namespace glm 58 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/projection.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_projection 24 | /// @file glm/gtx/projection.hpp 25 | /// @date 2005-12-21 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_projection GLM_GTX_projection 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Projection of a vector to other one 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_projection 39 | #define GLM_GTX_projection 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 45 | # pragma message("GLM: GLM_GTX_projection extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_projection 51 | /// @{ 52 | 53 | //! Projects x on Normal. 54 | //! From GLM_GTX_projection extension. 55 | template 56 | GLM_FUNC_DECL vecType proj( 57 | vecType const & x, 58 | vecType const & Normal); 59 | 60 | /// @} 61 | }//namespace glm 62 | 63 | #include "projection.inl" 64 | 65 | #endif//GLM_GTX_projection 66 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/projection.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2009-03-06 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/projection.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER vecType proj 14 | ( 15 | vecType const & x, 16 | vecType const & Normal 17 | ) 18 | { 19 | return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal; 20 | } 21 | }//namespace glm 22 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/random.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /////////////////////////////////////////////////////////////////////////////////// 23 | 24 | #if(defined(GLM_MESSAGES)) 25 | # pragma message("GLM: GLM_GTX_random extension is deprecated, include GLM_GTC_random instead") 26 | #endif 27 | 28 | // Promoted: 29 | #include "../gtc/random.hpp" 30 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/raw_data.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_raw_data 24 | /// @file glm/gtx/raw_data.hpp 25 | /// @date 2008-11-19 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_raw_data GLM_GTX_raw_data 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Projection of a vector to other one 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_raw_data 39 | #define GLM_GTX_raw_data 40 | 41 | // Dependencies 42 | #include "../detail/setup.hpp" 43 | #include "../detail/type_int.hpp" 44 | 45 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 46 | # pragma message("GLM: GLM_GTX_raw_data extension included") 47 | #endif 48 | 49 | namespace glm 50 | { 51 | /// @addtogroup gtx_raw_data 52 | /// @{ 53 | 54 | //! Type for byte numbers. 55 | //! From GLM_GTX_raw_data extension. 56 | typedef detail::uint8 byte; 57 | 58 | //! Type for word numbers. 59 | //! From GLM_GTX_raw_data extension. 60 | typedef detail::uint16 word; 61 | 62 | //! Type for dword numbers. 63 | //! From GLM_GTX_raw_data extension. 64 | typedef detail::uint32 dword; 65 | 66 | //! Type for qword numbers. 67 | //! From GLM_GTX_raw_data extension. 68 | typedef detail::uint64 qword; 69 | 70 | /// @} 71 | }// namespace glm 72 | 73 | #include "raw_data.inl" 74 | 75 | #endif//GLM_GTX_raw_data 76 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/raw_data.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2008-11-19 5 | // Updated : 2008-11-19 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/raw_data.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | // Dependency: 10 | // - GLM core 11 | /////////////////////////////////////////////////////////////////////////////////////////////////// 12 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/reciprocal.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /////////////////////////////////////////////////////////////////////////////////// 23 | 24 | #if(defined(GLM_MESSAGES)) 25 | # pragma message("GLM: GLM_GTX_reciprocal extension is deprecated, include GLM_GTC_reciprocal instead") 26 | #endif 27 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/scalar_relational.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_scalar_relational 24 | /// @file glm/gtx/scalar_relational.hpp 25 | /// @date 2013-02-04 / 2013-02-04 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_extend GLM_GTX_scalar_relational 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Extend a position from a source to a position at a defined length. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_scalar_relational 39 | #define GLM_GTX_scalar_relational 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 45 | # pragma message("GLM: GLM_GTX_extend extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_scalar_relational 51 | /// @{ 52 | 53 | 54 | 55 | /// @} 56 | }//namespace glm 57 | 58 | #include "scalar_relational.inl" 59 | 60 | #endif//GLM_GTX_scalar_relational 61 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/scalar_relational.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2013-02-04 5 | // Updated : 2013-02-04 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/scalar_relational.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER bool lessThan 14 | ( 15 | T const & x, 16 | T const & y 17 | ) 18 | { 19 | return x < y; 20 | } 21 | 22 | template 23 | GLM_FUNC_QUALIFIER bool lessThanEqual 24 | ( 25 | T const & x, 26 | T const & y 27 | ) 28 | { 29 | return x <= y; 30 | } 31 | 32 | template 33 | GLM_FUNC_QUALIFIER bool greaterThan 34 | ( 35 | T const & x, 36 | T const & y 37 | ) 38 | { 39 | return x > y; 40 | } 41 | 42 | template 43 | GLM_FUNC_QUALIFIER bool greaterThanEqual 44 | ( 45 | T const & x, 46 | T const & y 47 | ) 48 | { 49 | return x >= y; 50 | } 51 | 52 | template 53 | GLM_FUNC_QUALIFIER bool equal 54 | ( 55 | T const & x, 56 | T const & y 57 | ) 58 | { 59 | return x == y; 60 | } 61 | 62 | template 63 | GLM_FUNC_QUALIFIER bool notEqual 64 | ( 65 | T const & x, 66 | T const & y 67 | ) 68 | { 69 | return x != y; 70 | } 71 | 72 | GLM_FUNC_QUALIFIER bool any 73 | ( 74 | bool const & x 75 | ) 76 | { 77 | return x; 78 | } 79 | 80 | GLM_FUNC_QUALIFIER bool all 81 | ( 82 | bool const & x 83 | ) 84 | { 85 | return x; 86 | } 87 | 88 | GLM_FUNC_QUALIFIER bool not_ 89 | ( 90 | bool const & x 91 | ) 92 | { 93 | return !x; 94 | } 95 | }//namespace glm 96 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/spline.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2007-01-25 5 | // Updated : 2009-02-19 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/spline.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm{ 11 | 12 | template 13 | GLM_FUNC_QUALIFIER genType catmullRom 14 | ( 15 | genType const & v1, 16 | genType const & v2, 17 | genType const & v3, 18 | genType const & v4, 19 | typename genType::value_type const & s 20 | ) 21 | { 22 | typename genType::value_type s1 = s; 23 | typename genType::value_type s2 = pow2(s); 24 | typename genType::value_type s3 = pow3(s); 25 | 26 | typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s; 27 | typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2); 28 | typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s; 29 | typename genType::value_type f4 = s3 - s2; 30 | 31 | return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / typename genType::value_type(2); 32 | 33 | } 34 | 35 | template 36 | GLM_FUNC_QUALIFIER genType hermite 37 | ( 38 | genType const & v1, 39 | genType const & t1, 40 | genType const & v2, 41 | genType const & t2, 42 | typename genType::value_type const & s 43 | ) 44 | { 45 | typename genType::value_type s1 = s; 46 | typename genType::value_type s2 = pow2(s); 47 | typename genType::value_type s3 = pow3(s); 48 | 49 | typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1); 50 | typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2; 51 | typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s; 52 | typename genType::value_type f4 = s3 - s2; 53 | 54 | return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2; 55 | } 56 | 57 | template 58 | GLM_FUNC_QUALIFIER genType cubic 59 | ( 60 | genType const & v1, 61 | genType const & v2, 62 | genType const & v3, 63 | genType const & v4, 64 | typename genType::value_type const & s 65 | ) 66 | { 67 | return ((v1 * s + v2) * s + v3) * s + v4; 68 | } 69 | 70 | }//namespace glm 71 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/std_based_type.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2008-06-08 5 | // Updated : 2008-06-08 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/std_based_type.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/string_cast.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_string_cast 24 | /// @file glm/gtx/string_cast.hpp 25 | /// @date 2008-04-26 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// @see gtc_half_float (dependence) 30 | /// @see gtx_integer (dependence) 31 | /// @see gtx_quaternion (dependence) 32 | /// 33 | /// @defgroup gtx_string_cast GLM_GTX_string_cast 34 | /// @ingroup gtx 35 | /// 36 | /// @brief Setup strings for GLM type values 37 | /// 38 | /// need to be included to use these functionalities. 39 | /// This extension is not supported with CUDA 40 | /////////////////////////////////////////////////////////////////////////////////// 41 | 42 | #ifndef GLM_GTX_string_cast 43 | #define GLM_GTX_string_cast 44 | 45 | // Dependency: 46 | #include "../glm.hpp" 47 | #include "../gtx/integer.hpp" 48 | #include "../gtx/quaternion.hpp" 49 | #include 50 | 51 | #if(GLM_COMPILER & GLM_COMPILER_CUDA) 52 | # error "GLM_GTX_string_cast is not supported on CUDA compiler" 53 | #endif 54 | 55 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 56 | # pragma message("GLM: GLM_GTX_string_cast extension included") 57 | #endif 58 | 59 | namespace glm 60 | { 61 | /// @addtogroup gtx_string_cast 62 | /// @{ 63 | 64 | /// Create a string from a GLM type value. 65 | /// @see gtx_string_cast extension. 66 | template 67 | GLM_FUNC_DECL std::string to_string(genType const & x); 68 | 69 | /// @} 70 | }//namespace glm 71 | 72 | #include "string_cast.inl" 73 | 74 | #endif//GLM_GTX_string_cast 75 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/transform.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-21 5 | // Updated : 2009-04-29 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/transform.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | template 13 | GLM_FUNC_QUALIFIER detail::tmat4x4 translate( 14 | detail::tvec3 const & v) 15 | { 16 | return translate( 17 | detail::tmat4x4(1.0f), v); 18 | } 19 | 20 | template 21 | GLM_FUNC_QUALIFIER detail::tmat4x4 rotate( 22 | T angle, 23 | detail::tvec3 const & v) 24 | { 25 | return rotate( 26 | detail::tmat4x4(1), angle, v); 27 | } 28 | 29 | template 30 | GLM_FUNC_QUALIFIER detail::tmat4x4 scale( 31 | detail::tvec3 const & v) 32 | { 33 | return scale( 34 | detail::tmat4x4(1.0f), v); 35 | } 36 | 37 | }//namespace glm 38 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/ulp.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /////////////////////////////////////////////////////////////////////////////////// 23 | 24 | #if(defined(GLM_MESSAGES)) 25 | # pragma message("GLM: GLM_GTX_ulp extension is deprecated, include GLM_GTC_ulp (glm/gtc/ulp.hpp) instead") 26 | #endif 27 | 28 | // Promoted: 29 | #include "../gtc/ulp.hpp" 30 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/unsigned_int.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /////////////////////////////////////////////////////////////////////////////////// 23 | 24 | #if(defined(GLM_MESSAGES)) 25 | # pragma message("GLM: GLM_GTX_unsigned_int extension is deprecated, include GLM_GTX_integer instead") 26 | #endif 27 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/unsigned_int.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////////////////////// 2 | // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 3 | /////////////////////////////////////////////////////////////////////////////////////////////////// 4 | // Created : 2005-12-24 5 | // Updated : 2008-10-07 6 | // Licence : This source is under MIT License 7 | // File : glm/gtx/unsigned_int.inl 8 | /////////////////////////////////////////////////////////////////////////////////////////////////// 9 | 10 | namespace glm 11 | { 12 | 13 | }//namespace glm 14 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/vec1.inl: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_vec1 24 | /// @file glm/gtx/vec1.inl 25 | /// @date 2013-03-16 / 2013-03-16 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | -------------------------------------------------------------------------------- /Source/Include/GLM/gtx/wrap.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref gtx_wrap 24 | /// @file glm/gtx/wrap.hpp 25 | /// @date 2009-11-25 / 2011-06-07 26 | /// @author Christophe Riccio 27 | /// 28 | /// @see core (dependence) 29 | /// 30 | /// @defgroup gtx_wrap GLM_GTX_wrap 31 | /// @ingroup gtx 32 | /// 33 | /// @brief Wrapping mode of texture coordinates. 34 | /// 35 | /// need to be included to use these functionalities. 36 | /////////////////////////////////////////////////////////////////////////////////// 37 | 38 | #ifndef GLM_GTX_wrap 39 | #define GLM_GTX_wrap 40 | 41 | // Dependency: 42 | #include "../glm.hpp" 43 | 44 | #if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED)) 45 | # pragma message("GLM: GLM_GTX_wrap extension included") 46 | #endif 47 | 48 | namespace glm 49 | { 50 | /// @addtogroup gtx_wrap 51 | /// @{ 52 | 53 | /// Simulate GL_CLAMP OpenGL wrap mode 54 | /// @see gtx_wrap extension. 55 | template 56 | GLM_FUNC_DECL genType clamp(genType const & Texcoord); 57 | 58 | /// Simulate GL_REPEAT OpenGL wrap mode 59 | /// @see gtx_wrap extension. 60 | template 61 | GLM_FUNC_DECL genType repeat(genType const & Texcoord); 62 | 63 | /// Simulate GL_MIRROR_REPEAT OpenGL wrap mode 64 | /// @see gtx_wrap extension. 65 | template 66 | GLM_FUNC_DECL genType mirrorRepeat(genType const & Texcoord); 67 | 68 | /// @} 69 | }// namespace glm 70 | 71 | #include "wrap.inl" 72 | 73 | #endif//GLM_GTX_wrap 74 | -------------------------------------------------------------------------------- /Source/Include/GLM/integer.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/integer.hpp 25 | /// @date 2013-12-24 / 2013-12-24 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_INTEGER_INCLUDED 30 | #define GLM_INTEGER_INCLUDED 31 | 32 | #include "detail/func_integer.hpp" 33 | 34 | #endif//GLM_INTEGER_INCLUDED 35 | -------------------------------------------------------------------------------- /Source/Include/GLM/matrix.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/matrix.hpp 25 | /// @date 2013-12-24 / 2013-12-24 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_MATRIX_INCLUDED 30 | #define GLM_MATRIX_INCLUDED 31 | 32 | #include "detail/func_matrix.hpp" 33 | 34 | #endif//GLM_MATRIX_INCLUDED 35 | -------------------------------------------------------------------------------- /Source/Include/GLM/packing.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/packing.hpp 25 | /// @date 2013-12-24 / 2013-12-24 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_PACKING_INCLUDED 30 | #define GLM_PACKING_INCLUDED 31 | 32 | #include "detail/func_packing.hpp" 33 | 34 | #endif//GLM_PACKING_INCLUDED 35 | -------------------------------------------------------------------------------- /Source/Include/GLM/trigonometric.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/trigonometric.hpp 25 | /// @date 2013-12-24 / 2013-12-24 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_TRIGONOMETRIC_INCLUDED 30 | #define GLM_TRIGONOMETRIC_INCLUDED 31 | 32 | #include "detail/func_trigonometric.hpp" 33 | 34 | #endif//GLM_TRIGONOMETRIC_INCLUDED 35 | -------------------------------------------------------------------------------- /Source/Include/GLM/vec2.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/vec2.hpp 25 | /// @date 2013-12-24 / 2013-12-24 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_VEC2_INCLUDED 30 | #define GLM_VEC2_INCLUDED 31 | 32 | #include "detail/type_vec2.hpp" 33 | 34 | #endif//GLM_VEC2_INCLUDED 35 | -------------------------------------------------------------------------------- /Source/Include/GLM/vec3.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/vec3.hpp 25 | /// @date 2013-12-24 / 2013-12-24 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_VEC3_INCLUDED 30 | #define GLM_VEC3_INCLUDED 31 | 32 | #include "detail/type_vec3.hpp" 33 | 34 | #endif//GLM_VEC3_INCLUDED 35 | -------------------------------------------------------------------------------- /Source/Include/GLM/vec4.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/vec4.hpp 25 | /// @date 2013-12-24 / 2013-12-24 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_VEC4_INCLUDED 30 | #define GLM_VEC4_INCLUDED 31 | 32 | #include "detail/type_vec4.hpp" 33 | 34 | #endif//GLM_VEC4_INCLUDED 35 | -------------------------------------------------------------------------------- /Source/Include/GLM/vector_relational.hpp: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////////// 2 | /// OpenGL Mathematics (glm.g-truc.net) 3 | /// 4 | /// Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) 5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy 6 | /// of this software and associated documentation files (the "Software"), to deal 7 | /// in the Software without restriction, including without limitation the rights 8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | /// copies of the Software, and to permit persons to whom the Software is 10 | /// furnished to do so, subject to the following conditions: 11 | /// 12 | /// The above copyright notice and this permission notice shall be included in 13 | /// all copies or substantial portions of the Software. 14 | /// 15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | /// THE SOFTWARE. 22 | /// 23 | /// @ref core 24 | /// @file glm/vector_relational.hpp 25 | /// @date 2013-12-24 / 2013-12-24 26 | /// @author Christophe Riccio 27 | /////////////////////////////////////////////////////////////////////////////////// 28 | 29 | #ifndef GLM_VECTOR_RELATIONAL_INCLUDED 30 | #define GLM_VECTOR_RELATIONAL_INCLUDED 31 | 32 | #include "detail/func_vector_relational.hpp" 33 | 34 | #endif//GLM_VECTOR_RELATIONAL_INCLUDED 35 | -------------------------------------------------------------------------------- /Source/Include/OpenGL/gl_basic_typedefs.h: -------------------------------------------------------------------------------- 1 | #ifndef GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS 2 | #define GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS 3 | #include 4 | #ifndef GLEXT_64_TYPES_DEFINED 5 | /* This code block is duplicated in glxext.h, so must be protected */ 6 | #define GLEXT_64_TYPES_DEFINED 7 | /* Define int32_t, int64_t, and uint64_t types for UST/MSC */ 8 | /* (as used in the GL_EXT_timer_query extension). */ 9 | #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 10 | #include 11 | #elif defined(__sun__) || defined(__digital__) 12 | #include 13 | #if defined(__STDC__) 14 | #if defined(__arch64__) || defined(_LP64) 15 | typedef long int int64_t; 16 | typedef unsigned long int uint64_t; 17 | #else 18 | typedef long long int int64_t; 19 | typedef unsigned long long int uint64_t; 20 | #endif /* __arch64__ */ 21 | #endif /* __STDC__ */ 22 | #elif defined( __VMS ) || defined(__sgi) 23 | #include 24 | #elif defined(__SCO__) || defined(__USLC__) 25 | #include 26 | #elif defined(__UNIXOS2__) || defined(__SOL64__) 27 | typedef long int int32_t; 28 | typedef long long int int64_t; 29 | typedef unsigned long long int uint64_t; 30 | #elif defined(_WIN32) && defined(__GNUC__) 31 | #include 32 | #elif defined(_WIN32) 33 | typedef __int32 int32_t; 34 | typedef __int64 int64_t; 35 | typedef unsigned __int64 uint64_t; 36 | #else 37 | /* Fallback if nothing above works */ 38 | #include 39 | #endif 40 | #endif 41 | typedef unsigned int GLenum; 42 | typedef unsigned char GLboolean; 43 | typedef unsigned int GLbitfield; 44 | typedef void GLvoid; 45 | typedef signed char GLbyte; 46 | typedef short GLshort; 47 | typedef int GLint; 48 | typedef unsigned char GLubyte; 49 | typedef unsigned short GLushort; 50 | typedef unsigned int GLuint; 51 | typedef int GLsizei; 52 | typedef float GLfloat; 53 | typedef float GLclampf; 54 | typedef double GLdouble; 55 | typedef double GLclampd; 56 | typedef char GLchar; 57 | typedef char GLcharARB; 58 | #ifdef __APPLE__ 59 | typedef void *GLhandleARB; 60 | #else 61 | typedef unsigned int GLhandleARB; 62 | #endif 63 | typedef unsigned short GLhalfARB; 64 | typedef unsigned short GLhalf; 65 | typedef GLint GLfixed; 66 | typedef ptrdiff_t GLintptr; 67 | typedef ptrdiff_t GLsizeiptr; 68 | typedef int64_t GLint64; 69 | typedef uint64_t GLuint64; 70 | typedef ptrdiff_t GLintptrARB; 71 | typedef ptrdiff_t GLsizeiptrARB; 72 | typedef int64_t GLint64EXT; 73 | typedef uint64_t GLuint64EXT; 74 | typedef struct __GLsync *GLsync; 75 | #endif /*GL_LOAD_GEN_BASIC_OPENGL_TYPEDEFS*/ 76 | -------------------------------------------------------------------------------- /Source/Include/TinyOBJ/tiny_obj_loader.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2012-2013, Syoyo Fujita. 3 | // 4 | // Licensed under 2-clause BSD liecense. 5 | // 6 | #ifndef _TINY_OBJ_LOADER_H 7 | #define _TINY_OBJ_LOADER_H 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace tinyobj { 14 | 15 | typedef struct 16 | { 17 | std::string name; 18 | 19 | float ambient[3]; 20 | float diffuse[3]; 21 | float specular[3]; 22 | float transmittance[3]; 23 | float emission[3]; 24 | float shininess; 25 | float ior; // index of refraction 26 | float dissolve; // 1 == opaque; 0 == fully transparent 27 | // illumination model (see http://www.fileformat.info/format/material/) 28 | int illum; 29 | 30 | std::string ambient_texname; 31 | std::string diffuse_texname; 32 | std::string specular_texname; 33 | std::string normal_texname; 34 | std::map unknown_parameter; 35 | } material_t; 36 | 37 | typedef struct 38 | { 39 | std::vector positions; 40 | std::vector normals; 41 | std::vector texcoords; 42 | std::vector indices; 43 | } mesh_t; 44 | 45 | typedef struct 46 | { 47 | std::string name; 48 | material_t material; 49 | mesh_t mesh; 50 | } shape_t; 51 | 52 | /// Loads .obj from a file. 53 | /// 'shapes' will be filled with parsed shape data 54 | /// The function returns error string. 55 | /// Returns empty string when loading .obj success. 56 | /// 'mtl_basepath' is optional, and used for base path for .mtl file. 57 | std::string LoadObj( 58 | std::vector& shapes, // [output] 59 | const char* filename, 60 | const char* mtl_basepath = NULL); 61 | 62 | }; 63 | 64 | #endif // _TINY_OBJ_LOADER_H 65 | -------------------------------------------------------------------------------- /Source/Libraries/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zero-radiance/GIGL/1917c51c883bbe0bbd457abcf95aecf89ab05010/Source/Libraries/glfw3.lib -------------------------------------------------------------------------------- /Source/Libraries/glfw3d.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zero-radiance/GIGL/1917c51c883bbe0bbd457abcf95aecf89ab05010/Source/Libraries/glfw3d.lib -------------------------------------------------------------------------------- /Source/RT/PhotonTracer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class PPL; 6 | class VPL; 7 | class Scene; 8 | template class LightArray; 9 | 10 | /* Photon (particle) tracer which fills an array with VPLs */ 11 | namespace rt { 12 | namespace PhotonTracer { 13 | void trace(const Scene& scene, const PPL& source, const glm::vec3& shoot_dir, 14 | const int max_vpl_count, LightArray& la); 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /Source/RT/RTBase.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zero-radiance/GIGL/1917c51c883bbe0bbd457abcf95aecf89ab05010/Source/RT/RTBase.h -------------------------------------------------------------------------------- /Source/Shaders/GBuffer.frag: -------------------------------------------------------------------------------- 1 | #version 440 2 | 3 | #define SQRT_2 1.4142135 4 | 5 | // Vars IN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 6 | 7 | layout (early_fragment_tests) in; // Force early Z-test (prior to FS) 8 | 9 | smooth in vec3 w_pos; // Fragment position in world space 10 | smooth in vec3 w_norm; // Fragment normal in world space 11 | 12 | layout (location = 0) uniform int mat_id; // Material index 13 | 14 | // Vars OUT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 15 | 16 | layout (location = 0) out vec3 w_position; // Position in world space 17 | layout (location = 1) out vec2 w_enc_norm; // Encoded normal in world space 18 | layout (location = 2) out uint material_id; // Material index 19 | 20 | // Implementation >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 21 | 22 | // Lambert's azimuthal equal-area projection 23 | // https://en.wikipedia.org/wiki/Lambert_azimuthal_equal-area_projection 24 | vec2 lambertAzimEAProj(in const vec3 n) { 25 | const float abs_z = abs(n.z); 26 | if (abs_z <= 0.999) { 27 | // Regular case 28 | const float f = SQRT_2 / sqrt(1.0 - n.z); 29 | return f * n.xy; 30 | } else { 31 | // Special case 32 | // (0, 0, 1) and (0, 0, -1) both map to (0, 0) 33 | const float sgn_1 = n.z / abs_z; 34 | return sgn_1 * vec2(2.0, -1.0); 35 | } 36 | } 37 | 38 | void main() { 39 | w_position = w_pos; 40 | w_enc_norm = lambertAzimEAProj(w_norm); 41 | material_id = mat_id; 42 | } 43 | -------------------------------------------------------------------------------- /Source/Shaders/GBuffer.vert: -------------------------------------------------------------------------------- 1 | #version 440 2 | 3 | // Vars IN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4 | 5 | layout (location = 0) in vec3 vert_m_pos; // Vertex position in model coordinates 6 | layout (location = 1) in vec3 vert_m_norm; // Vertex normal in model coordinates 7 | 8 | uniform mat4 model_mat; // Model-to-world space transformation matrix 9 | uniform mat4 MVP; // Model-to-clip (homogeneous) space transformation matrix 10 | uniform mat3 norm_mat; // Model-to-camera space normal vector transformation matrix 11 | 12 | // Vars OUT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 13 | 14 | smooth out vec3 w_pos; // Position in world space 15 | smooth out vec3 w_norm; // Normal in camera space 16 | 17 | // Implementation >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 18 | 19 | void main() { 20 | const vec4 vert_m_pos4 = vec4(vert_m_pos, 1.0); 21 | // Transform vertex position and normal to world space 22 | w_pos = (model_mat * vert_m_pos4).xyz; 23 | w_norm = normalize(norm_mat * vert_m_norm); 24 | // Transform vertex position to clip coordinates 25 | gl_Position = MVP * vert_m_pos4; 26 | } 27 | -------------------------------------------------------------------------------- /Source/Shaders/Shade.vert: -------------------------------------------------------------------------------- 1 | #version 440 2 | 3 | // Vars IN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4 | 5 | layout (location = 0) in vec3 position; // Vertex position 6 | 7 | // Implementation >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 8 | 9 | void main() { 10 | gl_Position = vec4(position, 1.0); 11 | } 12 | -------------------------------------------------------------------------------- /Source/Shaders/Shadow.frag: -------------------------------------------------------------------------------- 1 | #version 440 2 | 3 | // Vars IN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4 | 5 | smooth in vec3 w_pos; // Fragment position in world coords 6 | 7 | layout (location = 8) uniform vec3 light_w_pos; // Light position in world coords 8 | layout (location = 9) uniform float inv_max_dist_sq; // Inverse max distance squared 9 | 10 | // Implementation >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 11 | 12 | void main() { 13 | // Compute vector from light to fragment 14 | const vec3 light_to_frag = w_pos - light_w_pos; 15 | // Compute distance squared 16 | const float dist_sq = dot(light_to_frag, light_to_frag); 17 | // Normalize it s.t. it lies on [0, 1] 18 | const float norm_dist_sq = dist_sq * inv_max_dist_sq; 19 | gl_FragDepth = norm_dist_sq; 20 | } 21 | -------------------------------------------------------------------------------- /Source/Shaders/Shadow.geom: -------------------------------------------------------------------------------- 1 | #version 440 2 | 3 | // Vars IN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4 | 5 | layout (triangles) in; 6 | 7 | layout (location = 1) uniform mat4 light_MVP[6]; // Model-view-projection matrix; locs 1..6 8 | layout (location = 7) uniform int layer_id; // Layer index within cubemap array 9 | 10 | // Vars OUT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 11 | 12 | smooth out vec3 w_pos; // Vertex position in world coords 13 | 14 | layout(triangle_strip, max_vertices = 18) out; // 3 triangle vertices x 6 cubemap faces 15 | 16 | // Implementation >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 17 | 18 | void main() { 19 | // Iterate over 6 cubemap faces 20 | for(int f = 0; f < 6; ++f) { 21 | for(int tri_vidx = 0; tri_vidx < 3; ++tri_vidx) { 22 | gl_Layer = layer_id + f; 23 | const vec4 w_pos4 = gl_in[tri_vidx].gl_Position; 24 | w_pos = w_pos4.xyz; 25 | gl_Position = light_MVP[f] * w_pos4; 26 | EmitVertex(); 27 | } 28 | EndPrimitive(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Source/Shaders/Shadow.vert: -------------------------------------------------------------------------------- 1 | #version 440 2 | 3 | // Vars IN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 4 | 5 | layout (location = 0) in vec3 vert_m_pos; // Vertex position in model coords 6 | 7 | layout (location = 0) uniform mat4 model_mat; // Model to world coords transformation matrix 8 | 9 | // Vars IN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 10 | 11 | void main() { 12 | // Transform model coordinates to world coordinates 13 | gl_Position = model_mat * vec4(vert_m_pos, 1.0); 14 | } 15 | -------------------------------------------------------------------------------- /Source/UI/InputHandler.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "..\Common\Definitions.h" 4 | 5 | struct GLFWwindow; 6 | struct RenderSettings; 7 | 8 | /* Static class handling user HID input */ 9 | class InputHandler { 10 | public: 11 | InputHandler() = delete; 12 | RULE_OF_ZERO(InputHandler); 13 | // Aquires and initializes (resets) all controlled parameters 14 | static void init(RenderSettings* params); 15 | // Adjusts parameters based on HID input 16 | static void updateParams(GLFWwindow* const wnd); 17 | private: 18 | // Handle toggling options on/off 19 | static void handleToggles(GLFWwindow* const wnd); 20 | // Handle input like motion controls and parameter adjustment 21 | static void handleSmoothInput(GLFWwindow* const wnd); 22 | // Resets all status to defaults 23 | static void reset(); 24 | // Updates last toggle time 25 | static void updateLastTime(); 26 | // Resets current frame number to 0 27 | static void resetFrameCount(); 28 | // Private data members 29 | static RenderSettings* m_params; // Controlled parameters 30 | static uint m_last_time_ms; // Number of milliseconds since timer reset (last toggle) 31 | }; 32 | -------------------------------------------------------------------------------- /Source/UI/Window.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "..\Common\Definitions.h" 5 | 6 | struct GLFWwindow; 7 | 8 | /* Class wrapping around GLFW window */ 9 | class Window { 10 | public: 11 | Window() = delete; 12 | RULE_OF_FIVE_NO_COPY(Window); 13 | // Constructs a window with specified resolution 14 | explicit Window(const int res_x, const int res_y); 15 | // Returns true if window has been opened successfully 16 | const bool isOpen() const; 17 | // Returns true if closing sequence has been triggered 18 | bool shouldClose() const; 19 | // Refreshes image, swaps buffers 20 | void refresh(); 21 | // Sets window title to a specified string 22 | void setTitle(const char* const title); 23 | // Returns a pointer to GLFWwindow 24 | GLFWwindow* get() const; 25 | private: 26 | // Performs window destruction 27 | void destroy(); 28 | // Private data members 29 | GLFWwindow* m_window; // Pointer to GLFW window 30 | GLsizei m_res_x, m_res_y; // Resolution in x, y 31 | GLuint m_tex_handle; // OpenGL accumulation texture handle 32 | bool m_is_ok; // Status 33 | }; 34 | -------------------------------------------------------------------------------- /Source/VPL/LightArray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "..\GL\GLPersistentBuffer.h" 4 | 5 | /* Array of Point Lights */ 6 | template 7 | class LightArray { 8 | public: 9 | LightArray() = delete; 10 | RULE_OF_ZERO(LightArray); 11 | // Constructs a light array capable of storing max_n_lights (active) lights 12 | LightArray(const int max_n_lights); 13 | // Returns size of PL array 14 | int size() const; 15 | // Returns a mutable PL reference from array 16 | PL& operator[](const int index); 17 | // Returns a const PL reference from array 18 | const PL& operator[](const int index) const; 19 | // Resets the size of the array, effectively clearing it 20 | void clear(); 21 | // Returns true if array contains 0 lights 22 | bool isEmpty() const; 23 | // Adds a single PL to array 24 | void addLight(const PL& pl); 25 | // Normalizes intensity by (1 / n_paths) 26 | void normalizeIntensity(const int n_paths); 27 | // Binds uniform buffer object to to uniform buffer binding point 28 | void bind(const GLuint bind_idx) const; 29 | // Activates the next buffer in ring-triple-buffer 30 | void switchToNextBuffer(); 31 | private: 32 | // Returns the pointer to the light buffer 33 | PL* data(); 34 | // Returns the pointer to the light buffer (read-only) 35 | const PL* data() const; 36 | // Private data members 37 | GLPUB140 m_ubo; // OpenGL persistent uniform buffer object 38 | int m_capacity; // Total buffer capacity (max. possible number of active lights) 39 | int m_sz; // Numer of stored (active) lights 40 | int m_offset; // Offset to the beginning of the current buffer 41 | }; 42 | -------------------------------------------------------------------------------- /Source/VPL/LightArray.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "LightArray.h" 4 | #include 5 | #include "..\GL\GLPersistentBuffer.hpp" 6 | 7 | template 8 | LightArray::LightArray(const int max_n_vpls): m_ubo{3 * max_n_vpls * sizeof(PL)}, 9 | m_capacity{max_n_vpls}, m_sz{0}, m_offset{0} {} 10 | 11 | template 12 | int LightArray::size() const { 13 | return m_sz; 14 | } 15 | 16 | template 17 | PL& LightArray::operator[](const int index) { 18 | assert(index < m_sz); 19 | PL* const pls{data()}; 20 | return pls[index]; 21 | } 22 | 23 | template 24 | const PL& LightArray::operator[](const int index) const { 25 | assert(index < m_sz); 26 | const PL* const pls{data()}; 27 | return pls[index]; 28 | } 29 | 30 | template 31 | void LightArray::clear() { 32 | m_sz = 0; 33 | } 34 | 35 | template 36 | bool LightArray::isEmpty() const { 37 | return (0 == m_sz); 38 | } 39 | 40 | template 41 | void LightArray::addLight(const PL& pl) { 42 | PL* pls{data()}; 43 | pls[m_sz++] = pl; 44 | } 45 | 46 | template 47 | void LightArray::normalizeIntensity(const int n_paths) { 48 | assert(m_sz > 0); 49 | const float inv_n_paths{1.0f / n_paths}; 50 | PL* pls{data()}; 51 | // Remove gaps in path indices 52 | uint old_path_id{pls[0].m_path_id}; 53 | uint new_path_id{0}; 54 | for (int i = 0; i < m_sz; ++i) { 55 | if (old_path_id == pls[i].m_path_id) { 56 | // Same path 57 | pls[i].m_path_id = new_path_id; 58 | } else { 59 | // New path started 60 | old_path_id = pls[i].m_path_id; 61 | pls[i].m_path_id = ++new_path_id; 62 | } 63 | // Normalize 64 | pls[i].m_intensity *= inv_n_paths; 65 | } 66 | } 67 | 68 | template 69 | void LightArray::bind(const GLuint bind_idx) const { 70 | m_ubo.bind(bind_idx); 71 | } 72 | 73 | template 74 | void LightArray::switchToNextBuffer() { 75 | m_offset = (m_offset + m_capacity) % (3 * m_capacity); 76 | } 77 | 78 | template 79 | PL* LightArray::data() { 80 | PL* data_ptr{static_cast(m_ubo.data())}; 81 | // Apply the offset 82 | return data_ptr + m_offset; 83 | } 84 | 85 | template 86 | const PL* LightArray::data() const { 87 | const PL* data_ptr{static_cast(m_ubo.data())}; 88 | // Apply the offset 89 | return data_ptr + m_offset; 90 | } 91 | -------------------------------------------------------------------------------- /Source/VPL/OmniShadowMap.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "..\Common\Definitions.h" 7 | 8 | class Scene; 9 | template class LightArray; 10 | 11 | class OmniShadowMap { 12 | public: 13 | OmniShadowMap() = delete; 14 | RULE_OF_FIVE(OmniShadowMap); 15 | // Constructor 16 | // res: shadow map map texture resolution: res x res 17 | // max_vpls: maximal number of Virtual Point Lights 18 | // max_dist: maximal distance at which shadow is still being cast 19 | // tex_unit: OpenGL texture unit id 20 | OmniShadowMap(const GLsizei res, const GLsizei max_vpls, const float max_dist, 21 | const int tex_unit); 22 | // Runs a rendering pass to generate shadow map 23 | template 24 | void generate(const Scene& scene, const LightArray& la, const glm::mat4& model_mat) const; 25 | private: 26 | // Creates a cubemap array depth texture 27 | void createDepthTexture(); 28 | // Creates a framebuffer for depth map rendering 29 | void createFramebuffer(); 30 | // Private data members 31 | std::array m_view_proj; // Projection * View matrices, 1 for each face 32 | int m_tex_unit; // OpenGL texture unit id 33 | GLsizei m_res; // Shadow map texture resolution: res x res 34 | GLsizei m_max_vpls; // Maximal number of Virtual Point Lights 35 | float m_inv_max_dist_sq; // Inverse max. [shadow] distance squared 36 | GLuint m_fbo_handle; // OpenGL frame buffer object handle 37 | GLuint m_cube_tex_handle; // OpenGL cubemap array texture handle 38 | }; 39 | -------------------------------------------------------------------------------- /Source/VPL/OmniShadowMap.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "OmniShadowMap.h" 4 | #include 5 | #include "..\Common\Scene.h" 6 | #include "LightArray.hpp" 7 | 8 | template 9 | void OmniShadowMap::generate(const Scene& scene, const LightArray& la, 10 | const glm::mat4& model_mat) const { 11 | // Set non-light-specific parameters 12 | gl::BindFramebuffer(gl::FRAMEBUFFER, m_fbo_handle); 13 | gl::Clear(gl::DEPTH_BUFFER_BIT); 14 | gl::Viewport(0, 0, m_res, m_res); 15 | gl::UniformMatrix4fv(UL_SM_MODELMAT, 1, GL_FALSE, &model_mat[0][0]); 16 | gl::Uniform1f(UL_SM_INVMAXD2, m_inv_max_dist_sq); 17 | assert(la.size() <= m_max_vpls); 18 | const GLsizei n{la.size()}; 19 | for (GLsizei i = 0; i < n; ++i) { 20 | const glm::vec3& light_w_pos{la[i].wPos()}; 21 | const glm::mat4 light_inv_trans{glm::translate(glm::mat4{1.0f}, -light_w_pos)}; 22 | // Set light source position 23 | gl::Uniform3f(UL_SM_WPOS_VPL, light_w_pos.x, light_w_pos.y, light_w_pos.z); 24 | // Set light transformation matrix 25 | const glm::mat4 lightMVPs[6] = {{m_view_proj[0] * light_inv_trans}, 26 | {m_view_proj[1] * light_inv_trans}, 27 | {m_view_proj[2] * light_inv_trans}, 28 | {m_view_proj[3] * light_inv_trans}, 29 | {m_view_proj[4] * light_inv_trans}, 30 | {m_view_proj[5] * light_inv_trans}}; 31 | gl::UniformMatrix4fv(UL_SM_LIGHTMVP, 6, GL_FALSE, &lightMVPs[0][0][0]); 32 | // Set layer index 33 | gl::Uniform1i(UL_SM_LAYER_ID, 6 * i); 34 | // Render scene to depth map 35 | scene.render(true); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/VPL/PointLight.cpp: -------------------------------------------------------------------------------- 1 | #include "PointLight.h" 2 | 3 | PPL::PPL(const glm::vec3& w_pos, const glm::vec3& intensity): m_w_pos{w_pos}, m_type{0}, 4 | m_intensity{intensity} {} 5 | 6 | 7 | const glm::vec3& PPL::getWPos() const { 8 | return m_w_pos; 9 | } 10 | 11 | const glm::vec3& PPL::getIntensity() const { 12 | return m_intensity; 13 | } 14 | 15 | VPL::VPL(const uint path_id, const glm::vec3& w_pos, const glm::vec3& w_inc, const glm::vec3& intensity, 16 | const float sca_k): m_w_pos{w_pos}, m_type{1}, m_intensity{intensity}, m_sca_k{sca_k}, 17 | m_w_inc{w_inc}, m_path_id{path_id} {} 18 | 19 | VPL::VPL(const uint path_id, const glm::vec3& w_pos, const glm::vec3& w_inc, const glm::vec3& intensity, 20 | const glm::vec3& w_norm, const glm::vec3& k_d, const glm::vec3& k_s, const float n_s): 21 | m_w_pos{w_pos + 1E-4f * w_norm}, m_type{2}, m_intensity{intensity}, m_w_inc{w_inc}, 22 | m_path_id{path_id}, m_w_norm{w_norm}, m_k_d{k_d}, m_k_s{k_s}, m_n_s{n_s} {} 23 | 24 | const glm::vec3& VPL::getWPos() const { 25 | return m_w_pos; 26 | } 27 | 28 | const glm::vec3& VPL::getIntensity() const { 29 | return m_intensity; 30 | } 31 | -------------------------------------------------------------------------------- /Source/VPL/PointLight.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "PointLight.h" 4 | 5 | template 6 | const glm::vec3& PointLight::wPos() const { 7 | return static_cast(this)->getWPos(); 8 | } 9 | 10 | template 11 | const glm::vec3& PointLight::intensity() const { 12 | return static_cast(this)->getIntensity(); 13 | } 14 | 15 | template 16 | const void PointLight::setWPos(const glm::vec3& w_pos) { 17 | static_cast(this)->m_w_pos = w_pos; 18 | } 19 | 20 | template 21 | const void PointLight::setIntensity(const glm::vec3& intensity) { 22 | static_cast(this)->m_intensity = intensity; 23 | } 24 | --------------------------------------------------------------------------------