OpenGL is Awesome!!
By Kshitij Aucharmal β’ 4 minutes read β’
Okay, so this is gonna be a bit long, get excited!
Lets divide this into three Parts:
- OpenGL
- C++
- Kdevelop
Lets start with OpenGL first.
OpenGL
OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics
OpenGL is cross-platform like vulkan, and wayyyy easier to understand and code than vulkan. While vulkan took me one week to get started and to draw a triangle on the screen (the one thing you do first as a graphics programming beginner), OpenGL allowed this to happen in under a few hours !!!
Iβve identified some differences, which maybe good or bad according to industry standards, but Iβll list them here according to my standards
Lets focus on the good points first:
- OpenGL is easy: The code is easy to understand, it does not require a hell lot of setup to get started, and also makes everything easier to understand. I of course am comparing it to Vulkan
- Handles a lot of things on its own: using glad, which is library for managing function pointers for OpenGL, initialization is a cinch
- Fast on my machine: Vulkan gave me some lagging when resizing windows, maybe it was my fault (probably), but in OpenGL I just used a callback function and it worked without any significant lags
Unfortunately, OpenGL is not all good:
- Not explicit: Many things are handled internally, unlike vulkan which allows for in depth customization of each system using structs.
- Not Shader friendly: Although people may call it shader friendly as you can compile the shaders anywhere you want in the code, but the code has to be compiled and shaders are a part of this. shaders can be kept different from the full code compilation, unlike vulkan.
- Slower: I havenβt personally experienced this, but people have said that Vulkan is much more performant than OpenGL
Given everything above, Iβm going to stick to OpenGL and try my best to make the engine Next step will be to integrate Imgui, which is much easier as compared to Vulkan
Current Progress
Yup, two triangles forming a rectangle with only 4 vertices defined and 6 indices for drawing/filling in the triangles using VBO and EBO This is the progress I got, and I can even send these values to the vertex shader !!!
The process is for rendering anything on the screen is as follows, taken from the LearnOpenGL website
The Vertex Buffer Objects (VBO) and Element Buffer Objects (EBO) are stored as follows under the Vertex Array Objects
C++
Iβm learning c++ from the c++ playlist series by the cherno, and its been amazing. I understand a lot of concepts, and it really allows my code to flow seamlessly. I have taken the liberty to seperate all of the code into seperate files, creating namespaces for certain systems such as WindowManagement
and InputManagement
. The heirarchy of the code is as follows:
OpenGL
βββ build
βββ CMakeLists.txt
βββ external
βΒ Β βββ glad
βΒ Β βββ imgui
βββ include
βΒ Β βββ input.hpp
βΒ Β βββ shaderman.hpp
βΒ Β βββ window.hpp
βββ Makefile
βββ OpenGL.kdev4
βββ shaders
βββ src
βββ input.cpp
βββ main.cpp
βββ shaderman.cpp
βββ window.cpp
As you can see, the structure is a pretty standard one with all the headers in the include
directory, c++ files in the src
directory, and the libaries in the external
directory. The shaders
is for storing the shader files, which is currently not being used as the shaders are written as const char *
(Iβm following the tutorial man)
The CmakeLists.txt handles everything, and I have a new Target in it to run the program once its compiled as well
Kdevelop
Yeah, I started using Kdevelop. Neovim is amazing, but the syntax highlighting and lsp server messes up as the structure changes. It does not take the CmakeLists.txt
in consideration, and hence Iβm always faced with not resolved/found errors.
As to why I donβt use VSCode, its electron based, and feels too slow for me.
Kdevelop has been perfect, it automatically detects what my CmakeLists.txt defines, and adds targets to the project window. It also has much better autocomplete, vi mode, and my preffered theme ayu-dark
built-in, so thats definately a plus.
Iβve added a custom target to the make system, so that I can just build (the build system is amazing as well, you can just add and remove targets) and it will run the binary generated as well. I canβt use harpoon (a nvim plugin) in it, but Iβll soon get used to Kdevelopβs version of it, and it definately feels fast as nvim too.
Thats it! That was the update, will see you guys in the next one!!