GLM 0.9.0.0: Mathematics Library for 3D Programming



GLM - OpenGL Mathematics



The new version of GLM is out. GLM or OpenGL Mathematics is a C++ math library based on a subset of GLSL specifications and conventions. GLM is not dependent on the OpenGL API so you can use it anywhere you need math functions: raytracing, image processing or physics. But of course, GLM is especially well suited for OpenGL development.

The new branch 0.9.x.x is now based on GLSL 4.00 specification.

Small code sample:

// 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));
} 

Let’s groove :D





[ Subscribe to Geeks3D latest news by email ]

Geeks3D.com

↑ Grab this Headline Animator