r/C_Programming • • Aug 20 '26

Project 3D Library using SDL3

https://github.com/Atled9/env

This project has taken a long time.

It took me about a week to learn the concepts behind 3D projection and transformations in euclidean space. Then it took me over a week to write out the LaTeX documentation that presented my knowledge in a way that would help a user of this library. As you can see, the overwhelming majority of the code committed to this repo is in LaTeX.

The implementation of the 3D rendering framework was relatively simple once I fully understood the mathematics. This only took a couple days, and it helps to have some familiarity with C going in.

I look forward to improving this project by building a separate homogeneous coordinate library that will replace pnt.c. I also need to tackle surface rendering using SDL_RenderGeometry() and implement 3D surface occlusion. I suppose what I'm left with for now are a few big questions.

How prohibitive is heap-allocation for performance in graphics applications? I went with dynamic allocation to preserve encapsulation so that header files didn't give the user access to data that would destroy library functionality when altered. However, given the fact that querying free memory at runtime for thousands of data points slows a program significantly, I'm having second thoughts.

Also, is there a convenient way to push all of the calculations needed for 3D transformations onto the GPU? This seems like something I shouldn't handle entirely in software.

I'll hear out any feedback or suggestions in the comments!

23 Upvotes

8 comments sorted by

View all comments

Show parent comment

9

u/nablaCat Aug 20 '26

No AI was involved in the creation of this project. I had to look up topics individually and I wrote all of the code manually. As far as sources go:

This wiki article helped me greatly with perspective projection and the associated 3D transformations.

This website was a convenient reference when writing up the documentation for my README

I relied entirely on my former knowledge implementing data structures in C when writing the C code for the library. You can see a similar pattern of struct usage in my other projects on Github.

2

u/mikeblas Aug 20 '26

Thank you for your disclosure. I have approved your post.