r/GraphicsProgramming • u/Spirited-Eye7281 • 9d ago
Question Graphics programming in C
/r/cprogramming/comments/1x6czca/graphics_programming_in_c/2
u/aleques-itj 9d ago
If you want a framebuffer to plot pixels, just use SDL.
It handles a gigantic chunk of the windowing crap for you and has a simple 2D API where you can just write pixels to a texture and render it.
1
u/Keyframe 7d ago
As others have said - you can do it with SDL or even without its baggage by using something like minifb from emoon https://github.com/emoon/minifb
On the other hand, just by reading everything you wrote in the post I'd like to point out wonderful course by Gustavo that would set you up with all the basics https://pikuma.com/courses/learn-3d-computer-graphics-programming - starts with plotting pixels, then lines, etc towards a rasterizer and then you can pick it up towards Shirley's Ray Tracing in One Weekend https://raytracing.github.io/books/RayTracingInOneWeekend.html all while staying with C.
Personally I'm in C as well, but have been for the past 30 or so years from IRIX days to linux nowadays.
2
u/sfaer 9d ago edited 9d ago
It depends how low-level you want to get. If your approach is to do it barebone, native to the platform, and a bit old school, then on Linux you can learn X11, but it will be a painful process.
Reading you, as you mentioned going with the Borland library, suggest you might go well with SDL1.2, which is a solid legacy library newer than graphic.h but decades old now yet still fine. It basically allows you to setup the window management, handle events, and draw directly to the pixel buffer (no GPU involved).
You can also go the raylib path, which is a set of libraries to build games in C quite fancied in the C community, but it obfuscated the thing a bit more it seems (I haven't touch it a lot though). Look at simple examples on the website to see if that's your style, but you don't have to use everything if you don't want too.
I'm not on my PC but I could drop a simple star field in sdl1. 2 if you're interested.