OpenGL

Projection Matrix

In the previous article, we discussed the camera transformation which maps a vertex from world space into the camera space. Recall that the camera spans a orthonormal coordinate system with the three vectors \(\vec{u}\), \(\vec{v}\) and \(\vec{w}\), where \(-\vec{w}\) points along the viewing direction. In this section we will deal with the projection of the 3D vertex in camera space into a 2D view plane. In OpenGL, what follows is clipping and mapping to so-called normalized device coordinates which are tightly coupled into the construction of projection matrix. In fact, the pure mathematical construction of the projection matrix is easy. What makes it difficult is the clipping part. (more…)

By admin, ago
Java

Simple OpenGL Shader Example

This post provides a clean, up-to-date and concise example on how to set up a simple custom shader in OpenGL that runs out of the box. My target language is Java with LWJGL, but the code can easily be ported to different languages on this level. To my surprise, I is quite difficult to find a state of the art example of a simple yet complete setup for shaders that can serve as a get-go for more complex programs. Most OpenGL shader tutorials are written for the pre-2.0 era (ie. using shaders through ARB extensions) that is long over. This post is therefore trying to provide a modern "Hello World of Shaders" set up example. (more…)

By admin, ago
OpenGL

Math Primer for 3D Graphics

In the following post I provide a simple-as-possible math primer to understand basic concepts necessary for 3D graphics. I do not put much emphasize on a formal notation, but rather on understandability and applicability for our case. That is why we always assume the Cartesian Coordinate System and specialize our definitions for three dimensions. (more…)

By admin, ago
OpenGL

Introduction to 3D Graphics

We shall begin. Let me welcome you, fellow nerd! You are about to embark on a wonderful journey full of geekiness and technical awesomeness. Computer graphics, especially 3D graphics is the pinnacle of nerdcraft. It has been fascinating gamers, artists and developers since the first photon has been shot on a screen. Together with game development, 3D computer graphics belongs to the most challenging parts of computer science, as it involves a lot of math, a deep understanding of underlying hardware, meticulous and efficient programming and a sense for beauty. (more…)

By admin, ago
OpenGL

Display Lists in OpenGL

This post is a brief tutorial on how to use display lists in OpenGL. An working and self-contained example is given below using LWJGL. Display lists are an essential feature of OpenGL to improve the rendering performance of your application. You can think of them as kind of a macro for OpenGL commands that you name, record and call at some point in your game. More specifically, you assign an integer handle to a sequence of OpenGL commands and call the commands identified by that handle when you need them. (more…)

By admin, ago
Java

OpenGL Picking in 3D

This blog post explains a common and versatile approach to OpenGL picking called "ray picking". An example in pseudo-code is given below. Picking is the process of finding objects in your scene based on user input. Most commonly, you want to determine what object a user has clicked with his mouse. The 2D mouse coordinates serve as a reference on the view port to identify the projected objected that has been clicked. A similar scenario is a first person shooter, where the gun is basically the picking pointer. If you shoot the gun, the trajectory of the bullet is traced through the scene and collisions are detected, similar to a laser pointer shooting a ray through a scene until it hits an object and marks it with a small red dot. (more…)

By admin, ago
OpenGL

LWJGL Example Base

This post contains the LWJGL base class that I use throughout the tutorials and examples. It basically sets up LWJGL and OpenGL which I otherwise would have to do over and over again in the individual examples. In addition, this makes the code in the tutorials and examples more readable by focusing on the important things. (more…)

By admin, ago
Java

JOGL in Eclipse

This getting started-tutorial is intended for JOGL users that are mere beginners. It helps to setup a recent JOGL installation in Eclipse on Windows. There is a video-walk-through further down the post, in case you dont feel like reading. (more…)

By admin, ago