OpenGL Mathematics

OpenGL Mathematics

GLM (OpenGL Mathematics) is an OpenGL utility library providing to C++ programmer all classes and functions allowing to use data for OpenGL [1].

One GLM characteristic is that GLM implementation is based on GLSL (OpenGL Shading Language) specification [2].

GLM source code is available under the MIT license.

Code samples

// Compute a triangle normal:
#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));
}
// Matrix transform:
#include <glm/glm.hpp> // glm::vec3, glm::vec4, glm::ivec4, glm::mat4
#include <glm/gtc/matrix_projection.hpp> // glm::perspective
#include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale
#include <glm/gtc/type_ptr.hpp> // glm::value_ptr
 
void transform()
{
  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));
}

References

External links


Wikimedia Foundation. 2010.

Игры ⚽ Поможем решить контрольную работу

Look at other dictionaries:

  • OpenGL Mathematics — GLM (OpenGL Mathematics математика для OpenGL) библиотека для OpenGL, предоставляющая программисту на C++ классы и функции, позволяющие использовать данные для OpenGL [1]. Одна из особенностей GLM состоит в том, что его реализация основана на… …   Википедия

  • OpenGL Mathematics — GLM (OpenGL Mathematics) est une bibliothèque libre utilitaire d OpenGL apportant au programmeur C++ tout un ensemble de classes et de fonctions permettant de manipuler les données pour OpenGL. Une spécificité de GLM, par rapport aux autres… …   Wikipédia en Français

  • OpenGL — Тип API Раз …   Википедия

  • OpenGL — Original author(s) Silicon Graphics Developer(s) Khronos Group Stable release 4.2 …   Wikipedia

  • Список программ, использующих лицензию MIT — Это список программ, использующих Лицензии MIT. Arctic Torrent Banshee  музыкальный проигрыватель BarsWF CUDA и SSE2 brute force взломщик md5 Bitcoin электронная пиринговая криптовалюта Bouncy Castle  криптографический API CakePHP… …   Википедия

  • GLM — The three letter acronym GLM may refer to:*general linear model *generalized linear model * gigabit linking module (for fast data transfer via a network interface card) *Gilman (Amtrak station), Illinois, United States; Amtrak station code GLM… …   Wikipedia

  • Список программ — Список программ, использующих лицензию MIT Это список программ, использующих Лицензии MIT. Arctic Torrent Banshee  музыкальный проигрыватель Bouncy Castle  криптографический API CakePHP CLiki  вики движок Chord project Compiz  …   Википедия

  • Quaternion — Quaternions, in mathematics, are a non commutative extension of complex numbers. They were first described by the Irish mathematician Sir William Rowan Hamilton in 1843 and applied to mechanics in three dimensional space. They find uses in both… …   Wikipedia

  • Spherical harmonics — In mathematics, the spherical harmonics are the angular portion of an orthogonal set of solutions to Laplace s equation represented in a system of spherical coordinates. Spherical harmonics are important in many theoretical and practical… …   Wikipedia

  • Z-buffering — Z buffer data In computer graphics, z buffering is the management of image depth coordinates in three dimensional (3 D) graphics, usually done in hardware, sometimes in software. It is one solution to the visibility problem, which is the problem… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”