Earlier quoted context omitted.
You do often need a graphics context to create the surface that displays the framebuffer.
Not necessarily. Most desktop OS compositors provide a void** buffer that can be blitted to. Sure, this buffer will probably end up going through the compositor which does GPU hardware acceleration anyway, but it is definitely possible to shrink the application-side stack without relying on D2D/GLUT/GLEW/GLFW/SDL/WGPU in this case. On Windows: CreateDIBSection and BitBlt On macOS: CALayer and CATransaction commit Not…
Software rendering in 500 lines of bare C++
41–50 of 83 posts
Re: Software rendering in 500 lines of bare C++
#42Earlier quoted context omitted.
You do often need a graphics context to create the surface that displays the framebuffer.
Not necessarily. Most desktop OS compositors provide a void** buffer that can be blitted to. Sure, this buffer will probably end up going through the compositor which does GPU hardware acceleration anyway, but it is definitely possible to shrink the application-side stack without relying on D2D/GLUT/GLEW/GLFW/SDL/WGPU in this case. On Windows: CreateDIBSection and BitBlt On macOS: CALayer and CATransaction commit Not…
Wayland: wl_shm and that’s it for the “stack”.
Re: Software rendering in 500 lines of bare C++
#43Earlier quoted context omitted.
My renderer attempts always got stuck on the "should implement clipping" phase too, until I finally bit the bullet and managed to write a working one without much effort, independently "rediscovering" the Sutherland–Hodgman algorithm [1] as I found out later (googling it beforehand would've been cheating, of course). The algorithm itself is fairly straightforward and intuitive, I think the biggest mental block is the…
This is a great comment. As someone who is familiar with R^3 geometry but not projection or clipping, I feel like I could almost implement it from your comment alone. Can you explain more about clipping before/after the divide by w operation? Is this about avoiding coordinates with w = 0? Otherwise all the geometric ideas seem to make sense in both the world/view-space frustum and the ±1 box.
Moreover, all geometry that is fully behind the camera will actually get projected in front of the camera into the distance by the w division because they have zthink clipping against the back plane would get rid of these, but it's still weird. And now my brain hurts.
Historically, of course, divisions were expensive and culling as much as possible before the perspective division was a performance question as well.
Re: Software rendering in 500 lines of bare C++
#44This is a very good article.
Edit: Ah: there's a quiet hamburger menubar. The page really should have forward/next/toc links.
Re: Software rendering in 500 lines of bare C++
#45Re: Software rendering in 500 lines of bare C++
#46I thought this would be something new but it’s just ssloy’s tinyrenderer. Article should have a date since it’s old as dirt
Just because you've seen something before doesn't mean it isn't new for some readers! This is my first time seeing it
Re: Software rendering in 500 lines of bare C++
#47Earlier quoted context omitted.
You do often need a graphics context to create the surface that displays the framebuffer.
Not necessarily. Most desktop OS compositors provide a void** buffer that can be blitted to. Sure, this buffer will probably end up going through the compositor which does GPU hardware acceleration anyway, but it is definitely possible to shrink the application-side stack without relying on D2D/GLUT/GLEW/GLFW/SDL/WGPU in this case. On Windows: CreateDIBSection and BitBlt On macOS: CALayer and CATransaction commit Not…
Linux has always been a weird kettle of fish, the thing that worked best for me was imlib2 which was originally part of enlightenment. It did what it was supposed to do, hid pixel format conversion without killing performance.
I'm not sure what would serve a similar function today,
If anyone knows of a library that takes a rectangle of memory, a pixel format and places it onscreen regardless of the display environment I'd like to hear about it.
The faster and more efficient, the better. More features than needed, worse.
Re: Software rendering in 500 lines of bare C++
#48Earlier quoted context omitted.
Softbuffer? (I originally wrote this a few years ago but other people maintain it now)
I like softbuffer, but it owns its window and doesn't support as many events / integrations as winit.
Re: Software rendering in 500 lines of bare C++
#49Back in the day, it was The Book for computer graphics.
Re: Software rendering in 500 lines of bare C++
#50on the topic of software rendering, im surprised how little gustavo pezzi's lectures get mentioned here on hacker news.