Thanks for the quick response!
I technically update the VBO when the float array I use to store vertex positions changes.
I do this (as well as drawing) on a timer that ticks every 1 ms (the time I set the tick to has not positively affected performance). I’m still pretty new to OpenGL so I’m not completely familiar with what SwapBuffers actually does, but I still call it.
*Note: GL11 is just a class I made because I used to use LWJGL a bit
The following code is run once every frame
First I get the models that will be rendered and add their data to the float array
//Set the current models that should be rendered
pinnedModals = data;
//Add vertex data to float array inside of a object called vertexBuffer
formatModalData(data);
Next I set buffer data if I have to and I make a draw call
// This variable stores the vertex data used last frame and checks if the buffer should update
if (!compareArrays(vertexBuffer.buffer(), GL11.CURRENT_BUFFER_DATA))
{
//Set Buffer Data
SetData(0, vertexBuffer, false, 3, GL11.GL_STATIC_DRAW);
Debug.WriteLine("Updating buffer with " + vertexBuffer.getSize() + " vertices");
}
gl.DrawArrays(GL11.GL_TRIANGLES, 0, 36 * pinnedModals.Length);
Next I make a call to Blit (a function in sharpgl) which does this
if (deviceContextHandle != IntPtr.Zero)
{
// Set the read buffer.
gl.ReadBuffer(OpenGL.GL_COLOR_ATTACHMENT0_EXT);
// Read the pixels into the DIB section.
gl.ReadPixels(0, 0, Width, Height, OpenGL.GL_BGRA,
OpenGL.GL_UNSIGNED_BYTE, dibSection.Bits);
// Blit the DC (containing the DIB section) to the target DC.
Win32.BitBlt(hdc, 0, 0, Width, Height,
dibSectionDeviceContext, 0, 0, Win32.SRCCOPY);
}
Then I make a call to Win32.SwapBuffers and im done with that frame.
Here are the calls made once when the program starts:
GL11.gl.Create(SharpGL.Version.OpenGLVersion.OpenGL2_1, RenderContextType.FBO, 1, 1, 32, null);
GL11.gl.ShadeModel(GL11.GL_SMOOTH);
GL11.gl.ClearColor(0F, 0F, 0F, 0F);
GL11.gl.ClearDepth(1.0);
GL11.gl.Enable(2929U);
GL11.gl.Enable(GL11.GL_VERTEX_ARRAY);
GL11.gl.Enable(GL11.GL_CULL_FACE);
GL11.gl.CullFace(GL11.GL_BACK);
GL11.gl.FrontFace(GL11.GL_CCW);
GL11.gl.DepthFunc(GL11.GL_LESS);
GL11.gl.Hint(3152U, 4354U);
Thank you!
-Shadow
Edit: Here’s the link to the SharpGL source on github: sharpgl/source/SharpGL/Core/SharpGL at master · dwmkerr/sharpgl · GitHub