PDA

View Full Version : Non-smooth vertical movement of the horizontal lines



sinaxp19
07-20-2015, 03:21 AM
Hi everybody :)
I have a weird problem: Simply put, I want to draw lots of horizontal lines on the screen which move vertically by time. For now, I've just used a simple value for Y (instead of real time) to examine the problem. There are thousands of vertices in my VBO with specific X and Y. I use glMapBuffer to access them one by one before each render loop and reduce their Y value by a certain offset. The problem is, the overall lines movement is not smooth and - on every frame - some line move up while others don't. I've tried VSync, BufferData, FPS increase/decrease, etc. Here's a sample code (C# OpenTK):


GL.BindBuffer(BufferTarget.ArrayBuffer, _vbo);
IntPtr bufferPointer = GL.MapBuffer(BufferTarget.ArrayBuffer, BufferAccess.ReadWrite);
try
{
unsafe
{
var dataPointer = (Vector2*)bufferPointer.ToPointer();
for (int i = 0; i < _initialVertexData.Length; i++)
{
dataPointer[i].Y -= 10f;
}
}
}
catch
{
throw new Exception("Error in MapBuffer");
}
GL.UnmapBuffer(BufferTarget.ArrayBuffer);
GL.BindBuffer(BufferTarget.ArrayBuffer, 0);

and a sample GIF snapshot of what happens:
http://tinypic.com/view.php?pic=4rtapw&s=8#.Vay9LPlv8fU