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/dummy.cpp 25/// @date 2011-01-19 / 2011-06-15 26/// @author Christophe Riccio 27/// 28/// GLM is a header only library. There is nothing to compile. 29/// dummy.cpp exist only a wordaround for CMake file. 30/////////////////////////////////////////////////////////////////////////////////// 31 32#define GLM_FORCE_RADIANS 33#define GLM_MESSAGES 34#include "../glm.hpp" 35#include <limits> 36 37struct material 38{ 39 glm::vec4 emission; // Ecm 40 glm::vec4 ambient; // Acm 41 glm::vec4 diffuse; // Dcm 42 glm::vec4 specular; // Scm 43 float shininess; // Srm 44}; 45struct light 46{ 47 glm::vec4 ambient; // Acli 48 glm::vec4 diffuse; // Dcli 49 glm::vec4 specular; // Scli 50 glm::vec4 position; // Ppli 51 glm::vec4 halfVector; // Derived: Hi 52 glm::vec3 spotDirection; // Sdli 53 float spotExponent; // Srli 54 float spotCutoff; // Crli 55 // (range: [0.0,90.0], 180.0) 56 float spotCosCutoff; // Derived: cos(Crli) 57 // (range: [1.0,0.0],-1.0) 58 float constantAttenuation; // K0 59 float linearAttenuation; // K1 60 float quadraticAttenuation;// K2 61}; 62 63// Sample 1 64#include <glm/vec3.hpp>// glm::vec3 65#include <glm/geometric.hpp>// glm::cross, glm::normalize 66 67glm::vec3 computeNormal 68( 69 glm::vec3 const & a, 70 glm::vec3 const & b, 71 glm::vec3 const & c 72) 73{ 74 return glm::normalize(glm::cross(c - a, b - a)); 75} 76 77typedef unsigned int GLuint; 78#define GL_FALSE 0 79void glUniformMatrix4fv(GLuint, int, int, float*){} 80 81// Sample 2 82#include <glm/vec3.hpp> // glm::vec3 83#include <glm/vec4.hpp> // glm::vec4, glm::ivec4 84#include <glm/mat4x4.hpp> // glm::mat4 85#include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale, glm::perspective 86#include <glm/gtc/type_ptr.hpp> // glm::value_ptr 87void func(GLuint LocationMVP, float Translate, glm::vec2 const & Rotate) 88{ 89 glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f); 90 glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate)); 91 glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f)); 92 glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f)); 93 glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f)); 94 glm::mat4 MVP = Projection * View * Model; 95 glUniformMatrix4fv(LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP)); 96} 97 98// Sample 3 99#include <glm/vec2.hpp>// glm::vec2 100#include <glm/packing.hpp>// glm::packUnorm2x16 101#include <glm/integer.hpp>// glm::uint 102#include <glm/gtc/type_precision.hpp>// glm::i8vec2, glm::i32vec2 103std::size_t const VertexCount = 4; 104// Float quad geometry 105std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2); 106glm::vec2 const PositionDataF32[VertexCount] = 107{ 108 glm::vec2(-1.0f,-1.0f), 109 glm::vec2( 1.0f,-1.0f), 110 glm::vec2( 1.0f, 1.0f), 111 glm::vec2(-1.0f, 1.0f) 112 }; 113// Half-float quad geometry 114std::size_t const PositionSizeF16 = VertexCount * sizeof(glm::uint); 115glm::uint const PositionDataF16[VertexCount] = 116{ 117 glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, -1.0f))), 118 glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, -1.0f))), 119 glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, 1.0f))), 120 glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, 1.0f))) 121}; 122// 8 bits signed integer quad geometry 123std::size_t const PositionSizeI8 = VertexCount * sizeof(glm::i8vec2); 124glm::i8vec2 const PositionDataI8[VertexCount] = 125{ 126 glm::i8vec2(-1,-1), 127 glm::i8vec2( 1,-1), 128 glm::i8vec2( 1, 1), 129 glm::i8vec2(-1, 1) 130}; 131// 32 bits signed integer quad geometry 132std::size_t const PositionSizeI32 = VertexCount * sizeof(glm::i32vec2); 133glm::i32vec2 const PositionDataI32[VertexCount] = 134{ 135 glm::i32vec2 (-1,-1), 136 glm::i32vec2 ( 1,-1), 137 glm::i32vec2 ( 1, 1), 138 glm::i32vec2 (-1, 1) 139}; 140 141struct intersection 142{ 143 glm::vec4 position; 144 glm::vec3 normal; 145}; 146 147/* 148// Sample 4 149#include <glm/vec3.hpp>// glm::vec3 150#include <glm/geometric.hpp>// glm::normalize, glm::dot, glm::reflect 151#include <glm/exponential.hpp>// glm::pow 152#include <glm/gtc/random.hpp>// glm::vecRand3 153glm::vec3 lighting 154( 155 intersection const & Intersection, 156 material const & Material, 157 light const & Light, 158 glm::vec3 const & View 159) 160{ 161 glm::vec3 Color(0.0f); 162 glm::vec3 LightVertor(glm::normalize( 163 Light.position - Intersection.position + 164 glm::vecRand3(0.0f, Light.inaccuracy)); 165 166 if(!shadow(Intersection.position, Light.position, LightVertor)) 167 { 168 float Diffuse = glm::dot(Intersection.normal, LightVector); 169 if(Diffuse <= 0.0f) 170 return Color; 171 if(Material.isDiffuse()) 172 Color += Light.color() * Material.diffuse * Diffuse; 173 if(Material.isSpecular()) 174 { 175 glm::vec3 Reflect(glm::reflect( 176 glm::normalize(-LightVector), 177 glm::normalize(Intersection.normal))); 178 float Dot = glm::dot(Reflect, View); 179 float Base = Dot > 0.0f ? Dot : 0.0f; 180 float Specular = glm::pow(Base, Material.exponent); 181 Color += Material.specular * Specular; 182 } 183 } 184 return Color; 185} 186*/ 187int main() 188{ 189 return 0; 190} 191