o
odinpkg.dev
packages / library / learn_graphics_programming

learn_graphics_programming

76bcd72library

Learning "GPU + Graphics Programming" with "OpenGL" using "Odin Programming Language".

MIT · updated 11 months ago

Learn Graphics Programming | mainly OpenGL with Odin Language

A repository dedicated to learning the fundamentals of graphics programming from the ground up. This project uses the Odin programming language and modern graphics APIs to explore core concepts, starting with simple shapes and progressing to a basic rendering engine.

Table of Contents


Project Overview

This project serves as a hands-on guide to understanding the principles of computer graphics. It is structured as a series of lessons, each building upon the last, to incrementally introduce new techniques and concepts. The primary goal is to demystify the graphics pipeline by implementing various features manually, leading to the development of a small, reusable rendering engine.

Technologies Used:


Core Concepts Covered

The lessons within the src directory cover the following fundamental topics:

  1. Basic Drawing: Rendering your first triangle.
  2. Shapes: Creating more complex shapes like squares.
  3. Index Buffers: Efficiently drawing objects by reusing vertices.
  4. Uniforms: Passing data from the CPU to shaders.
  5. Textures: Applying 2D images to surfaces.
  6. Blending: Implementing transparency and alpha blending.
  7. MVP Transformations: Understanding Model-View-Projection matrices for 3D space.
  8. Multiple Objects: Rendering a scene with several distinct objects.
  9. Batch Rendering: An optimization technique for drawing many similar objects efficiently.

Getting Started

Prerequisites

Before you begin, ensure you have the following installed on your system:

  • Odin Compiler: The project is written in Odin.
  • Make: For running the build scripts.
  • A C Compiler: (e.g., GCC or Clang) for linking dependencies.
  • OpenGL-compatible Graphics Driver: Required for rendering.
  • GLFW and GLEW/GLAD: Or equivalent libraries for window creation and OpenGL function loading. The Makefile should handle local dependencies.

Building and Running

You can compile and run any of the lessons using the provided Makefile.

To run a specific lesson, navigate to the project root and use the make run command with the lesson number. For example, to run the 01_triangle example:

make run LESSON=01_triangle

To run the main application which uses the developed engine:

make run LESSON=main

Project Structure

The repository is organized as follows:

.
├── Learn_Vulkan/     # (Future Work) Exploration of the Vulkan API
├── Makefile          # Build script for compiling and running lessons
├── shaders/          # GLSL shader files for vertex and fragment processing
├── src/              # Source code for all lessons and the rendering engine
│   ├── 01_triangle.odin  # Individual lessons
│   ├── ...
│   └── Engine/           # Core components of the rendering engine
└── textures/         # Image files used for texturing

Engine Components

As the lessons progress, a small rendering engine is developed with the following components located in src/Engine/:

  • Renderer: A high-level structure that encapsulates rendering logic.
  • VertexBuffer & IndexBuffer: Abstractions for managing vertex and index data on the GPU.
  • VertexArray: Represents the state of vertex buffers and their layouts.
  • VertexBufferLayout: Defines the structure of vertex data (e.g., position, color, texture coordinates).
  • Shader: A helper for loading, compiling, and managing GLSL shader programs.
  • Texture: A structure for loading and binding texture images.
  • Debugger: Provides utility functions for debugging and error checking.

Contact

FacebookInstagramLinkedinX