My efforts to make coding with pure C and SDL2 more clear and fun.
A Collection of SDL2 C Tutorials and Demos, SDL2 with OpenGL /
Vulkan and other APIs. Procedural Sounds and Graphics, plus GLSL Shaders for Game-Programming and general purpose. All done in pure C.
Because C is seeing! =)
Feel free to contact me for criticism, Demo Requests or whatever!
Oh, you can use the code as you wish, but don’t blame me!
I am trying to cover the SDL2-API as needed, OpenGL, Vulkan and a couple of other common API’s like curl or jannson, tho this is pure C and mainly Linux orientated, doesn’t mean I don’t cross-compile for Windows or Android. If you need a german translation I could make that happen. SDL-Audio Series and Joystick/Gamecontroller Series are nearly finished, just polishing it. At the same time I am building up my C-Snippets, but I am pretty behind on that. SDL_net 2.0 isn’t covered yet.
Procedural Sound Annotation
I spent quite some time on that topic and decided that it’s not worth going further. The Hardware isn’t there yet. The focus of the past few decades was to improve GPU’s. Common audio chips are simpler than ever, if one compares the complexity of a GPU and an audio chip it is clear that the audio chip doesn’t reveal a lot functionality.
If you struggle with getting things up and running, refer to one of those pages: Will Usher or Lazy Foo. For Mac OS: Setting Up An SDL2 Project in Xcode 9 or without Xcode. And if you wish to use SDL2 with CMake: Trenki’s Dev Blog
This is a set of small introductory programs. It’s about the window, the window icon, a custom cursor, surfaces, Pixel Manipulation and how to save a screenshot.
An Introduction to the Rendering Subsystem.
- Create a texture from surface, render it flipped, mirrored and rotated.
- Take Screenshot with RenderReadPixels.
- Render and animate a colorful gradient like a new shadertoy one.
- Shows a bit how glsl works and why we want shaders.
Records the duration how long left MouseButton is pressed.
Program quits after a certain amount of time.
Put it together
Create Spritesheet from gif and render it timed.
Let rect follow the mouse.
It is a follow up from Mousegrab. Shows how to make a Slider.
Drag and Drop
Drag and Drop. Receiving Text and Files via SDL_DropEvent.
Play music with SDL2 Repo
Use of SDL-Mixer for Music.
Use of SDL-Mixer for Sound.
Put it together
Use of SDL-Mixer and GUI-Elements.
Rapid Parallax implementation with 6 Layers.
Roll your own titlebar.
This is a series about the SDL-Extension SDL_ttf 2.0
In the surfaces-series I did some naive linear animations and scaling. This is a demo series about non linear animations. To get more control I am gonna use floats here, now I need some non linear functions. Math provides tons of those functions. In computer graphics shaping functions are well known and used to create procedural graphics, too. But, one can use those functions also to shape the time-steps, positions or colors.
Repository with Python 3 mathplotlib sources included.
This is a series about physics - SI-Units, Velocity, Acceleration, Gravity, Friction etc.
Artificial intelligence (AI)
How to apply De Casteljau’s algorithm on a quadratic Bézier curve.
Re-Render a part of the screen using
This small demo shows how to use TextureColorMod.
A simple Game
My scaleable Pong implementation. You can take over two player control anytime, the AI will take over if you go afk. A mingw Windows 64 build is in the Makefile.
This is a small SDL2 text API demo
Plays an animated gif - pauseable and scaleable. uses: SDL_gifwrap Repo by Jonathan Dearborn
SDL and OpenGL
SDL2-OpenGL Repo This is a starter series about GLSL Shaders using SDL2 as OpenGL Helper and a bit Shader-Language for C-Coders.
NanoVG-SDL2 starter Repo Startup Code to use SDL2/OpenGL/NanoVG
Using SDL2 to show Shadertoy GLSL Fragment Shaders.
Features “drag and drop”, Auto-Screenshot with shadername, editing with Auto-Compile.
WIP: Finishing SDL2-Audio right now, to move on to FFT and finally implement
visualization of GLSL shaders with low latency.
Demo using SDL2 Image, SDL2 TTF, SDL2 Mixer.
Flipping Bits on a real char and visualize that.
C&C++ mixed Code:
Classic Pong and Breakout stuff Ressources covering Atari’s classic game.
C++ game engine skeleton with GNU-Makefile
My C Code C-Idioms, C-Examples, C-Tutorials, C-Snippets
Simple-state-pattern High Level Game State Management - Code Flow diagram.
Game Loots This guide is intended to get the Idea of random drops and as introduction to random distribution or weighted distribution.
SDL Mixer: change Frequency during runtime