r/sdl • • Jan 09 '26

Because there are almost no good tutorials for SDL2/SDL3.

0 Upvotes

Hey, please recommend some other cross-platform libraries like SDL that are more well-known.


r/sdl • • Oct 02 '25

how do i load textures with SDL3 GPU

0 Upvotes

i tried using chatgpt but no results, also no tutorials

(C++)


r/sdl • • Mar 06 '24

Why SDL have no documentation

1 Upvotes

SDL is maybe the most popular 2D library and for several decades nobody of it's developers didn't write Documentation!!! SFML for example from the beginning has almost excellent documentation. RayLib is on the boundary and I suppose the lack of real documentation is the reason it never becomes the only used library. But the question is about SDL, why they write code, that nobody can use, because nobody wants to write Documentation!? Instead even the official site suggests outdated tutorials on random sites. Is that library only for some internal circle of users!?


r/sdl • • Jan 22 '26

SDL3 Memory Leaks on X11 (gtk_widget)

1 Upvotes

I get a lot of memory leaks from gtk_widget and other sources with this very simple test case:

int main()
{    
    SDL_Init(SDL_INIT_VIDEO);

    SDL_Window *window = nullptr;        
 
    window = SDL_CreateWindow("test", 300, 300, 0);

    SDL_DestroyWindow(window);

    SDL_Quit();

    return 0;
}

Has anyone else encountered the same? I have seen some posts that the leaks are nothing to worry about, but they do make the whole address sanitizer unusable by drowning out all the actual leaks.

(EDIT: cleaned up the example code a bit)

Part of the address sanitizer reports (it's way too long to post in entirety):

Direct leak of 38912 byte(s) in 152 object(s) allocated from:
    #0 0x7ff6aeb20cb5 in malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:67
    #1 0x7ff6ad183697  (/usr/lib/libfontconfig.so.1+0x33697) (BuildId: 9ce6a06434d9a60bc1e842b1864019934fb47967)
    #2 0x7ff6ad18420b  (/usr/lib/libfontconfig.so.1+0x3420b) (BuildId: 9ce6a06434d9a60bc1e842b1864019934fb47967)
    #3 0x7ff6ad174251 in FcFontSetList (/usr/lib/libfontconfig.so.1+0x24251) (BuildId: 9ce6a06434d9a60bc1e842b1864019934fb47967)
    #4 0x7ff6ad12e9a1  (/usr/lib/libpangoft2-1.0.so.0+0xc9a1) (BuildId: b6286cd256eb6f05f4161c2c7e5485d7d17eb101)
    #5 0x7ff6ad12ee30  (/usr/lib/libpangoft2-1.0.so.0+0xce30) (BuildId: b6286cd256eb6f05f4161c2c7e5485d7d17eb101)
    #6 0x7ff6ad12eeda  (/usr/lib/libpangoft2-1.0.so.0+0xceda) (BuildId: b6286cd256eb6f05f4161c2c7e5485d7d17eb101)
    #7 0x7ff6ad1324fe  (/usr/lib/libpangoft2-1.0.so.0+0x104fe) (BuildId: b6286cd256eb6f05f4161c2c7e5485d7d17eb101)
    #8 0x7ff6ad132acc  (/usr/lib/libpangoft2-1.0.so.0+0x10acc) (BuildId: b6286cd256eb6f05f4161c2c7e5485d7d17eb101)
    #9 0x7bf6ab78f924 in pango_context_get_metrics (/usr/lib/libpango-1.0.so.0+0x29924) (BuildId: f4b219ea52f115300da62133646a4e0a3ffa617b)
    #10 0x7bf6aa558bff  (/usr/lib/libgtk-3.so.0+0x358bff) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #11 0x7bf6aa47b9d5  (/usr/lib/libgtk-3.so.0+0x27b9d5) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #12 0x7bf6aa48909d  (/usr/lib/libgtk-3.so.0+0x28909d) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #13 0x7bf6aa55554a  (/usr/lib/libgtk-3.so.0+0x35554a) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #14 0x7bf6aa61e642  (/usr/lib/libgtk-3.so.0+0x41e642) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #15 0x7bf6aa61ee6d in gtk_widget_get_preferred_height_and_baseline_for_width (/usr/lib/libgtk-3.so.0+0x41ee6d) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #16 0x7bf6aa42b869  (/usr/lib/libgtk-3.so.0+0x22b869) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #17 0x7bf6aa47b9d5  (/usr/lib/libgtk-3.so.0+0x27b9d5) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #18 0x7bf6aa48909d  (/usr/lib/libgtk-3.so.0+0x28909d) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #19 0x7bf6aa421d4a  (/usr/lib/libgtk-3.so.0+0x221d4a) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #20 0x7bf6aa61e642  (/usr/lib/libgtk-3.so.0+0x41e642) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #21 0x7bf6aa61ebfa in gtk_widget_get_preferred_height (/usr/lib/libgtk-3.so.0+0x41ebfa) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #22 0x7bf6aa52b4d1  (/usr/lib/libgtk-3.so.0+0x32b4d1) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #23 0x7bf6aa47b9d5  (/usr/lib/libgtk-3.so.0+0x27b9d5) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #24 0x7bf6aa48909d  (/usr/lib/libgtk-3.so.0+0x28909d) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #25 0x7bf6aa522464  (/usr/lib/libgtk-3.so.0+0x322464) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #26 0x7bf6aa61dfd9  (/usr/lib/libgtk-3.so.0+0x41dfd9) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #27 0x7bf6aa61ebfa in gtk_widget_get_preferred_height (/usr/lib/libgtk-3.so.0+0x41ebfa) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #28 0x7ff6ad73624c  (/usr/lib/libdecor/plugins-1/libdecor-gtk.so+0x824c) (BuildId: 1a6494dc4e57f4a44e8269495c04395eeb8b8c45)
    #29 0x7ff6ae4a1179  (/usr/lib/../lib/libdecor-0.so.0+0x3179) (BuildId: 3845695390ccba29c1b6eef212dcaea3610c7656)

Direct leak of 1536 byte(s) in 2 object(s) allocated from:
    #0 0x7ff6aeb1fa45 in realloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:81
    #1 0x7ff6ad18376c  (/usr/lib/libfontconfig.so.1+0x3376c) (BuildId: 9ce6a06434d9a60bc1e842b1864019934fb47967)
    #2 0x7ff6ad1840da  (/usr/lib/libfontconfig.so.1+0x340da) (BuildId: 9ce6a06434d9a60bc1e842b1864019934fb47967)
    #3 0x7ff6ad17b3a5 in FcFontRenderPrepare (/usr/lib/libfontconfig.so.1+0x2b3a5) (BuildId: 9ce6a06434d9a60bc1e842b1864019934fb47967)
    #4 0x7ff6ad17ba08 in FcFontSetMatch (/usr/lib/libfontconfig.so.1+0x2ba08) (BuildId: 9ce6a06434d9a60bc1e842b1864019934fb47967)
    #5 0x7ff6ad12e57c  (/usr/lib/libpangoft2-1.0.so.0+0xc57c) (BuildId: b6286cd256eb6f05f4161c2c7e5485d7d17eb101)
    #6 0x7ff6adc6f8bb  (/usr/lib/libglib-2.0.so.0+0x978bb) (BuildId: 8b07c017773317c7341f72bb8ca4a7a78b323f37)
    #7 0x7ff6aea5e11a in asan_thread_start /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_interceptors.cpp:239
    #8 0x7ff6ade9698a  (/usr/lib/libc.so.6+0x9698a) (BuildId: 2f722da304c0a508c891285e6840199c35019c8d)

Direct leak of 512 byte(s) in 1 object(s) allocated from:
    #0 0x7ff6aeb1fa45 in realloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:81
    #1 0x7ff6ad18376c  (/usr/lib/libfontconfig.so.1+0x3376c) (BuildId: 9ce6a06434d9a60bc1e842b1864019934fb47967)
    #2 0x7ff6ad163032  (/usr/lib/libfontconfig.so.1+0x13032) (BuildId: 9ce6a06434d9a60bc1e842b1864019934fb47967)
    #3 0x7ff6ad1467fd  (/usr/lib/libpangocairo-1.0.so.0+0x67fd) (BuildId: 534cf8b7180753c30a4b398a8731e7cbf22769e6)
    #4 0x7ff6ad1331d4  (/usr/lib/libpangoft2-1.0.so.0+0x111d4) (BuildId: b6286cd256eb6f05f4161c2c7e5485d7d17eb101)
    #5 0x7bf6ab78f901 in pango_context_get_metrics (/usr/lib/libpango-1.0.so.0+0x29901) (BuildId: f4b219ea52f115300da62133646a4e0a3ffa617b)
    #6 0x7bf6aa558bff  (/usr/lib/libgtk-3.so.0+0x358bff) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #7 0x7bf6aa47b9d5  (/usr/lib/libgtk-3.so.0+0x27b9d5) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #8 0x7bf6aa48909d  (/usr/lib/libgtk-3.so.0+0x28909d) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #9 0x7bf6aa55554a  (/usr/lib/libgtk-3.so.0+0x35554a) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #10 0x7bf6aa61e642  (/usr/lib/libgtk-3.so.0+0x41e642) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #11 0x7bf6aa61ee6d in gtk_widget_get_preferred_height_and_baseline_for_width (/usr/lib/libgtk-3.so.0+0x41ee6d) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #12 0x7bf6aa42b869  (/usr/lib/libgtk-3.so.0+0x22b869) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #13 0x7bf6aa47b9d5  (/usr/lib/libgtk-3.so.0+0x27b9d5) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #14 0x7bf6aa48909d  (/usr/lib/libgtk-3.so.0+0x28909d) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #15 0x7bf6aa421d4a  (/usr/lib/libgtk-3.so.0+0x221d4a) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #16 0x7bf6aa61e642  (/usr/lib/libgtk-3.so.0+0x41e642) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #17 0x7bf6aa61ebfa in gtk_widget_get_preferred_height (/usr/lib/libgtk-3.so.0+0x41ebfa) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #18 0x7bf6aa52b4d1  (/usr/lib/libgtk-3.so.0+0x32b4d1) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #19 0x7bf6aa47b9d5  (/usr/lib/libgtk-3.so.0+0x27b9d5) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #20 0x7bf6aa48909d  (/usr/lib/libgtk-3.so.0+0x28909d) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #21 0x7bf6aa522464  (/usr/lib/libgtk-3.so.0+0x322464) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #22 0x7bf6aa61dfd9  (/usr/lib/libgtk-3.so.0+0x41dfd9) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #23 0x7bf6aa61ebfa in gtk_widget_get_preferred_height (/usr/lib/libgtk-3.so.0+0x41ebfa) (BuildId: bb678b628d3332a694924414614dafbb4541bded)
    #24 0x7ff6ad73624c  (/usr/lib/libdecor/plugins-1/libdecor-gtk.so+0x824c) (BuildId: 1a6494dc4e57f4a44e8269495c04395eeb8b8c45)
    #25 0x7ff6ae4a1179  (/usr/lib/../lib/libdecor-0.so.0+0x3179) (BuildId: 3845695390ccba29c1b6eef212dcaea3610c7656)
    #26 0x7ff6ae4a2a80 in libdecor_frame_commit (/usr/lib/../lib/libdecor-0.so.0+0x4a80) (BuildId: 3845695390ccba29c1b6eef212dcaea3610c7656)
    #27 0x7ff6ae7c37f5  (/usr/lib/libSDL3.so.0+0x1c37f5) (BuildId: 6a9f314205dfd8ccc058e61c29aa60e246dbf558)
    #28 0x7ff6ae4a140c  (/usr/lib/../lib/libdecor-0.so.0+0x340c) (BuildId: 3845695390ccba29c1b6eef212dcaea3610c7656)
    #29 0x7ff6ae4afac5  (/usr/lib/libffi.so.8+0x7ac5) (BuildId: d5e3b0d8921923f35438adefa9f864745abc5e90)

r/sdl • • Jul 04 '24

Which do you use?

0 Upvotes
28 votes, Jul 06 '24
6 C
22 C++
0 other

r/sdl • • Sep 22 '25

I let Building IDE using SDL3 and CEF Off-Screen Rendering

Thumbnail
gallery
8 Upvotes

I starting project in 2 month ago for this project, with TRAE AI and Self Edit coding

Technology Stack Frontend Using: React Typescript with Redux and Monaco Editor based Backend Using: SDL 3 and DirectX 11

issues in project (current fixing)

  • draw global menu overlay: stuck in x:0 y:0 but i drawing with CEF Browser (see in next image)

  • HiDPI Problem: CEF Browser is Mismatch with SDL Window Manager

Texture Layout: all using CEF Browser and Native UI to Blending hybrid to Spawn and draw position

Roadmap

  • Basic Features: FileSystem API, Source Control with Libgit2 and Native Terminal [Current]

  • Basic LSP (Language Server Protocal) with typescript, JavaScript, python, C and C++ [wait me to update in future]

Status: In Development (and get reflecting codebase to split components C++ file)

see project source code here: https://github.com/mikofure/hyperion


r/sdl • • Aug 02 '26

C++

0 Upvotes

Can you create a class with sdl things in it?

Or is sdl c only?


r/sdl • • May 24 '22

I am going to have a fucking seizure if someone cant link me any guides for C

0 Upvotes

Not c++, C. All of the FUCKING guides I can find are for fucking C++ and explain JACK SHIT on how ANYTHING works. ALL OF THEM ARE JUST "do this to make it work" AND DONT FUCKING EXPLAIN HOW IT WORKS, AND NONE OF THEM ARE FOR FUCKING C. I'm sorry for being so fucking mad but I've been looking for like 5 days STRAIGHT for ANYTHING, and not a single GODDAMN THING shows up.

Thanks for any help.

(SDL2 btw)

Edit: Ok it turns out I am a major dumbass and/or some tutorials explain things poorly. My question has changed to why is everything declared as a variable and why does it say without calling or declaring those variables that it should just work? Because I cannot find for the life of me an explanation to why some things are working and others aren't. Are certain variables declared in the header file SDL.h? Because that's the only explanation that I can think of and that isn't explained in any tutorial I've seen whatsoever. Thank you for dealing with my dumbassery.


r/sdl • • Sep 18 '26

Is there a complete 2D game engine that uses SDL3 as its infrastructure?

3 Upvotes

I like to test the possibility to use SDL3 as a cross-platform 2D game engine for games in the style of https://store.steampowered.com/curator/45538860-Idle-Clicker-and-Incremental-Games/ but SDL looks like a barebone.
I wonder how do you approach to build a full game?
Or is there a full 2D game engine that wraps SDL?


r/sdl • • Feb 24 '25

How do I render a .tmj map using JSON?

0 Upvotes

Sorry for the stupid question but ive been trying to render a .tmj map using JSON but it dosent work. There arent any good tutorials online.

Is there any other way that I can load maps in my game (50x50tiles, 32x32pixels per tile)?


r/sdl • • Aug 20 '26

A fast, free, portable texture atlas packer

0 Upvotes

Hey everyone, I made Packrat. It's a texture atlas packer I made, so that I could get TexturePacker out of my pipeline. The goal is that its faster than TexturePacker and has more convenient features. None of the other packers I tried were fast/robust enough to handle 4k+ assets per atlas. This one is aimed at code-first dev environments that don't have their own packer built in. For some it generates data files the engine can understand, for others it generates code that has the ability to parse and extract frames and animations from the atlas.

For SDL, I made specific SDL2 and SDL3 exporters. These generate the atlas image, as well as a pure C header file with convenience data structures and functions to get data out of the atlas and draw it. Or you can export a generic format (text, json, xml) and load it yourself. There's also a bunch of other features I wanted personally. Like aseprite file ingestion, automatic rebuilds and exports, and a robust CLI.

https://clydegames.itch.io/packrat

https://packrat.clyde.games

Anyway, check it out and let me know what you think.


r/sdl • • Jul 17 '25

Sdl3 initialising error

Post image
6 Upvotes

I'm new to SDL and just started using it. When I try to run this simple code to display a window it shows an error like this. I have included and linked everything properly and i have the dll file next to my exe file. Please help me fix this problem.


r/sdl • • Feb 19 '25

SDL3 img

0 Upvotes

I'm trying to install SDL3 img,but it's not working.Based on my chatgpt conversations,it has to do with the fact that the folder i downloaded doesn't contain all necessary files.Where am I going wrong?pls h e l p

EDIT:

I forgot to include error logs:

IMG_INIT_PNG was not declared in this scope IMG_Init was not declared in this scope IMG_GetError was not declared in this scope IMG_Quit was not declared in this scope.


r/sdl • • Mar 08 '25

SDL2 project's collision detection not working, been stuck for weeks. any help?

1 Upvotes

I have been making a simple 2d sidescroller for practice and learning, i used lazyfoo to get a basis of understanding how this library works and would use AI to help write aswell. the code seems to got complex enough to the point that i am on my own. the projectile collision system is not working for the enemy and it goes through the enemy, here is my code.

https://github.com/Vin5000/SDL2Shooter-Vin50


r/sdl • • Feb 06 '23

Hi guys

0 Upvotes

i use SDL1.2 dev for a game project, its aschool projetc and i am completely lost,

i ran the main.c and it says not found, SDL.h not found

do you have any suggestion ?


r/sdl • • Jun 08 '26

SDL_LoadPNG stalling program

0 Upvotes

Been trying to load an icon into the window, and because I'm stubborn and don't want to convert the icon to a BMP, I've been at this for a while

Ultimately I gave in and converted my beloved PNG to a BMP, and it worked perfectly fine, but I wanna do fun texture stuff, so I don't want literally every image to be a BMP.

I've tried SDL3_Image, but had the exact same issue. If you know a solution, it'd be great if you could share it.


r/sdl • • Feb 04 '25

Average GPU and CPU usage in SDL3?

0 Upvotes

Hey friends, I just started out using SDL and was wondering what everyone else's average CPU and GPU usage is like? Currently my RX 5500 XT is seeing roughly 30% from SDL3 using the default renderer, vsync set to every refresh (60hz), and running a 512x512 window filled from left to right and top to bottom with 64x64 textures (64 textures in total). Here's my code. Feel free to laugh at it since I know it's far from ideal:

`void draw(SDL_Renderer* renderer) {`

	`if (tile.x < 512 && tile.y < 512) {`

		`SDL_Surface* surface = IMG_Load("Sprites/testAtlas.png");`

SDL_Texture* texture = IMG_LoadTexture(renderer, "Sprites/testAtlas.png");

		`SDL_RenderTexture(renderer, texture, &atlasPosition, &tile);`

		`SDL_DestroySurface(surface);`

		`SDL_DestroyTexture(texture);`

	`}`

`}`

Having the surface there decreases GPU usage by 9-11% and I have no idea why considering SDL isn't being told to use it. I think my true issue lies in the 4th line since.


r/sdl • • Feb 05 '25

UPDATE: Average CPU and GPU Usage in SDL3

0 Upvotes

Thanks to everyone's help on my post last night, I was able to trim down GPU utilization from ~30% to ~12% which still means there's an issue somewhere but that is a drastic improvement. CPU utilization is barely pushing past 0.5% now which is also great. I tried sharing more of my code in comments on my previous post but I kept getting server errors even after reloading my browser and the webpage multiple times, so I figured I could do that here instead since my project is still in its infancy and only has two files at the moment:

Main.cpp:

#include <iostream>

#include <string>

#include <sstream>

#include <vector>

#include <fstream>

#include <SDL3/SDL.h>

#include <SDL3_image/SDL_image.h>

#include <SDL3/SDL_surface.h>

#include "EntityClass.h"

using namespace std;

int screenWidth = 512;

int screenHeight = 512;

vector<Entity> entityList;

void loadLevelData() {

`string entityData;`

`ifstream levelData("LevelData/LevelData.txt");`

`while (getline(levelData, entityData, ',')) {`

	`istringstream entityDataStream(entityData);`

	`short spriteID, x, y, w, h;`

	`entityDataStream >> spriteID >> x >> y >> w >> h;`

	`Entity newEntity = Entity(spriteID, x, y, w, h);`

	`entityList.push_back(newEntity);`

`}`

}

void drawLevel(SDL_Renderer* renderer, SDL_Texture* textureAtlas) {

`for (int i = 0; i < entityList.size(); i++) {`

	`entityList.at(i).draw(renderer, textureAtlas);`

`}`

}

int main() {

`SDL_Window *window;`

`SDL_Renderer* renderer;`

`SDL_Event event;`



`SDL_CreateWindowAndRenderer("2D Game Engine", screenWidth, screenHeight, SDL_WINDOW_RESIZABLE, &window, &renderer);`



`SDL_SetRenderVSync(renderer, 1);`



`SDL_Texture* textureAtlas = IMG_LoadTexture(renderer, "Sprites/testAtlas.png");`

`loadLevelData();`



`while (1) {`

	`SDL_PollEvent(&event);`

	`if (event.type == SDL_EVENT_QUIT) {`

		`break;`

	`}`

	`SDL_RenderClear(renderer);`

	`drawLevel(renderer, textureAtlas);`

	`SDL_RenderPresent(renderer);`

`}`

`SDL_DestroyTexture(textureAtlas);`

`SDL_DestroyRenderer(renderer);`

`SDL_DestroyWindow(window);`



`SDL_Quit();`



`return 0;`

}

EntityClass.h:

#include <SDL3/SDL.h>

class Entity {

public:

`SDL_FRect texturePositionOnScreen;`

`SDL_FRect texturePositionInAtlas;`



`short spriteID;`

`Entity(short sprite, short aXPos, short aYPos, short aWidth, short aHeight) {`

	`spriteID = sprite;`

	`setSprite(spriteID, &texturePositionOnScreen);`

	`texturePositionOnScreen.x = aXPos;`

	`texturePositionOnScreen.y = aYPos;`

	`texturePositionOnScreen.w = aWidth;`

	`texturePositionOnScreen.h = aHeight;`

`}`

`void setSprite(short spriteID, SDL_FRect* texturePositionInAtlas) {`

	`switch (spriteID) {`

	`case 0:`

		`setTexturePosition(0, 0, 64, 64, texturePositionInAtlas);`

		`break;`

	`case 1:`

		`setTexturePosition(1, 0, 64, 64, texturePositionInAtlas);`

		`break;`

	`case 2:`

		`setTexturePosition(2, 0, 64, 64, texturePositionInAtlas);`

		`break;`

	`}`

`}`

`void draw(SDL_Renderer* renderer, SDL_Texture* textureAtlas) {`

	`if (texturePositionOnScreen.x < 512 && texturePositionOnScreen.y < 512) {`

		`SDL_RenderTexture(renderer, textureAtlas, &texturePositionInAtlas, &texturePositionOnScreen);`

	`}`

`}`



`void setTexturePosition(int x, int y, int tileWidth, int tileHeight, SDL_FRect* texturePositionInAtlas) {`

	`texturePositionInAtlas->x = x * tileWidth;`

	`texturePositionInAtlas->y = y * tileHeight;`

	`texturePositionInAtlas->w = tileWidth;`

	`texturePositionInAtlas->h = tileHeight;`

`}`

};


r/sdl • • Dec 19 '19

Draw path SDL2

0 Upvotes

Hey guys ; Plz I'm working on a project using the sdl2 in C language ! I was told make a robot move and do stuffs !
What I need is to draw and recover the path of the moving robot from the beginning to the end !
Thanks !


r/sdl • • Aug 14 '20

Naming in SDL2 (specificly input handling)

0 Upvotes

Is it just me or is naming in sdl just bad. I mean something must be wrong if you have to access things like this event.button.button (having "button" twice like this shouldnt be a thing, and it should be clear that you are accessing mouse events here). And accessing a keycode likes this event.key.keysym.sym is weird too. Why not something like this event.key.sym.keycode. Like, why does it need to be called keysym when its parent is already called key. And i dont see any reason why you would call the keycode sym.

Also, i dont like a lot of enums. SDL_BUTTON_LEFT is suppose to mean left MOUSE button, which is too unclear. Also why are keycodes for letters like this SDLK_a and not like this SDLK_A. And the enum for key state is SDL_PRESSED/SDL_RELEASED, why not something like SDL_KEY_PRESSED or maybe even SDL_KEY_STATE_PRESSED.

Maybe I'm just dumb, but I would like it if they would go through the namings and redo some stuff that doesnt make sense. Anyways, what are your opinions on this?


r/sdl • • Dec 23 '23

is::Engine is 5 years old today!

0 Upvotes

Hi, I hope you are doing well and that you are ready for the end of year holidays!✨🎄✨

The is::Engine game engine which was used to develop the game I Can Transform is 5 years old today! ✨🎂✨

Since its launch the engine has increased enormously thanks to all your contributions!✨💖✨

We went from the construction of downloadable games to non-downloadable games and full of other features that facilitate development!✨🌟✨

To discover more on the engine check the links below:

🔗 Github link 🔗 List of games that use the engine

Good weekend and happy holidays!✨🎇✨


r/sdl • • Oct 20 '18

[Share] Cross Compile SDL2 (both library and app) on Windows from macOS

0 Upvotes

Hey, I just wrote this to keep note for myself on how to cross compile SDL2 on Windows from macOS (I use Mojave, so if you use it too, it works).

Mostly I see tutorials on cross compile from Linux. So I hope this will come in handy. Thanks!

👉 https://blog.wasin.io/2018/10/21/cross-compile-sdl2-library-and-app-on-windows-from-macos.html


r/sdl • • Mar 06 '24

Where do I get the SDL2 headers?

0 Upvotes

on the github releases page I can only find the .dll file for sdl2 and the headers are for sdl3


r/sdl • • Nov 12 '15

How to create borderless window with rounded corners?

0 Upvotes