Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

3D Renderer in C

Building a 3D graphics renderer from scratch using the C programming language. Based on Gustavo Pezzi's course

No GPU, or OpenGL. Just a C compiler and linear algebra.

In this project, I'm using the Left-Handed coordinate system (Z-values increase when going into the screen). I also use column-major matrices layout.

Check out also the WebGL 3D engine, that I created after finishing this project.

Content

  • Pure C and SDL
  • Foundations of 3D Graphics
  • Trigonometry and linear algebra (matrices, vectors, etc.)
  • Vertices and meshes
  • 3D projection and perspective
  • Rasterizing lines and triangles
  • Handling textures and texture mapping
  • Camera and view transformations
  • Displaying complex 3D models (imported from external programs like Blender)

Run commands

  • Using custom script

    • ./build-and-run.sh
  • Using Makefile

    • make build or just make (it will pick first command)
    • make run
    • make clean
  • Compiling the program

    • gcc main.c -o output
  • Running the program

    • ./output

Linux Installation

  • Build Tools

    • Command: sudo apt install build-essential
  • SDL2

    • Command: sudo apt install libsd12-dev

Mac Installation

  • Xcode Command Line Tools

    • Command: xcode-select --install.
  • SDL2 Library

    • Command via Homebrew: If Homebrew is not installed, first install it from brew.sh. Then, brew install sdl2 in the Terminal.

Importing mesh with Blender

When importing your own mesh, make sure to export it as a Wavefront (.obj) file. Then, in the export settings, make sure to check the following options:

  • Apply Modifiers
  • Normals
  • UV Coordinates
  • Triangulate Faces (so that the mesh is made of triangles, not quads)

Images from the project

1 2 3 4 5 6

关于 About

3D graphics renderer made from scratch using the C programming language.
3d-rendering-engine

语言 Languages

C99.5%
Makefile0.3%
Shell0.2%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
0
Total Commits
峰值: 1次/周
Less
More

核心贡献者 Contributors