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.
First of the upcoming series of OpenGL 3.3 (and later) tutorials. Describes how to create OpenGL 3.3 rendering context on Windows.
Download (119 KB)
11393 downloads. 33 comments
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).
Download (120 KB)
5442 downloads. 15 comments
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.
Download (128 KB)
5819 downloads. 13 comments
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.
Download (135 KB)
5531 downloads. 13 comments
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.
Download (139 KB)
4693 downloads. 3 comments
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 , but it's far more realistic than just colored triangles ).
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 (actually it's already here in Slovakia), we will use ice texture in this tutorial .
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.
Download (1.74 MB)
6357 downloads. 21 comments
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... (well not that far, but not now)
Download (1.26 MB)
3720 downloads. 3 comments
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 . I hope you'll like how sun looks ! Move around with WSAD keys, change sun's position with LEFT and RIGHT arrow keys to change direction of light.
Download (1.43 MB)
5285 downloads. 8 comments
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.
Download (1.43 MB)
4057 downloads. 8 comments
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 ).
After going through this tutorial, you shouldn't have problem applying as many textures on your object, as your hardware supports .
I also explain how to remove problem with flickering of scene, when looking at scene from far away.
Download (2.16 MB)
3666 downloads. 2 comments
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.
Download (2.13 MB)
3490 downloads. 1 comments
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 .
Download (2.16 MB)
3603 downloads. 5 comments
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 ).
Download (2.22 MB)
3664 downloads. 11 comments
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 .
Download (3.25 MB)
9407 downloads. 15 comments
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 .
Download (3.32 MB)
3420 downloads. 6 comments
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?)
Download (2.99 MB)
3589 downloads. 5 comments
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 .
Download (4.07 MB)
3020 downloads. 10 comments
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.
Download (4.09 MB)
3214 downloads. 7 comments
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 .
Download (26.92 MB)
4794 downloads. 19 comments
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.
Download (27.17 MB)
4034 downloads. 16 comments
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 .
Download (7.18 MB)
2009 downloads. 9 comments
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 !
Download (4.56 MB)
2385 downloads. 20 comments
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!
Download (5.89 MB)
2111 downloads. 10 comments
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 .
Download (12.56 MB)
1896 downloads. 9 comments
After almost 3 months of silence, I managed to bring you a new tutorial! This one is about basics of shadow mapping and I hope you will enjoy it .
Shadow mapping works briefly in following way: render the scene from the light's point of view, use the depth buffer of rendered result and make it a texture, and apply this texture to the scene. This texture is called shadow map. The quality of the shadows depends on the chosen shadow map size.
You can play around with many things in this tutorial - change shadow map size, light direction and also move around with Hobo Goblin and shoot arrows with SPACE . So enjoy this tutorial and your day (Carpe Diem ).
Download (11.76 MB)
1774 downloads. 10 comments
Time is passing by and another tutorial has come! This one is pretty useful and is about conditional rendering using occlusion queries .
Occlusion query is a mechanism, using which you can ask whether the object is visible and if it's sure that the object is not visible, there is no need to render it. Before rendering the whole complex object, we first render its bounding box, but not for real - we just asked how many pixels (fragments) would get affected with this render. If 0 pixels were affected, that means, that the bounding box is not visible therefore the whole complex objects can't be visible either.
Our complex object is sphere. Interesting thing that I found and you can also play with - if the sphere is poorly tesselated, the occlusion query actually dropped my FPS, but from some point, the rendering gets speed up signficantly. You can change the sphere tesselation values in the ini file sphere.ini .
Download (4.94 MB)
1099 downloads. 6 comments
Another tutorial is up! This time I decided to upgrade the fonts that we have learned previously in the tutorial 9 - new fonts support Unicode characters and also run faster and more efficiently .
So finally you can print out text with OpenGL in your favorite language !!!
Download (5.15 MB)
852 downloads. 4 comments
Finally I managed to finish this tutorial. As always, the lack of time and sometimes my laziness didn't allow me to finish the tutorial as I promised (who would believe my schedule now anyways ). One way or another, the tutorial, that improves the quality of our terrain is here - I programmed a grass, that covers the terrain, waves, you can also change the direction of wind in the shader and so on. I hope you will enjoy this tutorial .
Download (5.56 MB)
1070 downloads. 7 comments