09/02/2010 GLM 0.9 Alpha 1 released

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. The following examples uses GLM 0.9 conversions.

This release is still UNSTABLE and not recommanded for commertial product.

Compute face normals:
  • #include <glm/glm.hpp>
  • void computeFaceNormals(mesh & Mesh)
  • {
  • for(mesh::iteractor it = Mesh.Faces.begin(); it != Mesh.Faces.end(); ++it)
  • {
  • glm::vec3 const & a = Mesh.Points[it->Vertices[0].Index].Position;
  • glm::vec3 const & b = Mesh.Points[it->Vertices[1].Index].Position;
  • glm::vec3 const & c = Mesh.Points[it->Vertices[2].Index].Position;
  • it->Normal = glm::normalize(glm::cross(c - a, b - a));
  • }
  • }
OpenGL rendering:
  • #include <glm/glm.hpp>
  • #include <glm/gtc/matrix_projection.hpp>
  • #include <glm/gtc/matrix_transform.hpp>
  • #include <glm/gtx/type_ptr.hpp>
  • namespace
  • {
  • glm::vec4 const ClearColor(glm::vec3(0.0f), 1.0f);
  • glm::ivec4 const Viewport(glm::ivec4(0, 0, 640, 480);
  • }
  • void render()
  • {
  • glClearColor(ClearColor.r, ClearColor.g, ClearColor.b, ClearColor.a);
  • glClear(GL_COLOR_BUFFER_BIT);
  • glViewport(Viewport.x, Viewport.y, Viewport.z, Viewport.w);
  • glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.0f);
  • glm::mat4 ViewTranslate = glm::translate(
  • glm::mat4(1.0f),
  • glm::vec3(0.0f, 0.0f, -translateCurrent.y));
  • glm::mat4 ViewRotateX = glm::rotate(
  • ViewTranslate,
  • rotationCurrent.y,
  • glm::vec3(-1.0f, 0.0f, 0.0f));
  • glm::mat4 View = glm::rotate(
  • RotateX,
  • rotationCurrent.x,
  • glm::vec3(0.0f, 1.0f, 0.0f));
  • glm::mat4 ModelView = glm::scale(View, glm::vec3(0.5f));
  • glMatrixMode(GL_PROJECTION);
  • glLoadMatrixf(glm::value_ptr(Projection));
  • glMatrixMode(GL_MODELVIEW);
  • glLoadMatrixf(glm::value_ptr(ModelView));
  • draw();
  • }
Raytracing lighting:
  • #include <glm/glm.hpp>
  • glm::vec3 lighting
  • (
  • intersection const & Intersection,
  • material const & Material,
  • light const & Light,
  • glm::vec3 const & View
  • )
  • {
  • glm::vec3 Inaccuracy = glm::vecRand(0.0f, Light.inaccuracy());
  • glm::vec3 Color(0.0f);
  • glm::vec3 LightVector = glm::normalize(
  • Light.position() - Intersection.position() + Inaccuracy);
  • if(!shadow(Intersection.position(), Light.position(), LightVector))
  • {
  • float Diffuse = glm::dot(Intersection.normal(), LightVector);
  • if(Diffuse > 0.0f)
  • {
  • Color += Light.color() * Material.diffuse() * Diffuse;
  • glm::vec3 Reflect = glm::reflect(
  • glm::normalize(-LightVector),
  • glm::normalize(Intersection.normal()));
  • float Specular = glm::pow(
  • glm::max(glm::dot(Reflect, View), 0.0f),
  • Material.specularExponent());
  • Color += Material.specular() * Specular;
  • }
  • }
  • return Color;
  • }
February 2010 SDK and new samples for Direct3D 11 >
< G-Truc Creation 6.2 released
Copyright © Christophe Riccio 2002-2016 all rights reserved
Designed for Chrome 9, Firefox 4, Opera 11 and Safari 5