I was writing a new code base in opengl and have encountered a weird bug very early on. It is a distinct fluctuation in framerate that is repetitive and predictable.
I know that it is definitely proportional to objects rendered. It is also proportional to screen size (not viewport size, not window size, just physical device size) It is roughly a ratio of 0.2:1 (low:high) frames
I got curious and graphed it, bear in mind that the window/context isn't vsynced or capped.
The view is completely stationary and all objects are stationary. Each frame is exactly the same. No input was given at any time. There is nothing time-based. No garbage collection happens.
I don't get it, if it is basically one frame being rendered over and over what could cause such a great change?
Here's the pseudo code of program flow
create window
load shaders
grab uniform locations
create camera
create 3 meshes // They just hold the buffers and data for a model
create x objects and pass a pointer to a random mesh // Objects hold position, rotation etc + link to mesh
while game is running
poll window for events
capture mouse and recalculate VP matrix if required
for each object
recalc MVP
bind mesh's buffers and draw elements
draw window //SFML handles this, just swaps front/back buffers and draws
clean up data
If this gives no insights then I uploaded the VS2012 project to github: https://github.com/Twistedsnail/Untitled_for_SO(it probably won't run locally because it requires SFML2 in a specified location and GLM in VS's files)