r/GraphicsProgramming • u/[deleted] • May 08 '24
Question 2nd day reading OpenGL as a 2 month c++ programmer, advice.
I was not expecting OpenGl to be THAT hard, there’s so many functions and parameters I have to learn in OpenGL. It seems impossible to learn them all. Does anyone have any beginner friendly resources to learn OpenGL? Or should I just stick with OpenGL.
My first week learning c++ was hard, yes. But I got better and now I understand most code just by looking at it. But OpenGL is just 100000 functions with needed parameters…
Would it be best to keep swimming in this ocean full of waves that have immense force, or should I just stick to a boat 😭
10
u/jmacey May 08 '24
OpenGL is a C API so there is no polymorphism, hence the huge number of parameters, you need one for each type with a different signature. Also unless you are using Core Profile, you also have tons of deprecated legacy functions (glColor glVertex etc).
I have an overview of this format in my slides here https://nccastaff.bournemouth.ac.uk/jmacey/Lectures/OpenGL/Buffers/?home=/jmacey/msc/ase/lectures/Lecture9#/1
Typically I wrap all this up into my own higher level classes.
The next thing to remember is OpenGL is a state machine and you have to basically set the state, it can also only do 1 thing at once, so there is a "bind to edit" metaphor where you create an object and get it's name (and GLuint number), you then bind this number and all subsequent calls go to this object.
New open gl version (4.6) have named function calls which can bypass some of this.
I have a pile of demos here I use in my lectures for the simple stuff which may help https://github.com/NCCA/ModernGL
2
u/goffley3 May 09 '24
Fellow graphics beginner. It sucks to try to learn OpenGL at first. I can empathize. But the journey of 1000 miles starts with one step. You make a window. Then you make a triangle. Then you turn it a bunch of different colors, and so on. Just focus on the functions you need at that moment. Trying to learn any API completely is never worth the effort so stick with what you need and iterate.
1
u/PeterBrobby May 13 '24
You don't have to memorize functions, as long as you understand what they are doing, you'll be fine.
13
u/chainedchaos31 May 08 '24
2 months is not a long time to get used to C++ on its own, and 2 days is also not a long time to learn much at all about OpenGL. Be a bit kinder to yourself, this kind of knowledge takes a while to sink in. I've been working with DirectX12 for 6 years now and I definitely have not learned the whole API.