Important
These tutorials are meant for OpenGL versions 1.x and 2.x. A lot of the information in these tutorials is outdated and either deprecated or removed in OpenGL 3.x and 4.x, so I have been writing some new tutorials on OpenGL 4.0. As you can see some of the tutorials here are (Version 2.0) which means they have been rewritten and include much more information, not only on OpenGL but explaining the fundamentals of the computer graphics behind the tutorials.
Unchanged:
- 1. OpenGL Window (Version 2.0)If you wish to learn OpenGL, then this is the very first tutorial for you. Learn how to create a GLUT window with an OpenGL context, and how to initially setup OpenGL.
- 2. OpenGL Window Reshaping (Version 2.0)Re-shaping a window with an OpenGL context can cause undesired scaling if not done correctly. If you wish to learn how to fix this, then this tutorial is for you. Learn how to setup your projection matrix with a viewing angle and both near and far planes.
- 3. OpenGL Keyboard Interaction (Version 2.0)Keyboard interaction can be handled by the user using system API calls, but why do that when you are already using GLUT which can handle this for you? This tutorial will focus on getting and using the keyboard with the help of GLUT.
- 4. OpenGL Primitives – Square (Version 2.0)One of the very first things you will want to do with OpenGL is learn how to draw shapes. OpenGL provides some basic shapes, which can then used to make complex 3D objects.
- 5. OpenGL Color (Version 2.0)Colour is one of the fundamental building blocks of a scene. Colours can be used to portray mood, realsim, fictions, intensity, or anything else. It's up to the artist, and in this case, you are the artist.
- 6. OpenGL Cube (Version 2.0)From basic 2D shapes, 3D shapes are built. And whilst complex, there are some which are provided to us by GLUT, one of those being your standard cube, made up of 12 triangles and 8 vertices, why hand code it yourself?
- 7. OpenGL Rotation and Translation (Version 2.0)Placing objects in a 3D scene is nice, but often enough, you want to be able to move and interact with these shapes. Here you will learn how to rotate them with a single command.
- 8. OpenGL Buffering (Version 2.0)While single buffering still displays our final image, it can cause artifacts. Double buffering lets us draw everything in a second buffer, and when finished, lets us transfer it to the screen for a smoother application.
- 9. OpenGL Blending (Version 2.0)Colours can be mixed and matched in OpenGL, just like in real life. Here you will learn how to blend shapes using OpenGL, allowing you to overlay shapes on top of each other to get the most realism you can.
- 10. OpenGL Scaling (Version 2.0)Drawing shapes is fine, moving them about is fine. But do you always want a shape to be the same size? Are all tree's the same height? Of course not. Here I will show you how to scale your 3D shapes.
- 11. OpenGL Lighting (Version 2.0)Flatly colouring shapes is perfect, if we want an unrealistic look to our scene. But for realism, we really want to add some sort of lighting system. You can learn here how to use OpenGL's lighting system for a more realistic scene.
- 12. OpenGL Materials and Lighting (Version 2.0)Now you have your scene looking a little nicer with some lighting, but all objects are a gray colour. Here we will learn how to assign materials to shapes to change how they look under different lighting conditions.
- 13. OpenGL Lighting Types (Version 2.0)OpenGL provides us with not one, but three different types of lights we can make, directional lights, point lights and spot lights. I will try to teach you about how each is different, and how to use them.
- 14. OpenGL Fog (Version 2.0)Ever notice how on a clear day, your visibility seems to go on for miles, but when the weather changes, a nice misty fog may come over, and your vision can be reduced to virtually nothing? Well OpenGL has it's own fog system we can take advantage of if we wish to re-create this natural ...
- 15. OpenGL Fog Types (Version 2.0)Just like there are different types of lighting in OpenGL, we also have different types of fog for different effects. Learn how to use them in this tutorial.
- 16. OpenGL Texturing (Version 2.0)The next step in the quest for realism after lighting, comes in the form of texturing. Texturing is the art of drawing an image on top of a 3D object and is the core behind all 3D applications. Could you imaging Half Life 2 coming out, and the characters looked like store mannequins?
- 17. OpenGL Texture Coordinate Generation (Version 2.0)When assigning a texture to an object, you need to declare the texture coordinates, little values between 0 and 1 that tell us which part of the image maps to which part of the 3D model. OpenGL has some texture coordinate methods for generic texturing.
- 18. OpenGL Popping and Pushing Matrices (Version 2.0)When drawing objects in OpenGL, it can be annoying that you do a translation, and then before drawing the next shape, you have to do a reverse translation to fix your positions. Well OpenGL being a state machine, has the ability to pop and push the current model view matrix, meaning you push on a ...
- 19. OpenGL Fullscreen Mode (Version 2.0)Most games we know, run in fullscreen mode, and lucky for us, GLUT provides this ability also. So let me show you how to make use of it.
- 20. OpenGL MipMap Generation (Version 2.0)Mip maps are an essential texture extension, which creates scaled down versions of a texture and uses them when an object gets further away, or closer to the near plane. This scaled down version of the texture, makes for nicer, smoother looking textures.
- 21. OpenGL Display Lists (Version 2.0)Display lists are a cached version of a set of OpenGL calls, which can be called again and again, at quicker framerates than writing the code over and over again. There is much controversy over the use of these against Vertex Buffer Objects in relation to speed, so I will show you both, starting with ...
- 22. OpenGL Camera (Version 2.0)If you look at making any game where the scene is larger than can be displayed in the window at once, then you are going to need some type of camera system. This is the first of several tutorials on building a first person camera system.
- 23. OpenGL Camera Part 2 (Version 2.0)Here I will be extending upon the previous OpenGL Camera tutorial, and adding a strafe feature (moving side to side). A game without strafing, is going to be terrible, especially when it comes to multiplayer when strafing against enemy fire is essential.
- 24. OpenGL Camera Part 3 (Version 2.0)The first person camera is done, lets take a look at the third person camera, which is essential any type of Role Playing Game. The best part is, this tutorial uses most of the same code as the previous camera tutorial. Just some minor changes to entirely change the feel of your game.
- 25. OpenGL Vertex Coloring (Version 2.0)Along with assigning colours to objects, did you know you can also set colours to individual vertices? Well yes, yes you can.
- 26. OpenGL Vertex Alphas (Version 2.0)Alpha values, just like colours, can be assigned on a per-vertex basis. This allows for varying levels of transparency across objects.
- 27. OpenGL Basic Shadows (Version 2.0)With lighting, comes shadowing. This tutorial takes a basic stencil buffer, and uses it as a stencil to draw a basic shadow on to it.
- 28. OpenGL Basic Reflection (Version 2.0)Just like our shadowing tutorial, this one uses the stencil buffer, but we are going to keep our color buffer enabled to allow us to keep our colors for a basic reflection.
- 29. OpenGL Bounding Sphere Collision (Version 2.0)At present, none of our OpenGL shapes can interact with each other, that is because OpenGL is purely graphics, it doesn't handle physics, so using the Euclidean distance algorithm, we can implement some basic bounding sphere collision ourselves.
- 30. OpenGL Circle Drawing (Version 2.0)Circles are one of the few shapes that are not default in OpenGL, but the good news is, they are easily created using lines. In this tutorial, I will show you how to draw a nice, round, circle.
- 31. OpenGL Sphere Creation (Version 2.0)While GLUT provides a sphere for us to draw, that sphere does not contain texture coordinates. In this tutorial, I will show you how to create your own sphere, which has texture coordinates included. Now you can make that solar system demo you have always wanted!
- 32. OpenGL Particle Engine (Version 2.0)Lets face it, particles are ALOT of fun. Whether you want to create a weather system, some awesome fire, or just throw a million objects around randomly, they are both stimulating in a game, and fun.
- 33. OpenGL Animating Textures (Version 2.0)Textures by themselves are perfectly fine, you don't have to do anything with them. But have you ever wanted to load a movie into a 3D scene? Maybe you want to read a movie file, and display it on a quad moving around your scene. Well you can, but you have to do it frame, ...
- 34. Orthogonal Projections (Version 2.0)While OpenGL is built for 3D rendering, it does also support 2D. This is where you want orthogonal projections, which are perfect for a Heads Up Display, or a menu system.
- 35. OpenGL Tiling Engine (Version 2.0)If you want to create a game like Sim City, or an RPG, then you are going to need some sort of tiling engine. This breaks up the ground into a bunch of known images and places them on runtim. This saves us having extremely large image files for an entire map and also makes ...
- 6. Terrain Vertex Buffer ObjectsVertex Buffer Objects are used to store vertices, their indices and other information on the graphics card, for OpenGL to access directly. They are extremely fast and effecient, and are meant to supersede Display Lists. So lets use them for our terrain!
- 1. OpenGL DriversThe OpenGL drivers can be tricky for some people to find, and whilst I recommend using GLEW and FreeGLUT, feel free to download these files, although they may be out of date.
- 3. OpenGL TipsHere is a collection of tips for using OpenGL that I have started compiling, expect it to grow 🙂
- 36. OpenGL Framebuffers (Version 2.0)If you want to use any type of off screen rendering process, then frame buffers are probably the go for you. They allow you to render an entire scene, directly to a texture.
Unchanged:
- 1. OpenGL Window (Version 2.0)If you wish to learn OpenGL, then this is the very first tutorial for you. Learn how to create a GLUT window with an OpenGL context, and how to initially setup OpenGL.
- 2. OpenGL Window Reshaping (Version 2.0)Re-shaping a window with an OpenGL context can cause undesired scaling if not done correctly. If you wish to learn how to fix this, then this tutorial is for you. Learn how to setup your projection matrix with a viewing angle and both near and far planes.
- 3. OpenGL Keyboard Interaction (Version 2.0)Keyboard interaction can be handled by the user using system API calls, but why do that when you are already using GLUT which can handle this for you? This tutorial will focus on getting and using the keyboard with the help of GLUT.
- 4. OpenGL Primitives – Square (Version 2.0)One of the very first things you will want to do with OpenGL is learn how to draw shapes. OpenGL provides some basic shapes, which can then used to make complex 3D objects.
- 5. OpenGL Color (Version 2.0)Colour is one of the fundamental building blocks of a scene. Colours can be used to portray mood, realsim, fictions, intensity, or anything else. It's up to the artist, and in this case, you are the artist.
- 6. OpenGL Cube (Version 2.0)From basic 2D shapes, 3D shapes are built. And whilst complex, there are some which are provided to us by GLUT, one of those being your standard cube, made up of 12 triangles and 8 vertices, why hand code it yourself?
- 7. OpenGL Rotation and Translation (Version 2.0)Placing objects in a 3D scene is nice, but often enough, you want to be able to move and interact with these shapes. Here you will learn how to rotate them with a single command.
- 8. OpenGL Buffering (Version 2.0)While single buffering still displays our final image, it can cause artifacts. Double buffering lets us draw everything in a second buffer, and when finished, lets us transfer it to the screen for a smoother application.
- 9. OpenGL Blending (Version 2.0)Colours can be mixed and matched in OpenGL, just like in real life. Here you will learn how to blend shapes using OpenGL, allowing you to overlay shapes on top of each other to get the most realism you can.
- 10. OpenGL Scaling (Version 2.0)Drawing shapes is fine, moving them about is fine. But do you always want a shape to be the same size? Are all tree's the same height? Of course not. Here I will show you how to scale your 3D shapes.
- 11. OpenGL Lighting (Version 2.0)Flatly colouring shapes is perfect, if we want an unrealistic look to our scene. But for realism, we really want to add some sort of lighting system. You can learn here how to use OpenGL's lighting system for a more realistic scene.
- 12. OpenGL Materials and Lighting (Version 2.0)Now you have your scene looking a little nicer with some lighting, but all objects are a gray colour. Here we will learn how to assign materials to shapes to change how they look under different lighting conditions.
- 13. OpenGL Lighting Types (Version 2.0)OpenGL provides us with not one, but three different types of lights we can make, directional lights, point lights and spot lights. I will try to teach you about how each is different, and how to use them.
- 14. OpenGL Fog (Version 2.0)Ever notice how on a clear day, your visibility seems to go on for miles, but when the weather changes, a nice misty fog may come over, and your vision can be reduced to virtually nothing? Well OpenGL has it's own fog system we can take advantage of if we wish to re-create this natural ...
- 15. OpenGL Fog Types (Version 2.0)Just like there are different types of lighting in OpenGL, we also have different types of fog for different effects. Learn how to use them in this tutorial.
- 16. OpenGL Texturing (Version 2.0)The next step in the quest for realism after lighting, comes in the form of texturing. Texturing is the art of drawing an image on top of a 3D object and is the core behind all 3D applications. Could you imaging Half Life 2 coming out, and the characters looked like store mannequins?
- 17. OpenGL Texture Coordinate Generation (Version 2.0)When assigning a texture to an object, you need to declare the texture coordinates, little values between 0 and 1 that tell us which part of the image maps to which part of the 3D model. OpenGL has some texture coordinate methods for generic texturing.
- 18. OpenGL Popping and Pushing Matrices (Version 2.0)When drawing objects in OpenGL, it can be annoying that you do a translation, and then before drawing the next shape, you have to do a reverse translation to fix your positions. Well OpenGL being a state machine, has the ability to pop and push the current model view matrix, meaning you push on a ...
- 19. OpenGL Fullscreen Mode (Version 2.0)Most games we know, run in fullscreen mode, and lucky for us, GLUT provides this ability also. So let me show you how to make use of it.
- 20. OpenGL MipMap Generation (Version 2.0)Mip maps are an essential texture extension, which creates scaled down versions of a texture and uses them when an object gets further away, or closer to the near plane. This scaled down version of the texture, makes for nicer, smoother looking textures.
- 21. OpenGL Display Lists (Version 2.0)Display lists are a cached version of a set of OpenGL calls, which can be called again and again, at quicker framerates than writing the code over and over again. There is much controversy over the use of these against Vertex Buffer Objects in relation to speed, so I will show you both, starting with ...
- 22. OpenGL Camera (Version 2.0)If you look at making any game where the scene is larger than can be displayed in the window at once, then you are going to need some type of camera system. This is the first of several tutorials on building a first person camera system.
- 23. OpenGL Camera Part 2 (Version 2.0)Here I will be extending upon the previous OpenGL Camera tutorial, and adding a strafe feature (moving side to side). A game without strafing, is going to be terrible, especially when it comes to multiplayer when strafing against enemy fire is essential.
- 24. OpenGL Camera Part 3 (Version 2.0)The first person camera is done, lets take a look at the third person camera, which is essential any type of Role Playing Game. The best part is, this tutorial uses most of the same code as the previous camera tutorial. Just some minor changes to entirely change the feel of your game.
- 25. OpenGL Vertex Coloring (Version 2.0)Along with assigning colours to objects, did you know you can also set colours to individual vertices? Well yes, yes you can.
- 26. OpenGL Vertex Alphas (Version 2.0)Alpha values, just like colours, can be assigned on a per-vertex basis. This allows for varying levels of transparency across objects.
- 27. OpenGL Basic Shadows (Version 2.0)With lighting, comes shadowing. This tutorial takes a basic stencil buffer, and uses it as a stencil to draw a basic shadow on to it.
- 28. OpenGL Basic Reflection (Version 2.0)Just like our shadowing tutorial, this one uses the stencil buffer, but we are going to keep our color buffer enabled to allow us to keep our colors for a basic reflection.
- 29. OpenGL Bounding Sphere Collision (Version 2.0)At present, none of our OpenGL shapes can interact with each other, that is because OpenGL is purely graphics, it doesn't handle physics, so using the Euclidean distance algorithm, we can implement some basic bounding sphere collision ourselves.
- 30. OpenGL Circle Drawing (Version 2.0)Circles are one of the few shapes that are not default in OpenGL, but the good news is, they are easily created using lines. In this tutorial, I will show you how to draw a nice, round, circle.
- 31. OpenGL Sphere Creation (Version 2.0)While GLUT provides a sphere for us to draw, that sphere does not contain texture coordinates. In this tutorial, I will show you how to create your own sphere, which has texture coordinates included. Now you can make that solar system demo you have always wanted!
- 32. OpenGL Particle Engine (Version 2.0)Lets face it, particles are ALOT of fun. Whether you want to create a weather system, some awesome fire, or just throw a million objects around randomly, they are both stimulating in a game, and fun.
- 33. OpenGL Animating Textures (Version 2.0)Textures by themselves are perfectly fine, you don't have to do anything with them. But have you ever wanted to load a movie into a 3D scene? Maybe you want to read a movie file, and display it on a quad moving around your scene. Well you can, but you have to do it frame, ...
- 34. Orthogonal Projections (Version 2.0)While OpenGL is built for 3D rendering, it does also support 2D. This is where you want orthogonal projections, which are perfect for a Heads Up Display, or a menu system.
- 35. OpenGL Tiling Engine (Version 2.0)If you want to create a game like Sim City, or an RPG, then you are going to need some sort of tiling engine. This breaks up the ground into a bunch of known images and places them on runtim. This saves us having extremely large image files for an entire map and also makes ...
- 6. Terrain Vertex Buffer ObjectsVertex Buffer Objects are used to store vertices, their indices and other information on the graphics card, for OpenGL to access directly. They are extremely fast and effecient, and are meant to supersede Display Lists. So lets use them for our terrain!
- 1. OpenGL DriversThe OpenGL drivers can be tricky for some people to find, and whilst I recommend using GLEW and FreeGLUT, feel free to download these files, although they may be out of date.
- 3. OpenGL TipsHere is a collection of tips for using OpenGL that I have started compiling, expect it to grow 🙂
- 36. OpenGL Framebuffers (Version 2.0)If you want to use any type of off screen rendering process, then frame buffers are probably the go for you. They allow you to render an entire scene, directly to a texture.
I have some difficulty for export code into Xcode (Apple) code… Objective-c not swift
…
Great tutorials.It gave me a hope to enter into graphics field.I wish that more tutorials should be published
Keep up the good work, your 2.0 tutorials beautiful !
Thanks for this beautiful tutorial
nice tutorials thanks, to shear this tutorial. i will wait to get more tutorials…..
brilliant tutorial swiftless.
will you be doing any tutorials on memory allocation?
Great tutorial……. can you please provide any tutorial for page flipped stereo image rendering… thanks a lot 🙂
Great Tutorial…….But from tutorial no.8 when I copied the code it didn’t compile, it had lots and lots of errors
Hi Shivam,
From no.8 and onwards, those are older tutorials. I’m guessing your errors were related to library issues but copy and paste could have been formatting errors due to special characters. I’m trying to find the time to update the remainder of the tutorials.
Cheers,
Swiftless
this was such a shit life….my head were struggling for a while…its so difficult
I want to do texture mapping in Linux. I searched many sites but i didn’t get it. Will you please help me with a simple texture mapping tutorial in linux?
Thanking in advance
ThanQ for making this easy ans intrusting
Great tutorials, really easy to understand. Tysm 🙂
Thanks for posting these, its my intention to learn open gl just for kicks and these are really well structured and organised tutorials. Just what I need. If this isnt worth a book mark i dont know what is.
Awesome please make some new Physx tutorials aswell 😉
i want to rotate, translate,scale and shear all of this shape. please help me soon.
ebrahim firouzi (nilicity@gmail.com)
code is here in c++ , opengl
===================
/*
* Desaigned by Ebrahim Firouzi
* Graphic project
* professor : Dr. Yaghmayee
*82
*/
#include // also included gl.h, glu.h
void display() {
glClear(GL_COLOR_BUFFER_BIT); // Clear all screen
//part 1 of home
glBegin(GL_QUADS); // Each set of 4 vertices form a quad
glColor3f(1.0f, 0.0f, 1.0f); // pink
glVertex2f(-0.3f, -0.2f); // x, y
glVertex2f(-0.1f, -0.2f);
glVertex2f(-0.1f, 0.3f);
glVertex2f(-0.3f, 0.3f);
glEnd();
//part 2 of home
glBegin(GL_TRIANGLES); // Each set of 3 vertices form a triangle
glColor3f(0.0f, 1.0f, 0.0f); // Green
glVertex2f(-0.3f, 0.3f);
glVertex2f(-0.1f, 0.3f);
glVertex2f(-0.2f, 0.5f);
glEnd();
//part 3 of home
glBegin(GL_POLYGON); //draw square
glColor3f(0.0, 1.0, 1.0);
glVertex2f(0.20, 0.0);
glVertex2f(0.20, 0.40);
glVertex2f(-0.1f, 0.3f);
glVertex2f(-0.1f, -0.2f);
glEnd();
//part 4 of home
glBegin(GL_POLYGON); //draw square
glColor3f(1.0, 1.0, 0.0);
glVertex2f(0.20, 0.40);
glVertex2f(0.10, 0.55);
glVertex2f(-0.2f, 0.5f);
glVertex2f(-0.1f, 0.3f);
glEnd();
//part 5 of home
glBegin(GL_QUADS); // Each set of 4 vertices form a quad
glColor3f(0.0f, 0.0f, 1.0f); // pink
glVertex2f(-0.19, -0.2f); // x, y
glVertex2f(-0.1f, -0.2f);
glVertex2f(-0.1f, 0.07);
glVertex2f(-0.19, 0.07);
glEnd();
glFlush(); // Render now
}
// GLUT runs as a Console Application
int main(int argc, char** argv) {
glutInit(&argc, argv); // Initialize GLUT
glutInitWindowPosition(180, 80) ; //position of output window
glutInitWindowSize(1000, 600) ; // window size
glutCreateWindow(“Ebrahim Firouzi Graphic Project”); // Create a window with the given title
glutDisplayFunc(display); // Register callback handler for window re-paint
glutMainLoop(); // Enter infinitely event-processing loop
return 0;
}
Really the brilliant tutorials. I like them so much. Thanks for publishing these tutorials.
Morning, can u help me about make a transformer in open gl Visual C++??
u can send the source code in my email : jonathan_rere_kudus@yahoo.com
hi swiftless,,your tutorial is very informative really easy to understand,,can you make a tutorial how to create simple text in opengl?i’ve search a lot but it seems i cant find any tutorial that i can understand(im a newbies in programming.)thx a lot.
Please tell me to import 3d models of auto cad and googe sketchup…..
Thanks for the great tutorials. Please do not remove your OpenGL 1.x or 2.x tutorials, because many of us Linux/Mesa3D users are still living in the dark ages when it comes to OpenGL implementation. 🙁 Cheers.
Jeremy
Cool stuff 😉
thanku swiftless..i had no idea about opengl and i learnt a lot..:-)
Excellent tutorials. Very detailed. Very understandable. However there must be a tutorial for loading 3d models of various formats (.obj for instance) from 3d modeling software (Blender for instance) into OpenGL.
add a 3D rendering code for ct images.that is 2D to 3D conversion code
THANKS A LOT. This is one of the only site with such a complete Glut/OpenGL tutorial.
Maybe a little complement on how to include these in different programming environments (Visual Studio on Windows, XCode on Mac…).
add some more..great work
Please, more tutorials! Perhaps on more advanced rendering, like deferred shading, HDR, motion blur, frustrum culling techniques, anything like that? Showing how to use GLSL for ocean simulation (waves, shore fogging, underwater stuff…)
Your tutorials are great, please make more! 🙂