Hello, i started learning SDL (I am an absolute beginner) and decided to try to open an empty window to see if i installed SDL correctly and to test my build system (make). When i build the program and execute the file it runs with 0 errors, but the window doesn't show up. I have a vague feeling that it has to do with the fact that i'm on hyprland but that's just a hunch. Any ideas?
I'm a beginner in sdl3 , i just started today and followed the exact step by step tutorial in how to set up an sdl3 project with gcc but the program keeps returing those errors "#include errors detected. Please update your includePath. Syntax errors for this file will not be reported until included files are found."
I don't know what it means and i've updated my path by including it in my environement variable
Is there a tutorial or a basic code example anywhere that shows how to create an OpenGL context with SDL3? I've been trying to set it up on my own but haven't had any luck, all I get is a black window that won't let me render anything to it.
I've looked online but all I can find are vintage tutorials from the SDL1 days, and one SDL2 tutorial designed for Windows users (I'm on Linux).
EDIT: For anyone else who stumbles upon this, I managed to find one: https://lazyfoo.net/tutorials/SDL/51_SDL_and_modern_opengl/index.php. Scroll down to the bottom where it says: "Download SDL3 port of this demo (graciously provided by Sam Lantinga, creator of SDL) here."
yo ok so i can't access any of the SDL websites, i was trying to take a look at the wiki.libsdl but it timed out same thing for libsdl literally every other website runs fine so i don't see the issue, it even pings correctly
so where else can i find good documentation for SDL3?
I just started sdl(sdl2 to be exact) again after 4-6 months since I liked the control it gave me, and I'm really enjoying it so far after the first few days of using it again. It abstracts all of the hard stuff while still giving you a nice balance of control and ease. I'm currently making a simple and light game engine/framework and I'm wondering if sdl2 is equipped for it? I apologize if this is an annoying question, since I am still somewhat an intermediate/newbie programmer.
I started writing a game on an 11 inch Netbook (remember those?) in 2009. At first I wrote a CPU bitmap based software renderer, and a python game loop. After a bit of back and forth, and some unsuccessful experiments, I landed on a C++ core engine running on top of SDL, with a Lua scripting engine. About a year into the process I decided that I wanted to build it for the then new iPhone platform, with an emphasis on touchscreen controls. I really thought (and still think) that touchscreen games could be extremely intuitive and fun if you designed the interface around their limitations thoughtfully.
I ported the game to run on an iPod Touch, it worked! It ran hot and sometimes ran out of memory, but it was good.
I also wanted to continue developing for desktops so I built Windows and Mac versions from the same codebase. There were a few ugly #ifdefs but everything more or less worked. One of the more difficult platform specific parts was the filesystem handling, but rendering was _mostly_ the same code between all three platforms.
I continued to develop the game here and there for a few years, adding support for iPad's while dropping support for desktops. I was determined to make this a really good "mobile-first" project, where good games were (and arguably still are) lacking.
Several years go by with an update or two per year. Then Apple drops support for 32bit apps. Well, I'm sure those of you who were invested in the app ecosystem remember the great purge. Tons of apps, some great, were lost to digital rot forever. I thought about it and decided I will continue to support my game. Cue the upgrade to SDL2.
The upgrade process was extremely straightforward. I was anticipating a nightmare, SDL_mixer was the only snag in the port. After a few weeks of upgrading the engine, and a few bugfixes for gameplay and some new features, the game was re-released for 64 bit iOS.
Years go by with additional bugfixes and new features trickling in slowly. Then late 2023 rolls around. I am sitting in my office looking over almost 15 years of code, much of it poorly maintained, and yet it is holding up, it's not collapsing under it's own weight (proof that I am a better architect than any current LLM 😂). I figure: "why have I never ported this to Android?".
So the next odyssey begins. This time it's a bit more involved. I take some time to clean up edge cases, remove dead code, and rethink some platform specific code. I have to ramp up on Android Studio and Gradle and other unspeakable horrors, but after about 2 and half months, it's running on a bottom of the barrel entry level Samsung... running nicely. There were several places where the code had to be customized (again with the filesystem), but the vast majority of rendering and event handling worked out of the box.
I thought to myself, "that wasn't so bad, why did it take me over a decade to try that?". Then I remembered emscripten. If I could port to Android with so little friction, could I port to the web? Of course you know the answer, My SDL2 game was running (almost) flawlessly in a web browser a couple of short weeks later. I had to do a few hacky things, SDL_mixer caused the most difficulty with weird untraceable crashes that required me to modify some long wave loops for the web platform specifically, but overall it ran well and ran very fast.
Then, over 15 years after I started writing this game, in early January, I think to myself: "what am I doing with my life? My industry is imploding and the work is boring, what if I _actually_ try and make a commercially viable game?". After years of part-time, semi-invested development in a game that is very cool, has a cult following, but is nowhere near a hit, I decide to double down and make it _polished_.
So that means I need shaders, right? Now the port to SDL3 begins, surely now with so many API changes, and a new paradigm for rendering this will be a humongous task? Of course not! There were issues here and there, Rect formats, GPU pipelines, some dark corners that lay undisturbed for a decade that suddenly wouldn't compile. But on iOS and Android not only did the port work, but with the new GPU pipeline it looked amazing! Adding new GPU shader effects to a 26 year old open-source tileset really spruced it up!
The web build needed a new custom renderer using WebGPU, and parallel shaders in WGSL, but the event code, the SDL_mixer code, virtually everything else worked right out of the box.
So now I am maintaining and improving one of the oldest continually updated games on iOS, ported it to many platforms, with many changes to the underlying technologies; I couldn't have picked a better foundation than SDL!
Not sure if this is welcome or allowed, but I have been working on a game for a few years with SDL3 as it's only dependency. I started off on SDL1, but the appeal of GPU acceleration was too much to ignore, and I moved to SDL2. Then there seemed no real reason to hold back from going to SDL3.
It's a Cannon Fodder inspired tactical action game, probably still a few months away from release, but it's on Steam now:
I'm trying to create black and white noise surface (so I don't need 4 bits per pixel) but when I try to write to it all pixels have value 0. When I change pixel format to RGBA8888 everything works fine. How can I not waste memory?
SDL_Surface *bg = SDL_CreateSurface(64, 64, SDL_PIXELFORMAT_INDEX8) ;
//SDL_Surface *bg = SDL_CreateSurface(64, 64, SDL_PIXELFORMAT_RGBA8888) ;
for(int i = 0; i < 4096; i++)
{
px = noise() ; // noisy pixel
SDL_WriteSurfacePixel(bg, i % 64, i / 64, px, px, px, 255) ;
SDL_ReadSurfacePixel(bg, i % 64, i / 64, &r, &g, &b, &a) ;
printf("%d\t%d\t%d\t%d\t%d\n", px, r, g, b, a) ;
}
the SDL_renderer seems to support custom fragment shaders with SDL_GPURenderState? Are there any tutorials or samples that show how to use these properly?
A beginner here, I want to get into SDL3 but not from a game dev point of view.
I have this itch in me, to create a custom physics engine (even if extremely basic). I am doing this as my First Year BTech Project.
I already know C andd C++ (At least so much so that I can comfortably work with them), and some python. I know nothing about physics simulations or such.
But I love to learn as I explore.
When I see SDL3 Wiki, Its quite overwhelming, Would love some guidance.
I’ve been working on SDLPainter, an open-source C++17 library that brings a QPainter-inspired drawing API to SDL3 projects. It started as a visualization tool for my simulation and GIS application and later grew into a standalone library.
The basic idea is to work with shapes, pens, brushes, and transforms without having to implement the underlying geometry. A few things it currently supports:
Basic shapes and paths, including circles, thick strokes, dashed lines, and gradient fills,
Thick strokes are generated as geometry, shapes are tessellated into triangles,
Image rendering and updates, plus UTF-8 text rendering through SDL_ttf,
Save/restore transforms, rectangular clipping, viewports, and render targets,
Automatic draw-call batching through RenderBatcher, which groups compatible drawing operations to reduce the number of GPU draw calls.
It uses OpenGL/Vulkan rendering backends, with SDL3 handling the platform layer. There’s also an optional application layer for window creation and the event loop.
Beyond rendering, I’ve also been using this repo to illustrate modern C++ development practices: modern c++, CMake for builds and integration, Conan 2 for dependency management, and CI/CD pipelines on GitHub Actions and GitLab CI. Feedback on the build setup and developer experience is welcome too!
I also write about the project and its development on my blog, yazilimperver.net, covering modern C++ features, SDL3, drawing features, CMake/Conan setup, testing, and CI/CD. The articles are in Turkish for the time being (planning to add them to repo in English very soon). You can find these post and some other SDL related ones in readme file.
I’d love to hear what you think, especially if you’ve built something similar or needed a drawing layer like this in your SDL projects. Questions, suggestions, and contributions are all welcome!
By the way, I also add a gif, showing some of the drawing features. What do you think of the current feature set? Is there anything you’d want to see added?
Changing the range from -1 through +1 to 0 to 1 somehow, with calibration maybe? This is so that racing pedals that are mapped as centered axis don't map as -x or +x, but instead how you would map an analog trigger, without - or +, just use the full range.
I followed this tutorial to link SDL3 as a git submodule, which works perfectly but I'd like to do the same for SDL_Image so i followed all the steps but it returns this error:
Could not find CMakeLists.txt for zlib in external/zlib.
Run the download script in the external folder, or re-configure with
-DSDLIMAGE_VENDORED=OFF to use system packages.
How do I fix this? When I look into the external/zlib it's indeed an empty directory without a CMakeLists.txt. vendor/CMakeLists.txt: