Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Modern 2D graphics are not based on plotting pixels to a framebuffer, they have "textures" or "surfaces" as a native part of the system and any compositing is done as a separate step. So if anything making "simple sprites" has become a bit easier since you can just think of any composited surface as a more generic version of a hardware sprite.



I think this is more simple from the pov of making a game engine from scratch or a game with complex effects and graphics. But is it more simple from the pov of a high schooler that just wants to get some flat colored shapes on the screen?


Even rendering "flat colored shapes" efficiently can be a bit non-trivial if you expect pixel-perfect results, like you'd get by plotting to an ordinary framebuffer - the GPU's fixed rendering pipeline is not generally built for that. The emerging approach is to use compute shaders, and these are not yet fully integrated with existing programming languages - you can't just edit ordinary C++/Rust code and have it seamlessly compile for CPU and GPU rendering. But we're getting closer to that.


I'm curious how does the texturing work in the SDL backend? I did not read the code but am curious now.

Back in the day I heard about of a friend who claimed to write some 2d framework which was faster than Direct2D -- that was a pretty early version of Direct2D I think.


SDL is a cross platform library, so it works by just using whatever native rendering context is available, abstracted to a common API. In more general terms AFAIK it uses the geometry API under the hood and just pushes triangles/quads to the GPU whenever possible.


Thanks a lot. Is it the same for 2d?


I was refering to 2D. for 3D, SDL2 has OpenGL and Vulkan APIs.

SDL3 is going to have a general purpose 3D API with its own shader language AFAIK.

In my experience, if what you want is to just get a window open and render some sprites, have some basic low level stuff handled and not have your hand held, SDL2 is ridiculously easy for it. There's also Raylib[0] and SFML[1], neither of which I've used but I hear good things about.

[0]https://www.raylib.com/

[1]https://www.sfml-dev.org/


Thanks, I'm not familiar with the graphics internals so sorry for the confusion.

Yeah I made half of a Ultima spinoff with SDL2 and it's pretty easy. Basically I load a texture which is a spritesheet and it's trivial to present a tilemap.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: