Giter Site home page Giter Site logo

wallashss / 3d-renderer-in-c Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michalzalobny/3d-renderer-in-c

0.0 0.0 0.0 5.96 MB

3D graphics renderer made from scratch using the C programming language.

Home Page: https://michalzalobny.com/case-study/3d-renderer-in-c

Shell 0.19% C 99.53% Makefile 0.28%

3d-renderer-in-c's Introduction

3D Renderer in C

Building a 3D graphics renderer from scratch using the C programming language.

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)

Based on Gustavo Pezzi's course

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

3d-renderer-in-c's People

Contributors

michalzalobny avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.