Tutorials


Current series: OpenGL 3.3
(Return to list of tutorial series)

This series covers step-by-step learning of OpenGL 3.3 and later. As you may know, in OpenGL 3.0, most of old stuff has been deprecated (the fixed pipeline), including the easy-to-use rendering using glBegin() / glEnd() functions and in OpenGL 3.2 removed from core profile. Programming the new way may be more difficult than old way, but the results are worth learning it, trust me. These tutorials are also forward-compatible with later versions of OpenGL.


Date: 19.09.2011

First of the upcoming series of OpenGL 3.3 (and later) tutorials. Describes how to create OpenGL 3.3 rendering context on Windows.


Read here
Download (119 KB)
7637 downloads. 28 comments

Date: 22.10.2011

Well, this tutorial should have name First Triangle and Quad, since there's triangle and quad rendered, but it doesn't matter :D Point is, that you can learn what is VBO and how to render basic primitives (now it's without color, in next tutorial we will dive into shaders).


Read here
Download (120 KB)
3416 downloads. 12 comments

Date: 14.11.2011

As the name suggests - you will be introduced to probably most important thing in new OpenGL - shaders - programs executed on GPU that processes vertices and data. After reading this tutorial you should be able to compile and use shaders and color your primitives.


Read here
Download (128 KB)
3752 downloads. 12 comments

Date: 25.11.2011

In this tutorial, we are finally going to do some 3D rendering. We will create a VAO for pyramid, and we will render 5 moving pyramids. This tutorial introduces comeback of matrices, but without fixed functionality that older OpenGL provided. We will use free OpenGL Mathematics Library glm, which eases life so much by replacing all good old functions that OpenGL and GLU had. We will also learn about uniform variables in shaders, how to switch vertical synchronization, that limits FPS to monitor refresh rate, and how to update scene based on time elapsed (nothing difficult). So prepare, this one's gonna be longest so far.


Read here
Download (135 KB)
3481 downloads. 13 comments

Date: 10.12.2011

Indexed drawing is another mode for rendering things in OpenGL. With it, you don't provide vertex data directly, but rather by telling OpenGL where they're stored (you just tell OpenGL indices of vertices), and this can be beneficial for rendering some objects, like heightmaps (in this tutorial there's a simple 4x4 heightmap used to demonstrate power of indexed drawing), but not that good for objects like pyramid from our previous tutorial.

This tutorial also covers how to run application in fullscreen mode and provides such option at startup.


Read here
Download (139 KB)
2836 downloads. 2 comments

Date: 22.12.2011

The time has come now to add plenty of realism to our scene - we will learn how to texture objects. There are many libraries for loading images, I decided to use FreeImage library, with which I have most experience. After this tutorial, our scenes will become almost photorealistic (just kidding, it has too far from photorealism LULZ, but it's far more realistic than just colored triangles LULZ).


This tutorial is pretty long, as it covers image loading, texture filterings, texture coordinate mapping, and samplers. In the end you will see, that moving from old way of texturing to new isn't that hard. And because Winter Is Coming LULZ (actually it's already here in Slovakia), we will use ice texture in this tutorial LULZ.


You may notice increase in filesize, compared to other tutorials. It's because I pack FreeImage.dll within, so you can run this tutorial without problems.


Read here
Download (1.74 MB)
3756 downloads. 13 comments

Date: 11.01.2012

In this tutorial, you are going to learn (if you already don't know) how to use pixel blending to achieve effects like object transparency. Object transparency actually isn't that simple - in order to do it properly, several things must be ensured for it to work properly.

It's called basics, because topics discussed here are really only basics. There is a better method for rendering transparent objects called Order Independent Transparency, which is more advanced and will be explained in a tutorial far far away... LULZ (well not that far, but not now)


Read here
Download (1.26 MB)
2343 downloads. 0 comments

Date: 21.01.2012

Lighting is what gives flavour to the look of our scene. Without it, scene looks dull and flat, not resembling reality. This tutorial tries to explain basic lighting terms and also starts to implement simple lighting model based on ambient, diffuse and specular contribution to light. The lighting tutorials will continue, this is only the first.

Light source in this part is directional light, more specifically sun, which has also it's texture made in MSPaint LULZ. I hope you'll like how sun looks LULZ ! Move around with WSAD keys, change sun's position with LEFT and RIGHT arrow keys to change direction of light.


Read here
Download (1.43 MB)
3049 downloads. 7 comments

Date: 02.02.2012

This tutorial introduces you to orthographic 2D projection, with which you can do 2D renderings over a scene and then you will learn about FreeType fonts and how to load and print them with OpenGL. FreeType is a great choice for fonts in OpenGL, because they can handle all font types used nowadays.


Read here
Download (1.43 MB)
2434 downloads. 8 comments

Date: 14.02.2012

Skybox is a simple but powerful technique for creating realistic surroundings and backgrounds for our scene. This concept is described here. I used skybox from Jaj's Fragtory, they should be free (http://www.quakewiki.net/archives/jaj/skies.html).


Read here
Download (2.12 MB)
4100 downloads. 5 comments

Date: 14.03.2012

Multitexturing is a technique of applying multiple textures to a surface. We can easily mix two or more textures with shaders the way we want. In this tutorial, you are on a desert, and you can easily control desertification level with keys 'G' (more grass) or 'H' (less grass, more draugHt LULZ).

After going through this tutorial, you shouldn't have problem applying as many textures on your object, as your hardware supports LULZ.

I also explain how to remove problem with flickering of scene, when looking at scene from far away.


Read here
Download (2.16 MB)
2054 downloads. 2 comments

Date: 24.03.2012

Brace yourselves, foggy days are coming . This tutorial adds a fog shader to the scene. In old OpenGL, making fog was as simple as calling glEnable(GL_FOG), while specifying few settings for fog. Within new, we must build this on our own. But it's not anything extremely difficult.

This tutorial will be continued later with Volumetric Fog, or fog that is present only in certain areas of scene.


Read here
Download (2.13 MB)
1981 downloads. 1 comments

Date: 07.05.2012

This tutorial describes point lights. These lights are illuminating only area around them, depending on their attenuation factors. Typical point light in real world is a light bulb. But we won't have one, instead we have here shining colored cube .


Read here
Download (2.16 MB)
2133 downloads. 2 comments

Date: 08.07.2012

After 2 months delay, new tutorial is finally here! It introduces another type of shader commonly used nowadays - Geometry shader. Its purpose is to produce additional geometry from input data, for example higher tesselation of input polygons. In the future, we will use this shader for creating particle system.

In this tutorial, we divide each triangle into 3 subtriangles right in its centroid, and move that centroid towards or backwards from triangle in the normal direction. This creates interesting effect.

You will also learn how to turn on wireframe rendering mode (single function call, nothing advanced ).


Read here
Download (2.22 MB)
2200 downloads. 6 comments

Date: 30.07.2012

Finally! A first tutorial in which we work with something else than just boxes and toroids . This tutorial will teach you how to load and render Wavefront OBJ model files. From now on, we'll use models to make our scenes more interesting.

In this tutorial, there is a free Thor model. And there is also another model. Which? See for yourself .


Read here
Download (3.25 MB)
4809 downloads. 9 comments

Date: 22.08.2012

3 weeks have passed since last tutorial, but it's here - rendering to a texture. What's it good for? Well, you can render something, then make a texture out of it, and map it somewhere. It's good for example when programming TV screens, mirrors and so on.

In this tutorial, we'll create a TV screen with moving and rotating Thor model on it and Spongebob will be watching all this like movie .


Read here
Download (3.32 MB)
1789 downloads. 3 comments

Date: 24.09.2012

More than 4 weeks gone and another tutorial is here - this time it's the spotlight. It's a light that has a position, direction and a cutoff angle, that defines the breadth of light cone emitted (also some other parameters). Typical example of a spotlight is flashlight, which is also implemented here.

Exploring the scene, what can you find in the top of the tower, in the dark? (SpongeBob? Or something else?)


Read here
Download (2.99 MB)
2025 downloads. 2 comments

Date: 29.12.2012

Finally! After endless 3 MONTHS break, new tutorial is here! It was supposed to be about shadows, but I decided to go with something less difficult, yet very useful and common in 3D graphics - 3D picking, so that you can select objects in 3D by (for example) clicking on them.

This tutorial is the first part, that shows color picking method. In part 2, I'll show alternative method for picking objects using ray casting.

I hope such a long break hasn't discouraged you to keep reading this webpage .


Read here
Download (4.07 MB)
1589 downloads. 6 comments

Date: 29.04.2013

Is it even possible? A new tutorial? New tutorial is here after almost 4 months and it shows a different approach to 3D picking by using ray casting. You cast a 3D ray beneath the cursor from near to far plane and then check for intersection with model's bounding sphere.

This approach can be used when you don't have a depth buffer reading available like on OpenGL ES 2.0, so you must do 3D picking in different way. It's up to you which one you choose. The first part rendered model's bouding box (or you can even render whole model to have things 100% exact), which was more precise, now you need to define some shapes with which you will check collision with (you can even check every triangle of model and ray intersection, but that would be horribly slow).

For this tutorial, I chose an easy object to represent model - a sphere, because checking ray-sphere collisions is pretty easy and it shows the concept well.


Read here
Download (4.09 MB)
1626 downloads. 5 comments

Date: 29.08.2013

5 months have passed and I come up with another tutorial - this one is rather simple and is about model loading using Assimp Library. I feel so bad about this incosistency, hope you guys forgive me :/

Forget about my old 15th tutorial that teaches you OBJ model loading - Assimp can load basically every common format of models and parses it into it's internal structures. We'll use these structures to construct OpenGL VAOs and VBOs for rendering. Ignore the file size, wolf model from them internets has too big tga textures, and my main editor can't open tga files, so I didn't bother with shrinking them .


Read here
Download (26.92 MB)
1925 downloads. 13 comments

Date: 04.10.2013

Hitting one month and one week mark (not that bad ) and another tutorial is here!

It's about rendering terrains using heightmaps loaded from images, where grayscale value in image represents height of that point.

Not only that, our heightmap has 3 layers of textures - in the lowest places there is fungus texture, going higher we transition into regular grass, and on top of heightmap there is a rock texture.

And still not only that ! I also add a special texture, which describes path going through that terrain.


Read here
Download (27.17 MB)
1552 downloads. 8 comments

Date: 24.02.2014

Yet another tutorial! This one after a long period of inactiveness. Endless stream of duties from school / band etc. .

This tutorial teaches you how to create specular highlights on objects. This is yet another of basic concepts when it comes to light. Specular highlight doesn't only depend on position of viewer, but also on position of the viewer.

Another thing, that's explained in this tutorial is how to display normals of a model using geometry shader .

Hope you guys forgive my endless, neverending breaks between consecutive tutorials .


Read here
Download (7.18 MB)
643 downloads. 5 comments

Date: 01.07.2014

After finishing university studies, I bring you another tutorial after more than 4 months. Better late than never right ?

This one teaches how to program particle system that's running almost entirely on GPU, making all these thousands of particles being updated on GPU rather than on CPU, leaving as CPU computational power for something else.

The main ingredient to this is transform feedback feature. This tutorial should open some new horizons of OpenGL 3.3, which I have never talked about before, so definitely try to read through this and learn as much as possible !


Read here
Download (4.56 MB)
475 downloads. 16 comments

Date: 15.07.2014

In a pretty quick succession (only 2 weeks!!! ) I bring you another tutorial - Animation Part 1. This tutorial teaches the easiest, yet pretty effective and nice method of animating a model using keyframes. One of the first (or even maybe very first) formats that used keyframe animations were Quake 2 models (*.md2). We will use these here. The animation calculations run inside the shader, so CPU is free again and graphical work is left to GPU .

Apart from that, I made this one in a way that you can really play around . Use Arrow Keys to move model around, Ctrl key to attack and other keys to change models and animations.

You can also see Blade Training Facility on the screenshot, led by Dr. Freak . Dr. Freak is one of the most common MD2 models I have encountered in many OpenGL based applications. Enjoy!


Read here
Download (5.89 MB)
512 downloads. 5 comments

Date: 31.08.2014

Tutorial with a pretty number 25 is here and this time it brings you a Bump Mapping technique, that adds a lot of realism by altering surface normals, so that the surface looks more "bumpy" without need of extra geometry and it's also not very computationally expensive, because it basically uses only Multitexturing and a new kind of math (never seen before to achieve this effect.

Extra stuff: Dr. Freak now has it's personal jet engine .


Read here
Download (12.56 MB)
311 downloads. 2 comments

Number of entries:

This webpage has been visited 723141 times since 29.01.2009.
Currently there are 29 people viewing this page.