I've been working on an OpenGL program that simply renders a square that rotates in 3D space. The square also has a texture applied to both sides. Here you can see an example screenshot of the program running:
I used very little abstraction in that project and most of the code was in main.cpp (apart from the shader loading and usage).
After finishing this project, I wanted to improve it as much as I could with my current knowledge. I started abstracting away functionality. The final result was a very clean main.cpp file with multiple classes (Mesh, Shader, Resource Manager and Window classes).
Apart from the texture, everything should functionally be the same, but I experienced the following after using the rotate function; left is the abstracted version of the first project, right is the first project:
The square in the new project rotates at a much higher speed than in the previous project. The implementation is the same, as in, the degrees that the square should rotate around the y-axis are the same in both projects - the time the program has been running, which is gotten through GLFW's
I checked nearly everything. The .lib files are linked the same way between the projects. There are no differences between the vertex data. Both projects are running in DEBUG mode.
The only difference I could think of is the texture not being applied in the second project, but I recall that the textureless version of the first project was still running with the same speed as it is currently. But rendering a 64x64 texture on a square shouldn't be that expensive to run.
NOTE: I'm using GLM for the matrices and for the rotation transformation.
Does abstracting away all of OpenGL's initializing and buffer code improve performance by that much?
I'm using GLFW for window and context creation, and thus using
(float)glfwGetTime() for the angle of rotation along the y-axis.
The second project basically moves over all functionality into categorized classes. So everything to do with meshes was moved to a Mesh class, loading of GLSL shaders and textures was moved over to a ResourceManager class etc. So all functionality should be the same.