Euler angles operation with specified rotation order Cast to other toolkit (D3D, some engines) Arrays SIMD optimisations Standard output stream In place operations More tests. Arrays. SIMD optimizations. In place operations. RGBE. row matrices. fixed numbers row and column major matrices Bug fixes Only for GLM 0.9.1.2. GLM 0.9.1.2 (zip) GLM 0.9.1.2 (7z) Submit a bug report GLM 0.9.1.1 fixes some bugs, warnings on Clang C++ and clean up a bit the code. If you have uncounter any issue with GLM 0.9.1.0, please download this revision. Finally, the work has started for GLM 0.9.2 so if you have requests don't forget to submit them! GLM 0.9.1.1 (zip) GLM 0.9.1.1 (7z) Submit a bug report Finally, GLM 0.9.1 branch is reaching the status of stable with GLM 0.9.1.0. From GLM 0.9.1 beta, mainly bugs has been fixed. GLM has evolved on many sides since GLM 0.9.0: Improved documentation (manual and doxygen), better test framework, simplified setup/options/configration of GLM and new experimental SIMD API. GLM 0.9.1.0 is not 100% backward compatile with GLM 0.9.0.8 but mainly advanced usages should be affected by the differencies. Have a look at the GLM manual for more information on how to use GLM 0.9.1. GLM 0.9.1.0 (zip) GLM 0.9.1.0 (7z) GLM 0.9.1 manual Submit a bug report The stable version, GLM 0.9.0.8, adds the operator * for quaternion products and deprecated the cross function previously used for the same purpose. Also, it clarifies that GLM is a header only library when a user try to build it. Once more, there is nothing to build. The development version, GLM 0.9.1 beta, provides an improved API documentation by Alfonse Reinheart, author of a great OpenGL tutorial which uses GLM. This version also improves the SIMD extensions and it fixes many bugs. GLM 0.9.1.B (zip) GLM 0.9.1.B (7z) GLM 0.9.1 manual GLM 0.9.0.8 (zip) GLM 0.9.0.8 (7z) GLM 0.9.0 manual Submit a bug report This new version of GLM is bringing a lot of improvements and maybe too many considering the development time it has required: API exposing SIMD implementation but also some new, safe and feature complet swizzling functions and a new setup API. All this is described in the largely updated GLM manual. With the new setup system, GLM detects automatically the compiler settings to adapt its implementation to the flag set at build time. It will automatically enable C++0x features, SSE optimizations and the display configuration informations at build-time. The automatic setup can be overdrive by the GLM user. The SIMD API maintly focus on vec4 and mat4 implementations that are embodied by the types simdVec4 and simdMat4. The implemention cover most of the common functions, the geometry functions and the matrix functions as described in the GLSL specifications. Because it is hight inefficient to access individual components of a SIMD register, the simdVec4 doesn't allow it. To reflect this constraint, the simdVec4 has to be converted to vec4 first which would be effectively handle by the compiler thank to the function simdCast. Furthermore, GLM provides some specials functions like simdDot4 that returns a simdVec4 instead of a float with the duplicated dot product value in each components and ensure that no unnecessary component manipulations are performed (typically __m128 to float and float to __m128). This implementation can probably be improve in many ways so don't hesitate to send me some feedbacks. GLM 0.9.1 is not 100% backward compatible with GLM 0.9.0 but mostly advanced usages should be concerned by this compatibility issues. GLM 0.9.1.A (zip, 2.7 MB) GLM 0.9.1.A (7z, 1.7 MB) GLM 0.9.0.7 provides 2 main changes: GLSL 4.10 packing functions but also == and != operators for every types. GLM 0.9.0.7 (zip, 1.4 MB) GLM 0.9.0.7 (7z, 832 KB) Submit a bug report GLM 0.9.0.6 is a new update of GLM built over GLM's user bug reports. It mainly fixes issues regarding non-squared matrices but also provides multiple extensions corrections as well. I expect to release GLM 0.9.1.0 in Junuary but I might continue to update GLM 0.9.0.X as there are minor incompatibilities. GLM 0.9.0.6 (zip, 2.2 MB) GLM 0.9.0.6 (7z, 1.6 MB) Submit a bug report GLM 0.9.0.5 fixes the usual set of bugs, some allowing a better Clang support. GLM 0.9.0.5 (zip, 2.2 MB) GLM 0.9.0.5 (7z, 1.6 MB) Submit a bug report GLM 0.9.0.4 revision mainly fixes bugs. It also contains a contribution by Arnaud Masserann, a autoexp.dat file to make GLM looks nicer in Visual Studio debugger. To take advantage of this file, edit ${VISUALSTUDIO_DIRECTORY}/common7/packages/debugger/autoexp.dat file and add the content of the file util/autoexp.txt included in GLM 0.9.0.4. GLM 0.9.0.4 (zip, 1.5 MB) GLM 0.9.0.4 (7z, 1.2 MB) Submit a bug report GLM 0.9.0.3 fixes major issues on non-squared matrices. GLM 0.9.0.3 (zip, 1.2 MB) GLM 0.9.0.3 (7z, 684 KB) Submit a bug report Second update of GLM 0.9.0 with more bug fixes. It also contains a new extension called GLM_GTX_int_10_10_10_2 to use GLM with OpenGL and GL_ARB_vertex_type_2_10_10_10_rev. GLM 0.9.0.2 (zip, 809 KB) GLM 0.9.0.2 (7z, 651 KB) Submit a bug report This revision only fixes few extensions bugs. GLM 0.9.0.1 (zip, 714 KB) GLM 0.9.0.1 (7z, 556 KB) Submit a bug report GLM 0.9.0.0 is finally available! It brings various API changes from GLM 0.8.4.X branch which makes it not backward compatible. GLM is now compatible with Objective C++ to be used for MacOS X and iPhone projects. To continue making GLM a better library, 2 mailing lists have been created for users and developers. GLM 0.9.0.0 (zip, 1.0 MB) GLM 0.9.0.0 (7z, 514 KB) Register to GLM mailing list for users Register to GLM mailing list for developers Submit a bug report GLM 0.9 Beta 2 is available and should be the last development release of GLM 0.9. The code has been moved from a SVN to Git repository which branching efficiency allowed to remove all the experimental code from this release. Various bug fixes and manual updates have been done too. GLM 0.9.B.2 (zip, 1.07 MB) GLM 0.9.B.2 (7z, 555 KB) A new development version of GLM 0.9 is available. This version is based on GLSL 4.0 and supports the new common and integer functions. Also a long and frequently asked feature has been implemented: inplicit conversions. However, the rules defining implicit conversions by GLSL 4.0 are quite weaked and can't really be apply in C++. Reaching the beta status, this new features close the feature list of GLM 0.9. Further development releases may happen before the final release. GLM 0.9.B.1 (zip, 964 KB) GLM 0.9.B.1 (7z, 414 KB) Groove This update fixes some problem of Alpha 1 but also brings some improvements in case of errors when using GLM to provide more relevant messages. GLM 0.9.A.2 (zip, 1.3 MB) GLM 0.9.A.2 (7z, 726 KB) Groove First step until a major release for GLM with this first alpha of GLM 0.9. This version brings a large internal redesign to improve the library reliability and optimized some parts. It removed the deprecated features and API which implies that GLM 0.9 isn't backward compatible. For most users the build issues when upgrading to GLM 0.9 should be reduced especially if they follow the deprecation policy. This release is still UNSTABLE and not recommanded for commertial products. GLM 0.9.A.1 (zip, 950 KB) GLM 0.9.A.1 (7z, 391 KB) Full changelog Groove This update just removes some warnings By the way, if you have questions about GLM, a good place for those is the OpenGL.org Toolkits forum. GLM 0.8.4.4 (zip, 1.1 MB) GLM 0.8.4.4 (7z, 479 KB) Full changelog Groove This version fixed half scalars and half vectors arithmetics. This is a really slow practice that should be avoid. Half floating point value should be use only to store GPU data. GPUs have native support for half values, not x86 CPUs. GLM 0.8.4.3 (zip, 1.1 MB) GLM 0.8.4.3 (7z, 463 KB) Full changelog Groove This version is a really minor updates, fixing single issue with half float types. GLM 0.8.4.2 (zip, 1.1 MB) GLM 0.8.4.2 (7z, 443 KB) Full changelog Groove This version fixes few bugs and provides an major update of the manual thanks to Damian Trebilco. GLM 0.8.4.1 (zip, 1.1 MB) GLM 0.8.4.1 (7z, 443 KB) Full changelog Groove This new version mainly adds support for Visual Studio 2010 and GCC 4.4. It also provides various code optimization, bug fixes and an extension. GLM 0.8.4.0 (zip, 1.1 MB) GLM 0.8.4.0 (7z, 439 KB) Full changelog Groove Fixed extension bugs introduced by core update. GLM 0.8.3.5 (zip, 971 KB) GLM 0.8.3.5 (7z, 405 KB) Full changelog Groove Fixed varius bugs. Move determinant fonction to core following GLSL 1.5 specification. GLM 0.8.3.4 (zip, 971 KB) GLM 0.8.3.4 (7z, 405 KB) Full changelog Groove Fixed varius bugs. GLM 0.8.3.3 (zip, 971 KB) GLM 0.8.3.3 (7z, 405 KB) Full changelog Groove Add GLM_GTC_quaternion and GLM_GTC_type_precision extensions both subset of GLM_GTX_quaternion and GLM_GTX_number_precision GLM 0.8.3.2 (zip, 971 KB) GLM 0.8.3.2 (7z, 405 KB) Full changelog Groove The old way to use extensions have been fixed and GLM_GTX_bit extension gets updated with more functions to manipulate bit fields. GLM 0.8.3.1 (zip, 954 KB) GLM 0.8.3.1 (7z, 402 KB) Full changelog Groove This version brings to main changed: Stable extensions and a new extension system. The first stable GLM extensions are: GLM_GTC_double_float and GLM_GTC_half_float for higher and lower vectors and matrices floating point precision. GLM_GTC_matrix_operation provides determinant and inverse matrix calculation. GLM_GTC_matrix_transform allows to build scale, rotate and translate matrices and GLM_GTC_matrix_projection provides varius functions to build projection matrices. Few stable extensions yet but the number is going to grow with the next release! Both GLM 0.8.2.x extensions use method are deprecated (but still working) and replace by a new one. If you wnat to use GLM_GTC_half_float just include "glm/gtc/half_float.hpp" and it is going to be included in GLM namespace. Finally, quite some file have been renamed, using "hpp" instead of ".h". Old file have been deprecated but are still available so that GLM 0.8.3.0 is fully compatible with GLM 0.8.2.x. GLM 0.8.3.0 (zip, 896 KB) GLM 0.8.3.0 (7z, 359 KB) Code samples page Manual Full changelog Groove GLM 0.8.2.3 (zip, 963 KB) GLM 0.8.2.3 (7z, 381 KB) Manual Full changelog Groove A new release is available and inogurate a patch number. The goal of this patch number is to release faster fixes from bug reports. GLM 0.8.2.1 (zip, 963 KB) GLM 0.8.2.1 (7z, 381 KB) Manual Full changelog Groove This release only fixes bugs. Left sided swizzle operators, quaternion operators, vectors access operators for the main onces. GLM 0.8.2 (zip, 963 KB) GLM 0.8.2 (7z, 381 KB) Manual Full changelog Groove Some artifacts have been added to the tracker to give a picture of what you could expect for the next releases. If you need something else you can add some artifacts to the tracker. Any comment on added entries is welcome. Furthermore, no more release of GLM 0.7.x will be done. Please upgrade to GLM 0.8.1. Finally, a pack of programmable oriented OpenGL samples using GLM is under development and planed to be release in December. Tracker Groove GLM 0.8.1 is released. This new version mainly fixes 64 bit integers with GCC and various bugs. GLM 0.8.1 (zip, 938 KB) GLM 0.8.1 (7z, 372 KB) GLM 0.8.1 Manual Full changelog Groove GLM 0.8.0 is released. This new version is now based on GLSL 1.30 specification which provided new functions and precision qualifiers. Beyond this, lot of changes have been done to make GLM easier to use, easier to develop, more reliable, more conform to C++ ISO98 standard and GLSL specifications. It involves that GLM 0.8.x is not backward compatible with GLM 0.7.x... However, an application port from GLM 0.7.x to GLM 0.8.x isn't a huge work and actually for some, it won’t be work at all. On GLM core side, based on GLSL features, vector types can't be automatically cast to pointer anymore for code safety purposes. Vector constructors require a single scalar parameter of the exact number of components. On GLM extension side, the mechanism to use them has changed. The old [__]***GTX way doesn't exist anymore. Have a look on the manual for more information. Have a look on the manual and the changelog for more information. Don't forget to send your feedback and enjoy! GLM 0.8.0 (zip, 936 KB) GLM 0.8.0 (7z, 370 KB) GLM 0.8.0 Manual Full changelog Post a comment Groove Ambient aperture lighting Humus demo have been updated to use GLM as math library. Updated demo + all sources (zip, 2.38 MB) Original demo (zip, 1.40 MB) Post a comment Groove As you can see the website get a little update to prepare GLM 0.8.0 final release. GLM 0.8.0 final should be release during the week. Groove This release fixes some bugs and add few features though extensions. The development is now based on CMake to make easier cross platform tests and project management. GLM 0.8.0 Beta 3 (zip, 819 KB) GLM 0.8.0 Beta 3 (7z, 345 KB) Full changelog Post a comment Groove This release mainly improves half float vectors support. By default the low precission vectors are based on float numbers not on half numbers It also provides new setup options. GLM_USE_ONLY_XYZW to disable multiple names to access to a single vector component. GLM_USE_ANONYMOUS_UNION to allow multiple component names on half vectors with Visual C++. Various bugs and updates of extensions have been done too. Final release is coming... GLM 0.8.0 Beta 2 (zip, 798 KB) GLM 0.8.0 Beta 2 (7z, 327 KB) Full changelog Post a comment Groove GLM have been updated to support GLSL 1.30. API documentation had significant improvements to make easier finding of GLSL functions and types. GLM 0.8.x is NOT backward compatible with GLM 0.7.x. Upgrade to GLM 0.8.x could involve build errors for the following cases: A lot of improvements have been made to increase the conformance with GLSL specification. Lot of GLSL 1.30 features were already exposed in extensions that have been deleted. The extension syntaxe based on ARB convension is no long used. Due to the number of changes GLM 0.8.0 is release as beta first. The final release is schedule for october. GLM 0.8.0 Beta 1 (zip, 786 KB) GLM 0.8.0 Beta 1 (7z, 321 KB) Full changelog Post a comment Groove GLM 0.7.6 provides a better C++ conformance so that you can build GLM with –pedantic G++ parameter or without Visual Studio extensions. To make GLM more reliable, BOOST_STATIC_ASSERT are used according developer wishes. GLM 0.7.6 (zip, 907 KB) GLM 0.7.6 (7z, 387 KB) Full changelog Manual Groove GLM 0.7.5 is available and introduces a new build messsage system to get information of GLM build configuration with Visual Studio. This mechanism is documented in section 6 of GLM manual. Also, GLM can be built with GCC pedantic options. GLM 0.7.5 (zip, 852 KB) GLM 0.7.5 (7z, 366 KB) Full changelog Manual Groove GLM 0.7.4 introduces a new system to manage external dependencies. It allows developing extension using external dependencies like GLEW, Boost, etc. without making required those dependencies for GLM programmer that doesn't need those external dependent extensions. The mechanism is described into the updated manual. GLM 0.7.4 (zip, 859 KB) GLM 0.7.4 (7z, 372 KB) Full changelog Manual Groove GLM 0.7.3 is released. This version fixes few bugs and add few extensions GLM 0.7.3 (zip, 1.8 MB) GLM 0.7.3 (7z, 635 KB) Full changelog Groove GLM 0.7.2 is released. The documentation have been completed again and several issues handle with precompiler options. #define GLM_SWIZZLE GLM_SWIZZLE_FUNC allows to use swizzle operators with internal functions. For example, glm::vec3(1, 2, 3).zyx is replaced by glm::vec3(1, 2, 3)._zyx() with this option. #define GLM_FORCE_NO_HALF allows to include all extensions (#include "glm/glmext.h") without any support of half-precision floating-point numbers. #define GLM_AUTO_CAST GLM_DISABLE allows to disable automatic cast (eg: glLoadMatrixf(glm::mat4(1.0))) which could involve unfortunate issues in some cases. More information on these topic are available in GLM manual section 5 "Known issues". GLM 0.7.2 (zip, 1.8 MB) GLM 0.7.2 (7z, 635 KB) Full changelog Groove GLM 0.7.1 is available under MIT license. It fixes bugs with GCC. GLM 0.7.1 (zip, 1.8 MB) GLM 0.7.1 (7z, 635 KB) Full changelog Groove GLM 0.7.0 is available under MIT license. LGPL lisence have been discard due to an issue of use for console development. This release contains a lot better documentation based on Doxygen. Lot of bugs have been fixed and the documentation completed. Thanks to all people that has contributed thought bug reports and ideas to make this version a lot better! GLM 0.7.0 (zip, 1.8 MB) GLM 0.7.0 (7z, 635 KB) Full changelog Groove GLM 0.6.4 is available and fixes some swizzle operator issues. GLM 0.6.4 (zip, 1.7 MB) GLM 0.6.4 (7z, 612 KB) Full changelog Groove GLM 0.6.3 fixes accesses of matrices and a 3DSMax SDK conflict. GLM 0.6.3 (zip, 1.8 MB) GLM 0.6.3 (7z, 633 KB) Full changelog Groove GLM 0.6.2 fixes an error on an extension. GLM 0.6.2 (zip, 1.8 MB) GLM 0.6.2 (7z, 632 KB) Full changelog Groove GLM 0.6.1 is a minor update that fix an issue on extension namespace and add two more extensions. GLM 0.6.1 (zip, 1.8 MB) GLM 0.6.1 (7z, 632 KB) Full changelog Groove GLM 0.6.0 is available. For this release, work focus on extensions. A new mecanisum allows to integrate GLM extensions as it is actually done for GLSL extension by vendors. Lot of new extensions have been added. GLM 0.6.0 (zip, 1.8 MB) GLM 0.6.0 (7z, 666 KB) Raytracer v1.0 (exe) Raytracer v1.0 (zip) Full changelog Groove This release fixes some issues with swizzle operators. GLM 0.5.1 (zip, 2.3 MB) GLM 0.5.1 (7z, 789 KB) Groove A new sample is available. It's an update of Philip Rideout's Catmull Clark subdivision program that uses GLM. Released with pleasant permission of Philip Rideout. CatmullClark sample (zip, 605 KB) Groove This release include GLSL 1.2 new feature in the core implementation. Also, it includes swizzle read and write operators and a custom options system to setup GLM. It includes some new extensions to extend GLSL features but they remain experimental. The next release should provide the first stable extensions. The GLM 0.5.0 packages contain some basic samples and some documentation. The ray tracer sample has been updated to GLM 0.5.0. Except for specific cases, especially with extensions, GLM 0.5 is backward compatible. Now, GLM development is taking advantages of SourceForge.net services: a bug tracker system and the development source code is publicly available on SF.net SVN server. GLM 0.5.0 (zip, 2.4 MB) GLM 0.5.0 (7z, 843 KB) Raytracer b3.0 (exe, 751 KB) Raytracer b3.0 (zip, 1.1 MB) Groove A GLM update is available. It simply includes some examples for a sweet start with GLM. The examples show how to use GLM with OpenGL intermediate mode and OpenGL vertex arrays. Also, they show how to use GLM extensions to replace GLU and OpenGL function witch could slightly increase performances by decreasing the number of OpenGL states changes. GLM 0.4.1 (zip, 1.6 MB) GLM 0.4.1 (7z, 521 KB) Groove This release introduces first GLSL 1.2 features as planed. Also, various new extensions have been added and updated. Finally, it's not anymore required to include windows.h before glm.h when windows.h is required. The number of features of GLM, including extensions, start to really increase the compilation time. That's why it's recommended to use precompiled headers. GLM 0.4.0 Groove Version 0.4 will complete matrices and vectors operators and will add GLSL 1.2 features. First, conversions simplifications will be integrated. Then, 4 per 3 matrices and outer product will be available from extensions. The transpose function is already available from extension. Version 0.5 will integrate GLSL 1.2 features to GLM core. Version 0.6 will add swizzle operators in reading and writing. (eg: vec3 v1(1.0, 2.0, 3.0); vec3 v2 = v1.xxx; v1.zyx = v;). Groove This release corrects two main bugs. First, a bug of the imat4 and mat4 division operators and other correct the vectors components access from texture coordinate way. GLM 0.3.2 Groove This update adds GCC 4.0 support for MacOS X and Linux and GCC 4.1 under Linux. Also, its provides some optimisations. Further release will prodive GLSL 1.2 compliances. GLM 0.3.1 Groove A new release of GLM is now available. It improves GLSL data type conversion and construction compliance. Also, It's adds extensions like some to manage double-precision and half-precision float numbers. Finally a Doxygen documentation has been added. This new release have been tested under Visual C++ 7.1, Visual C++ 8.0, GCC 3.2.3 et GCC 3.4.2. GLM 0.3 Raytrace Online documentation Groove A new release of GLM is now available. A few bugs have been fixed, the portability of GLSL into C++ has been improved, and new experimental extensions have been implemented, enhancing GLSL features. Project now supports quaternions, adds new features to handle colors, vectors and matrices. For example, GLM allows base colors changing, vector projected operations, and 2D/3D transforms. To demo the features of this new version, a sample program is included. It is a simple Ray Tracer supporting reflected and refracted rays, three lights types (point, directionnal and spot), two objects types (sphere, plan), using all of the GLM possibilities. Groove The english section of this site is now available. Groove This is the first public availability of GLM. This library supports part of GLSL specifications : All vectors and matrices types, and all the operators and associated functions. For now, there isn't detailed documentation, but you can freely have a look on GLSL specifications. Consider any incoherence with GLM as an error. Keep in mind the library is included in the namespace "glm". This project is multi platform and was successfully tested under Visual C++ 7.1, MinGW 3.4 and GCC 3.4. GLM 0.1 User Release GLM 0.1 Contributor Release GLSL 1.10.59 specifications #include <glm/glm.hpp> void computeNormal(triangle & Triangle) { glm::vec3 const & a = Triangle.Position[0]; glm::vec3 const & b = Triangle.Position[1]; glm::vec3 const & c = Triangle.Position[2]; Triangle.Normal = glm::normalize(glm::cross(c - a, b - a)); } // glm::vec3, glm::vec4, glm::ivec4, glm::mat4 #include <glm/glm.hpp> // glm::perspective #include <glm/gtc/matrix_projection.hpp> // glm::translate, glm::rotate, glm::scale #include <glm/gtc/matrix_transform.hpp> // glm::value_ptr #include <glm/gtc/type_ptr.hpp> { glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f); glm::mat4 ViewTranslate = glm::translate( glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate)); glm::mat4 ViewRotateX = glm::rotate( ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f)); glm::mat4 View = glm::rotate( ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f)); glm::mat4 Model = glm::scale( glm::mat4(1.0f), glm::vec3(0.5f)); glm::mat4 MVP = Projection * View * Model; glUniformMatrix4fv( LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP)); } #include <glm/glm.hpp> #include <glm/gtx/type_precision.hpp> std::size_t const VertexCount = 4; // Float quad geometry std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2); glm::vec2 const PositionDataF32[VertexCount] = { glm::vec2(-1.0f,-1.0f), glm::vec2( 1.0f,-1.0f), glm::vec2( 1.0f, 1.0f), glm::vec2(-1.0f, 1.0f) }; // Half-float quad geometry std::size_t const PositionSizeF16 = VertexCount * sizeof(glm::hvec2); glm::hvec2 const PositionDataF16[VertexCount] = { glm::hvec2(-1.0f, -1.0f), glm::hvec2( 1.0f, -1.0f), glm::hvec2( 1.0f, 1.0f), glm::hvec2(-1.0f, 1.0f) }; // 8 bits signed integer quad geometry std::size_t const PositionSizeI8 = VertexCount * sizeof(glm::i8vec2); glm::i8vec2 const PositionDataI8[VertexCount] = { glm::i8vec2(-1,-1), glm::i8vec2( 1,-1), glm::i8vec2( 1, 1), glm::i8vec2(-1, 1) }; // 32 bits signed integer quad geometry std::size_t const PositionSizeI32 = VertexCount * sizeof(glm::i32vec2); glm::i32vec2 const PositionDataI32[VertexCount] = { glm::i32vec2 (-1,-1), glm::i32vec2 ( 1,-1), glm::i32vec2 ( 1, 1), glm::i32vec2 (-1, 1) }; #include <glm/glm.hpp> #include <glm/gtx/random.hpp> glm::vec3 lighting ( intersection const & Intersection, material const & Material, light const & Light, glm::vec3 const & View ) { glm::vec3 Color = glm::vec3(0.0f); glm::vec3 LightVertor = glm::normalize( Light.position() - Intersection.globalPosition() + glm::vecRand3(0.0f, Light.inaccuracy()); if(!shadow( Intersection.globalPosition(), Light.position(), LightVertor)) { float Diffuse = glm::dot(Intersection.normal(), LightVector); if(Diffuse <= 0.0f) return Color; if(Material.isDiffuse()) Color += Light.color() * Material.diffuse() * Diffuse; if(Material.isSpecular()) { glm::vec3 Reflect = glm::reflect( glm::normalize(-LightVector), glm::normalize(Intersection.normal())); float Dot = glm::dot(Reflect, View); float Base = Dot > 0.0f ? Dot : 0.0f; float Specular = glm::pow(Base, Material.exponent()); Color += Material.specular() * Specular; } } OpenGL's Official site. You would find OpenGL specifications, news and tons of related informations. This page contains all OpenGL extensions specifications. This page contains OpenGL 2.0 specifications. This page contains OpenGL Shading Language Specification. This document lists all the conventions for writing GLSL extensions. These rules are the basics of the GLM extensions system. GLSL is not the ultimate mathematics library, i.e. for matrices operations, specs are very restricted. There aren't any functions to get the determinant, inverse, or a matrix transpose. Moreover, there are a few vector types and no quaternions. What about completing the missing features using the extensions ? It will be developed from GLSL conventions and may add for exemple the extension GLM_GTX_quaternion, defining __quatGT type and conjugateGT function. Extensions may be available through a separate file called glmext.h instead of being directly into the library core file. It would be interesting to suggest GLM extensions implementations directly in GLSL to increase portability. It may hopefully end by submitting extensions to ARB. The use of a namespace allows to prevenf from any name collision problem with other libraries like STL. GLSL uses a reserved 'namespace' keyword but does not define it. OpenGL uses a C technic for the namespaces management with the 'gl' prefix. What name should we give to this namespace ? 'gl', 'glsl', 'glm' or 'sl' ? What is the best solution ? C-like or C++-like namespaces ? Bug #3 says that 'not' is a C++ keyword. C-style namespaces use would resolves this bug but GLSL has been built from C upon a C++ logic. The interaction with OpenGL is not the purpose of GLM. However, GLM should be easily usable with OpenGL and some features could be welcome. i.e., using vec3 type with Vertex3fv function should simplify and optimize the program. Eventually, semantically speaking, vec3 is more accurate and stronger than addressing on a potential 3 floats table. If it is possible to make easy the interoperability between GLM and OpenGL, then this work is recommended if semantic stays correct. GLM must also remain independent towards OpenGL. GLSL specifications include unimplemented reserved keywords list. Their use must return an error. Some of them already exist in C++. GLM can only allow C++ reserved keywords. The others must be undefined so the compiler returns an error. GLSL defines six variable qualifiers types : const, varying, uniform, attrib, in, out, inout. 'const' variables are only usable in a local way into a shader. They are available for vertex and fragments shaders. GLSL's 'const' are similar to C++ 'static const', i.e. the variable only exists inside a compilation unit (.o files with GCC). 'varying' variables offer a communication interface between vertex and fragment sahder. 'uniform' and 'attrib' variables are a way of communication between C/C++ program and shaders, so 'varying' are useless in the C++ program; so this qualifier is not allowed. Some programmers are already using 'in', 'ou' and 'inout' qualifiers for semantic purpose. They define them as empty '#define'. It seems difficult to keep the same syntax than GLSL for 'uniform' and 'attrib' variables although this notion seems interesting. Why not keeping it only for their semantic properties ? All integrated variables matches with OpenGL state variables. So there are all accessible from the OpenGL API. smapler* types come from GL_ARB_multitexure extension. Values matches with a texture unit. A sampler type would offer an additionnal semantic value. No, this is not the GLM objective. GLSL allows several components to be accessed at the same time. Moreover, GLSL let the possibility to the user to order components as he wants. To implement such a possibility, 4² * 3 * 2 = 96 fuctions should be added for vec4 type, for example (components number : 4, access types : 3, readonly access and write access : 2). A solution witch reach GLSL conformance have been found. However it need lot of functions. This feature is coming in a futur release. GLSL allows an access to a component with many different names, that explains the component notion. i.e. the first vec3 component is accessible with .x, .r, .s. A possibility would be creating three functions for each component. Another would be using the keyword 'union'. The first solution allows to keep components values in a private classes table, but in this case, the overloaded operator [] must be used to access values and/or functions per component that is not conform to GLSL specifications. The second respect GLSL rules but components are public. In this case, this is not a real problem so this second solution is kept. GLSL specifications tell that 'fragment processing functions' are only available for fragment shaders and function ftransform is only available for vertex shaders. The C/C++ program must be considered as a third program type so this functions are not available. 'union' keyword is here to allow access to vector components with several different variables names. Moreover, templates are also used to create two vector type categories : _vec* and _ivec*. Eventually, anonymous structures are not allowed in ISO C++ norm. Problem might come from the lack of supporting both templates and unions from Visual C++ 7.1. If -pedantic isn't used with G++, then code compiles correctly. As we are waiting for a better compromise, the code stays that way. As notified for the bug #4, the ultimate solution might be to avoid templates in vector definition. GCC supports all C++ keywords that includes 'not', which is equivalent to '!' operator. So there is a problem with GLM because GLSL defines the 'not' function. Overloading the '!' operator or the 'not' keyword we can partly resolve the problem but leaving as ignored the GLM namespace concept. If the source code contains 'glm:not' string, then GCC gives an error. 'not' is a C++ keyword so GLM mustn't define a 'not' function. However, all the compilers don't support this keyword (VC7.1). Does this name has to be changed ? For now, it is recommended to avoid using 'not'. The GLSL specifications grant access to multiple components for vector types. i.e. with GLSL the following lines are correct : vec3 MyVector = vec4(1.0, 1.0, 1.0, 0.0).xyz. It seems difficult to create an equal feature in C++ because 'x', 'y', and 'z' according to the previous example can be sorted in any order and be repeated from zero to four to a max of four components. OpenGL Mathematics (GLM) is a header only C++ mathematics library for graphics software based on the OpenGL Shading Language (GLSL) specification. GLM provides classes and functions designed and implemented with the same naming conventions and functionalities than GLSL so that when a programmer knows GLSL, he knows GLM as well which makes it really easy to use. This project isn't limited by GLSL features. An extension system, based on the GLSL extension conventions, provides extended capabilities: matrix transformations, quaternions, half-based types, random numbers, etc... This library works perfectly with OpenGL but it also ensures interoperability with other third party libraries and SDKs. It is a good candidate for software rendering (Raytracing / Rasterisation), image processing, physic simulations and any context that requires a simple and convenient mathematics library. GCC 3.4 and higher LLVM 2.3 through GCC 4.2 front-end and higher Visual C++ 2005 and higher Any C++ compiler following C++98 norm The source code is under the MIT license. Thanks for contributing to the project by submitting tickets for bug reports and feature requests. (SF.net account required). Any feedback is welcome at glm@g-truc.net. GLSL + Optional features = OpenGL Mathematics (GLM). A C++ mathematics library for 3D graphics. 2560x1600 1920x1200 1600x1000 1280x0800 1024x0640 Font (.otf)