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

If you want to render 2d vs 3d there are different tradeofs, a 3d renderer has to do interpolation of attributes over triangles, a 2d renderer doesn't and as a result can render ngons without having to triangulate them.

I'm just going to dump some links really quick, which should get anyone started.

Getting a framebuffer on screen: https://github.com/zserge/fenster

I would recommend something like SDL if you want a more complete platform abstraction, it even supports software rendering as a context mode.

Filling solid rectangles is the obvious first step.

Loading images and copying pixels onto parts of the screen is another. I recommend just not drawing things that intersect the screen boundaries to get started. Clipping complicates things a bunch but is essential.

Next up: ghetto text blitting https://github.com/dhepper/font8x8 I dislike how basically every rendering tutorial just skips over drawing text on screen, which is super useful for debugging.

For drawing single pixel lines, this page has everything on Bresenham:

http://members.chello.at/easyfilter/bresenham.html

For 2d rasterization, here's an example of 3 common approaches: https://www.mathematik.uni-marburg.de/~thormae/lectures/grap...

Scanline rasterization tought me a lot about traversing polygons, I recommend trying it even if you end up preferi g a different method. Sean Barrett has a good overview: https://nothings.org/gamedev/rasterize/

Side note: analytical antialising is fast, but you should be carefull with treating alpha as coverage, the analytic approaches tell you how much of a pixel is covered, not which parts are.

For 3d rasterization Scratchapixel is good: https://www.scratchapixel.com/lessons/3d-basic-rendering/ras...

Someone mentioned the Pikuma course which is also great, though it skips over some of the finer details such as fixed point rasterizing.

For good measure here's some classic demoscene effects for fun: https://seancode.com/demofx/

Anyway, this is just scratching the surface, being progressively able to draw more and more types of primitives is a lot of fun.



Hi there. Gustavo Pezzi here! Thanks for the mention. I always add new stuff to the lectures and I'm happy to inform that about a year ago I have added a bonus lecture on fixed-point rasterization at the end of that course. Nothing too crazy, but enough to cover the main points. Also, the PlayStation programming course is pretty much 100% fixed-point if anyone feels like diving into that too.


Awesome! Do you have any resources on, uhhh, "hardware accelerating" a software renderer. i.e. using SIMD (or math hardware like the vector hardware you can access with the Accelerate[0] framework on Apple devices).

[0] https://developer.apple.com/documentation/accelerate


There's the work on Larrabee by Mike Abrash and co: https://www.gamedeveloper.com/programming/sponsored-feature-...


This is a gold mine, thank you.




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

Search: