Modern OpenGL example

I have been in the process of learning modern OpenGL and I was finally able to get a full working example. However the means I did so was complicated. I had to copy paste examples from two entirely different tutorials and mash them together for the purposes of what I wanted. One tutorial used SFML for context creation but set up the Vertex Buffer Object, Vertex Array Object, and shaders for a 2D drawing. The other tutorial used GLFW and glad for setting up the context but then was using 3D coordinates and did not have examples of shaders that I understood. I merged the two tutorial examples into one and the result was about 150 lines of code to draw a triangle.

So far all my work has not enabled me to do anything new that I couldn’t do with legacy OpenGL but the way this was set up with glad was so that only the modern functions are loaded and all the deprecated functions like glbegin/end cannot be used. I’m learning the modern way but so far it seems like the modern way is stupid compared to the old legacy way. But at the same time there is supposed to be some performance benefit from what I read. I have two free youtube tutorials I can follow as well as the opengl course on linkedin.

But one really weird thing is that compiling things still requires the weirdest set of flags and each opengl tutorial uses different libraries for context creation and extension loading. So I’m having a hard time making sense of much, but I can brag that I wasted 12 hours of my life drawing a triangle! This is why I am glad computer programming is something I do for fun and not my paid job.

I took screenshots of the entire program!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s