SDL 2.0 Texture Bank

Tim Jones    |     March 18th, 2014    |     4 comments
The 2nd part of revamping code to SDL 2.0 is up on GitHub. It focuses around loading and rendering textures, along with a few other useful classes (I've gone beyond what I did in the past with the SDL 1.2 tutorials). You can see a simple outline below:

Texture Class
Wrapper class for SDL_Textures. Makes it easier to load and render textures.

Texture Bank Class
Helps manage multiple textures, and auto-loads textures.

File Manager Class
Utility class for saving and loading files, listing files inside of a directory, and a few other useful methods.

Stringify Class
Small utility class useful for converting to and from strings.

You can find the code here:

A serious question for everyone out there. I've been debating making multiple repos for each possible tutorial, or making one master repo with all my code (which would essentially make up an SDL game engine), and then making tutorials later based off of that one repo. Please let me know in the comments below if you would prefer one repo or multiple repos. My fear is that repos will become out of sync as code is updated, and that some people will not realize other repos exist. Thanks!

SDL 2.0.3

Tim Jones    |     March 17th, 2014    |     0 comments
Official SDL Announcement
This is a minor bugfix release to take care of creating an OpenGL context on Mac OS X 10.6:

SDL Announcements

SDL 2.0 Basics and Textures

Tim Jones    |     March 13th, 2014    |     0 comments
I have two repos up on GitHub so far with code for SDL 2.0. You can find them here:

One is a basic foundation code for getting SDL 2.0 working. The other is for wrapping SDL_Textures into another Texture class. I'll most likely update the Texture code to also include TextureBank class.

Keep checking back for updates.
SDL Tutorials

GitHub and SDL 2.0

Tim Jones    |     March 11th, 2014    |     0 comments
I have begun the process of coding new tutorials for SDL 2.0. I am first going to code the new tutorial series and sync to GitHub here:

This will allow me to get the code out fairly quickly and allow a majority of the readers to benefit from the new code. Comments, forks, and the like are welcome as the new tutorial serious is put together.

The actual tutorial that explains the code will come at a later date. Also, please note that these tutorials are going to be new and independent of the old SDL 1.2 tutorials. However, the goal of demonstrating how to create games is still going to be the focus.

Have fun!
SDL Tutorials

SDL 2.0.2

Tim Jones    |     March 10th, 2014    |     0 comments
Official SDL Announcement

Download SDL 2.0.2
Thanks to everyone who contributed, SDL 2.0.2 is now available!

In addition to numerous bug fixes, here are the major changes since 2.0.1:
* Added SDL_GL_ResetAttributes() to reset OpenGL attributes to default values
* Added an API to load a database of game controller mappings from a file:
    SDL_GameControllerAddMappingsFromFile(), SDL_GameControllerAddMappingsFromRW()
* Added game controller mappings for the PS4 and OUYA controllers
* Added SDL_GetDefaultAssertionHandler() and SDL_GetAssertionHandler()
* Added SDL_DetachThread()
* Added SDL_HasAVX() to determine if the CPU has AVX features
* Added SDL_vsscanf(), SDL_acos(), and SDL_asin() to the stdlib routines
* EGL can now create/manage OpenGL and OpenGL ES 1.x/2.x contexts, and share
* Added a field "clicks" to the mouse button event which records whether the event is a single click, double click, etc.
* The screensaver is now disabled by default, and there is a hint SDL_HINT_VIDEO_ALLOW_SCREENSAVER that can change that behavior.
* Added a hint SDL_HINT_MOUSE_RELATIVE_MODE_WARP to specify whether mouse relative mode should be emulated using mouse warping.
* testgl2 does not need to link with libGL anymore
* Added testgles2 test program to demonstrate working with OpenGL ES 2.0
* Added controllermap test program to visually map a game controller

* Support for OpenGL ES 2.x contexts using either WGL or EGL (natively via
  the driver or emulated through ANGLE)
* Added a hint SDL_HINT_VIDEO_WIN_D3DCOMPILER to specify which D3D shader compiler to use for OpenGL ES 2 support through ANGLE
* Added a hint SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT that is useful when creating multiple windows that should share the same OpenGL context.
* Added an event SDL_RENDER_TARGETS_RESET that is sent when D3D9 render targets are reset after the device has been restored.

Mac OS X:
* Fullscreen desktop mode now uses spaces for a more fluid Mac experience.
* Added a hint SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK to control whether Ctrl+click should be treated as a right click on Mac OS X. This is off by default.

* Fixed fullscreen and focused behavior when receiving NotifyGrab events
* Added experimental Wayland and Mir support, disabled by default

* Joystick support (minimum SDK version required to build SDL is now 12,
  the required runtime version remains at 10, but on such devices joystick
  support won't be available).
* Hotplugging support for joysticks
* Added a hint SDL_HINT_ACCELEROMETER_AS_JOYSTICK to control whether the accelerometer should be listed as a 3 axis joystick, which it will by default.

SDL Announcements

Game Development with SDL 2.0

Tim Jones    |     March 7th, 2014    |     0 comments
Check out this video talking about SDL 2.0 from Steam Dev Days.

SDL Announcements
SDL Tips

German Translation

Tim Jones    |     August 27th, 2012    |     3 comments
We now have a German translation of "SDL Tutorial Basics" thanks to Nicolas. You'll find flag icons at the top of the page to switch which Language you are reading. Thanks!

Or click here: German Version of SDL Tutorial Basics

Spring Contest 2012 Winner

Tim Jones    |     May 16th, 2012    |     13 comments
And the winner for the Spring Contest 2012 is...

Spring Contest 2012 Poll

Tim Jones    |     May 7th, 2012    |     17 comments
It's that time now to pick the best game. Remember not to only look at game play, but also the source code.

Spring Contest 2012

Tim Jones    |     April 10th, 2012    |     11 comments
It's that time again boys and girls. This time I decided to do something a bit different. Instead of trying to clone a specific game or develop a game for a specific genre, I will give you a theme and everyone can choose what sort of game to create based off of that theme (thanks Aaru for the idea). The time frame for this contest is much shorter than previous contests. Better get crackin'. Rules past the break.

First Foray into SDL/OpenGL

OpenGL handles the drawing of models in a window but it does not provide the window, or handle events; that is why SDL is required. The prime purpose of this tutorial is to set up the SDL window and events mechanism. It also sets up the OpenGL environment that uses the window, the game loop, and a rotating cube.

Huh? My Pong clone uses 100% CPU and is still slow?

Your program is being a CPU hog! In some cases, this situation can actually make your program run slowly! Your code needs to give some time back to the OS (i.e. delay or sleep).

Setting up MonoDevelop to run Tao

A new series from Stephen Jones demonstrating how to use C#, Mono, and Tao to develop SDL / OpenGL games.