diff --git a/glm/common.hpp b/glm/common.hpp index 5ad29013..efce346a 100644 --- a/glm/common.hpp +++ b/glm/common.hpp @@ -6,9 +6,9 @@ /// @defgroup core_func_common Common functions /// @ingroup core /// -/// Include to use these core features. -/// /// These all operate component-wise. The description is per component. +/// +/// Include to use these core features. #pragma once diff --git a/glm/integer.hpp b/glm/integer.hpp index 5165ef96..450809bc 100644 --- a/glm/integer.hpp +++ b/glm/integer.hpp @@ -6,11 +6,11 @@ /// @defgroup core_func_integer Integer functions /// @ingroup core /// -/// Include to use these core features. -/// /// These all operate component-wise. The description is per component. /// The notation [a, b] means the set of bits from bit-number a through bit-number /// b, inclusive. The lowest-order bit is bit 0. +/// +/// Include to use these core features. #pragma once diff --git a/glm/matrix.hpp b/glm/matrix.hpp index aec0af4e..fb7efce2 100644 --- a/glm/matrix.hpp +++ b/glm/matrix.hpp @@ -6,13 +6,13 @@ /// @defgroup core_func_matrix Matrix functions /// @ingroup core /// -/// Include to use these core features. -/// /// For each of the following built-in matrix functions, there is both a /// single-qualifier floating point version, where all arguments and return values /// are single qualifier, and a double-qualifier floating version, where all /// arguments and return values are double qualifier. Only the single-qualifier /// floating point version is shown. +/// +/// Include to use these core features. #pragma once diff --git a/glm/packing.hpp b/glm/packing.hpp index a01a5837..d493ff9d 100644 --- a/glm/packing.hpp +++ b/glm/packing.hpp @@ -7,9 +7,9 @@ /// @defgroup core_func_packing Floating-Point Pack and Unpack Functions /// @ingroup core /// -/// Include to use these core features. -/// /// These functions do not operate component-wise, rather as described in each case. +/// +/// Include to use these core features. #pragma once diff --git a/manual.md b/manual.md index de21bbbf..6bec245b 100644 --- a/manual.md +++ b/manual.md @@ -463,7 +463,7 @@ Additionally, GLM provides a low level SIMD API in glm/simd directory for users C++ does not provide a way to implement GLSL default precision selection (as defined in GLSL 4.10 specification section 4.5.3) with GLSL-like syntax. -```cpp +```glsl precision mediump int; precision highp float; ``` @@ -508,7 +508,7 @@ Some platforms (Dreamcast) doesn't support double precision floating point value Shader languages like GLSL often feature so-called swizzle expressions, which may be used to freely select and arrange a vector's components. For example, `variable.x`, `variable.xzy` and `variable.zxyy` respectively form a scalar, a 3D vector and a 4D vector. The result of a swizzle expression in GLSL can be either an R-value or an L-value. Swizzle expressions can be written with characters from exactly one of `xyzw` (usually for positions), `rgba` (usually for colors), and `stpq` (usually for texture coordinates). -```cpp +```glsl vec4 A; vec2 B; @@ -700,6 +700,19 @@ Include `` to use these features. This extension exposes sized and unsigned integer types. +```cpp +#include + +glm::uint64 pack(glm::uint32 A, glm::uint16 B, glm::uint8 C, glm::uint8 D) +{ + glm::uint64 ShiftA = 0; + glm::uint64 ShiftB = sizeof(glm::uint32) * 8; + glm::uint64 ShiftC = (sizeof(glm::uint32) + sizeof(glm::uint16)) * 8; + glm::uint64 ShiftD = (sizeof(glm::uint32) + sizeof(glm::uint16) + sizeof(glm::uint8)) * 8; + return (glm::uint64(A) << ShiftA) | (glm::uint64(B) << ShiftB) | (glm::uint64(C) << ShiftC) | (glm::uint64(D) << ShiftD); +} +``` + Include `` to use these features. ### 3.2. Scalar functions @@ -850,17 +863,44 @@ Include `` to use these features. #### 3.6.2. GLM_EXT_matrix_transform -TODO +This extension exposes matrix transformation functions: `translate`, `rotate` and `scale`. + +```cpp +#include // vec2 +#include // vec3 +#include // mat4x4 +#include // translate, rotate, scale, identity + +glm::mat4 computeModelViewMatrix(float Translate, glm::vec2 const & Rotate) +{ + glm::mat4 View = glm::translate(glm::identity(), glm::vec3(0.0f, 0.0f, -Translate)); + View = glm::rotate(View, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f)); + View = glm::rotate(View, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f)); + glm::mat4 Model = glm::scale(glm::identity(), glm::vec3(0.5f)); + return View * Model; +} +``` Include `` to use these features. -#### 3.6.3. GLM_EXT_matrix_clip_space +#### 3.6.4. GLM_EXT_matrix_clip_space -TODO +This extension exposes functions to transform scenes into the clip space. + +```cpp +#include // mat4x4 +#include // perspective +#include // radians + +glm::mat4 computeProjection(float Width, float Height) +{ + return glm::perspective(glm::radians(45.0f), Width / Height, 0.1f, 100.f); +} +``` Include `` to use these features. -#### 3.6.4. GLM_EXT_matrix_projection +#### 3.6.3. GLM_EXT_matrix_projection TODO