Blog contents


Programming in C++11 and SDL2

Welcome to my blog abut C++11 and game programming in SDL2! Here you’ll find a list of all the tutorials on this blog.

Here you will find mainly tutorials on SDL2 and OpenGL but also a few other post. I try to make my tutorials a bit slow paced, dwelling a bit longer on each subject in order to be able to give more details and better understanding of each subject. This is hugely important because development is always hard when you don’t know all the details, how things work, what each line of coed does etc.

Hopefully my blogs will teach you all you need to make an awesome game!

If you have any questions about anything, please check out the forums.

Game programming in OpenGL ( and SDL2 )

My newest tutorial. Aims to teach you all about OpenGL and help you understand what each function does, how and when you should call it. This can be very hard in OpenGL ( a lot harder than in SDL2 ) but at the same time ; 3d is awesome!

You can find the OpenGL forum here.

Part 1 – Setting up OpenGL

OpenGL using SDL2. Using SDL2 with OpenGL makes it really easy. And it’ll all be multi-platform. And if you’ve already read my previous tutorials on SDL2, you already know a lot about using SDL2 with OpenGL

Game programming in SDL2

A tutorial about making games. Focuses a lot on SDL 2, but also other topics related to game programming. Some parts are pretty extensive so that you’ll get a deeper understanding about what’s going on.

You can find the SDL 2 forum here.

Part 1 – Setting up SDL 2

This part gives you a quick introduction to SDL 2. It’ll help you set up SDL2 including header files, linking and everything you need to get SDL 2 up and running. It also contains a bare-boned SDL2 program.

Setting up Visual Studio for SDL2

A guide on how to set up Visual Studio for SDL2 development. Also includes a fix for Visual Studio 2015 ( which failed when you tried to compile it with SDL2 stuff because they changed it. ) This guide also works for setting up additional libs like SDL2_image, SDL2_ttf and SDL2_net

Part 2 – Your first SDL 2 application

Here we take a look at the two basic structs of SDL 2, SDL_Window and SDL_Renderer. It’ll help you understand what these do and how to initialize them and the basics of SDL2 correctly. We also take a look at how to set the render color ( which also works as background color )

Part 3 – Drawing rectangles

Here we take a look at SDL_Rect and how to render it with SDL_RenderDrawRect and SDL_RenderFillRect.

Part 4 – Making things happen

About events in SDL 2. How to get the events, how the event structure, SDL_Event laid out, and how we do we handle the event.

Part 5 – Collision detection and our first game!

We learn how to check for collisions and make a simple game out of it.

Part 6 – Let’s load some textures!

In this part we take a look at SDL_Textures and how to create them from image files ( bmp. ) We also look at how to render SDL_Textures.

Part 7 – Using PNG files

We look at, and set up, SDL_Image library. This is used to load png files which then can be rendered with the transparency layer.

Part 8 – It’s TIME for another update!

Here we look at a new rendering function, SDL_RenderCopyEx. The function lets us render textures rotated. We use it to make a simple analog clock.

Part 9 – No more delays!

Up until now we’ve used SDL_Delay to limit framerate to ~16 FPS. We look at how to render using a delta time.

Part 10 – Text Rendering

Text rendering in games can be tricky. Luckily, SDL2_TTF does this for us. This part talks about SDL2_TTF, how to set it up and how to use it.

Part 11 – Text Styles

Now that we know how to render text, we look at how to set various styles like bold, italics, underline and strikethrough. We also quickly look at binary numbers and bitwise operations and use them to manipulate the various style flags.

Part 12 – Multiplayer ( UDP )

In order to get multiplayer functionality, we need to learn about networks / Internet and how it works. This part deals about UDP connections and how use them in SDL_net. It’ll over what you need to know in order to communicate via UDP

Part 13 – Multiplayer ( TCP )

In the previous part, we looked at UDP. This time we take a close look at TCP, see how it solves some of the problems UDP has. We also look at how to use SDL_net to do TCP communication ( without blocking )

C++11 Features

A series about the new features of C++11. I will try to explain everything thoroughly and extensively. The goal is to learn about C++11, how the various parts of it works and why you should use them.

I will cover both minor features like enum classes and larger ones like chrono

Part 1 – Enum classes

This is a very short part about the new version of enums, enum classes. It covers what they are and why you should use them as much as possible

Part 2 – Timing with chrono

This part is very extensive and covers the new timing features of C++11, chrono. It will help you when you’re dealing with timing in games and other applications.

My SDL2 Tutorial part 9 ( No more delays! ) also deals with chrono but this part covers it more extensively.

Part 3 – Smart pointers in C++11

About smart pointers in C++11 ( unique_ptr, shared_ptr and weak_ptr ) what they are, how they work and how to use them. You should always use smart pointers unless you have a really good to.

Part 4 – STL Iterators

About the four major iterator types in C++ ( input iterator, output iterator, forward iterator, bidirectional iterator and random-acces iterator ). We’ll look at what they do and don”t do and how to use them.

10 thoughts on “Blog contents”

    1. Hello,

      Thank you, I’m glad my posts are useful to people. =)

      Yes, actually SDL_net is one of the upcoming posts. I’ll be going through both TCP and UDP, pros and cons of each and how to use them. I hope to get around to it soon.

      Thanks for the tip, I’ll check it out when I’ve got the time

  1. Thank you so much. I really like your blog. Simple, clean and the codes work. I hope you share more especially toward real projects with using OOP. Sad I can’t use some of C++11, because I got stuck with visual studio 2010.

    1. I’ll see what I can do. I’ve been kinda busy lately, starting a new job, moving halfway across the country and stuff.

      For OOP stuff, it’s very usefull to experiment and try to write your own project from scratch. I might write a little about it in the future, but I have a few other tutorials I want to finish first.

      Why are you stuck with 2010? I think you can get free versions of every VS versions, including the newer ones.

  2. I’m learning SDL2 using CodeBlocks/MinGW on Windows, but would like to use OpenGL3 whenever possible..

    Can an SDL2 window that has rendered a texture containing shape primatives and/or images, also contain an OpenGL3 elements? Or because of the way it renders, you have to have separate windows for OpenGL3 and SLD2?

    It’d be nice to do draw a rectangle/text/png using pure SDL2 and pure OpenGL3 on the same window for comparison!

    Do you have any plans for making a simple ‘Hello World’ application using SDL2 and OpenGL3? For example how to setup ‘Glut’, ‘Glew’ or ‘glLoadGen’.

    1. Hello!

      I’m not completely sure about this as I haven’t tested it. But it sounds to me like it’s possible. I think the results will be more or less identical, though. Only that drawing is a lot simpler in SDL ; )

      SDL2 + OpenGL 3/4 will probably be my next tutorial. I really miss working with OpenGL, and setting up a rendering context using SDL2 is quite easy. This is a quick guide on how to set it up, it should help you on your way. ( 1.3 is the same as SDL2, it was just called 1.3 before it was properly released. )

  3. Good post! I read your blog often and you always post excellent content. I posted this article on Facebook and my followers like it. Thanks for writing this!

  4. whoa1h this blog is great i love reading your posts. Keep up the great work! You know, a lot of people are looking around for this information, you can aid them greatly.

Leave a Reply

Your email address will not be published. Required fields are marked *