Skip to content

kidando/learnopengl-odin

Repository files navigation

Learn OpenGL (https://learnopengl.com/) examples in Odin

This repo contains code for the examples from the Learn OpenGl site but written in Odin. At the end of each chapter on the site, there is a link to C++ source code. This project replicates that but again, using Odin.

What you need before you start

  • You will need to install Odin. The Getting Started guide has different options you can follow.
  • If you have Odin already, I suggest that you update it. I will be using the most recent build of odin as of the time I uploaded this repo onto github.
  • You will need a text editor or IDE. This project was a put together in VS Code (and on Win11)
  • That's it. Odin ships with the libraries needed to follow along with the tutorials on learnopengl. Plus the additional assets required are contained in the project.

Changes compared the C++ versions

For starters, Odin is not an object-oriented language while C++ is. In the original C++ versions, OOP is used in certain chapters. In this project there are places where I will use functions to minimize code repetition and to make the code a lot more readable.

Also, this is not going to be a "direct translation" from C++ to Odin. There are concepts in Odin that are just different or let me say, interpreted differently. Because of that, I shall try my best using comments, to explain what exactly the Odin code is doing in contrast to it's C++ counterpart.

How to run the projects

This is not one large Odin project, instead it is a collection of smaller Odin projects grouped by chapters. To run each project, you will need to enter each folder and run the project from there. Simply run odin run . and you will be good to go.

cd 1-4-a-hello-triangle/
odin run .

If you get stuck or need help

  • Bugs in my code could cause you to get stuck. If you catch a bug, please submit an issue
  • I highly recommend visiting Learn OpenGL to get in-depth explanations (outside of code) of how things work.
  • If you need assistance with Odin and OpenGL, I highly recommend joining two Discord servers
  • If you are new to Odin and are interested in learning it, I recommend checking the Odin website. You can also follow Ginger Bill (Creator of Odin) on Youtube. You can also checkout Karl's Youtube Channel and I recommend buying his book Odin Book.
  • It goes without saying but using web search engines helps
  • In case you use ChatGPT or equivalent, just keep in mind that unlike search engine results, these programs tend to return just 1 solution or result that they deem most accurate/relevant. As opposed to a list of different results that you could compare and analyze yourself. That 1 result may not always be correct (I speak from experience 😭)

Notes

Chapter 3 Modeling Loading With Assimp (Not Working 100%)

  • To use the Assimp library for odin to follow along with learnopengl.org import oding bindings library Odin-Assimp
  • To follow along with this project you can import this library into the shared folder of where you have installed your odin repo locally. For example it could be that you installed/cloned odin to C:\Odin.
  • Open your terminal in this location and cd into the shared directory so that it becomes C:\Odin\shared
  • Clone the odin-assimp library into this directory by running git clone https://github.com/CoolDove/odin-assimp.git
  • This will allow you to use the assimp library in all your odin projects moving forward. Simply add the following import statement at the top of your odin file import assimp "shared:odin-assimp"
  • I added this just so that I could follow along with learnopengl. However, I highly recommend using the cgltf package I describe next.

Chapter 3 Model Loading With CGLTF (Works 100%)

  • To use the cgltf package simply import it from vendor as it ships with odin.
  • Just add import "vendor:cgltf" at the top of your file. In my implementation I import it as import cg "vendor:cgltf".
  • This will be the loader used for the rest of the lessons

Chapter 4 Differences in how the final application build looks

  • There is a slight (or maybe not so slight) difference in my application build compared to what learnopengl has as their application build. In this chapter it is the first time we use random number generation and if I were to guess, that is where the cause of the difference may lie. However, this goal of the chapters are met regardless of the visual difference.

TODO

  • Chapter 1 - Getting Started
  • Chapter 2 - Lighting
  • Chapter 3 - Model Loading
  • Chapter 4 - Advanced OpenGL
  • Chapter 5 - Advanced Lighting
  • Chapter 6 - PBR
  • Chapter 7 - Debugging
  • Chapter 8 - Text Rendering
  • Chapter 9 - 2D Game

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published