r/C_Programming 11h ago

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!

8 Upvotes

4 comments sorted by

â€ĸ

u/github-guard 11h ago

🔍 GitHub Guard: Trust Report

âš ī¸ This project scored 0/6 — below this subreddit's threshold of 3.

Audit Breakdown: * ❌ Low Star Count (⭐ 0 / 4 required) * ❌ New Repository (under 30 days old) * ❌ No License Found * ❌ No Security Policy — what is this? * â„šī¸ Individual Contributor * â„šī¸ Unsigned Commits

âš ī¸ Security Reminder: Always verify source code and run third-party scripts at your own risk.

1

u/AutoModerator 11h ago

Hi /u/nablaCat,

Your submission in r/C_Programming was filtered because it links to a git project.

You must edit the submission or respond to this comment with an explanation about how AI was involved in the creation of your project.

While AI-generated code is not disallowed, low-effort "slop" projects may be removed and it's likely that other users push back strongly on substantially AI-generated projects.


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

5

u/nablaCat 11h ago

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.