Explaining Homogenous Coordinates & Projective Geometry

on February 24th, 2014 by Tom 11 Comments Modern OpenGL Series http://commons.wikimedia.org/wiki/File:Zentralprojektion.jpg

In this article I’m going to explain homogenous coordinates (a.k.a. 4D coordinates) as simply as I can. In previous articles, we’ve used 4D vectors for matrix multiplication, but I’ve never really defined what the fourth dimension actually is. Now it’s time to take a closer look at projective geometry.

Also, welcome back! It has been a while since my last post. Hopefully I will find some time in the next couple of months to finish up the Modern OpenGL Series of articles. The code for article 08 is done, but writing the article will take some time.

Read full post →

Modern OpenGL 07 – More Lighting: Ambient, Specular, Attenuation, Gamma

on April 18th, 2013 by Tom 40 Comments Modern OpenGL Series more_lighting_screenshot

In this article we will continue to implement lighting. We will implement the ambient and specular components of the Phong reflection model, attenuation, and gamma correction.

Read full post →

Modern OpenGL 06 – Diffuse Point Lighting

on March 23rd, 2013 by Tom 20 Comments Modern OpenGL Series article-06-diffuse-lighting

This is the first article covering lighting. We will begin our lighting adventure by implementing per-pixel, diffuse lighting with a single point light. In later articles we will implement ambient and specular reflection, directional lights, spotlights, attenuation, and using multiple lights.

Read full post →

Modern OpenGL 05 – Model Assets & Instances

on February 8th, 2013 by Tom 10 Comments Modern OpenGL Series article-05

In this article, we will be refactoring the code to be more like a 3D engine/framework. Specifically, we will be replacing some of the globals with structs that represent “assets” and “instances.” At the end, we will have a single wooden crate asset, and five instances of that asset arranged to spell out “Hi” in 3D.

Read full post →

Modern OpenGL 04 – Cameras, Vectors & Input

on January 21st, 2013 by Tom 33 Comments Modern OpenGL Series ogl-camera-article

In this article, we will be consolidating the matrix and camera knowledge from the previous article into the new tdogl::Camera class, which will be a first-person shooter type of camera. Then, we will connect the camera to keyboard and mouse input, so we can move within the 3D scene and look around. This will involve learning a bit of vector math. We will also learn about inverting matrices, which was not mentioned in the previous article.

Read full post →

Modern OpenGL 03 – Matrices, Depth Buffering, Animation

on December 16th, 2012 by Tom 22 Comments Modern OpenGL Series article-03-matrices

In this article, we will replace our immobile 2D triangle with a spinning 3D cube. The end result will look like this:

Now that we’re finally getting something interesting on the screen, I can include more pictures! An album of animated gifs is available here: http://imgur.com/a/x8q7R

In order to make this spinning cube, we will learn a bit about matrix math, and how it is used to create perspective projections, rotation, translation, and the concept of a “camera.” We will also learn about depth buffering, and why it is necessary. We will also see how a typical 3D application implements changes over time, such as animation.

Read full post →

Modern OpenGL 02 – Textures

on December 2nd, 2012 by Tom 24 Comments Modern OpenGL Series opengl-article-02

In this article, we will be adding a texture to the triangle. This will involve adding new variables to the vertex and fragment shaders, creating and using texture objects, and learning a bit about texture units and texture coordinates.

As with every article, we will be adding to the small library of reusable code in the tdogl namespace. This article introduces two new classes: tdogl::Bitmap and tdogl::Texture. These two new classes will allow us to load an image from a jpg, png, or bmp file into video memory, for use in the shaders. Also, the tdogl::Program class has some new methods for setting shader variables.

Read full post →

Modern OpenGL 01 – Getting Started in Xcode, Visual C++, and Linux

on November 24th, 2012 by Tom 60 Comments Modern OpenGL Series opengl-article-01

Welcome to the first of a series of articles about modern OpenGL, with a focus on making games. All the code will be open source, and downloadable from github: https://github.com/tomdalling/opengl-series.

By the end of this article, you will have a working OpenGL 3.2 project in Visual C++ on Windows, Xcode on OSX, and Linux. The app will have a vertex shader, a fragment shader, and will display a single triangle using a VAO and a VBO. The project will use GLEW to access the OpenGL API, GLFW to handle window creation and input, and GLM for matrix/vector math.

Yes, it is a little bit boring, but just getting a project set up correctly can be difficult, especially for beginners. Once this is out of the way we will get into the more interesting stuff.

Read full post →