PDA

View Full Version : How to scroll a drawn texture



RobSz123
09-13-2017, 11:32 AM
Hi,

I have written a WinForms .Net app using OpenGL.Net to render iterations of 1d cellular automata.
A line of cells is drawn at top of window with randomly coloured cells.
When next line is drawn a formula is applied to determine color of each cell based on neighbouring cells in the line above.
And so the process continues, drawing a line of cells (iteration) at a time.

When I get to the last line at the bottom of the window, I would like to move all lines up one and draw the next line at the bottom, thus scrolling the drawn iterations up as I draw new lines of cells at the bottom of the window.

How to do this smoothly in OpenGL?

Since this is in .Net, my initial attempt was to draw iterations into a WinForms managed bitmap the size of the window and then call glDrawPixels to render the bitmap for each frame.
(I use unsafe pointers and bitmap data to shift cells in the bitmap to move the iterations up.)
This works, but there is some flicker/shimmer/jitter. I tried doing this in the Render event handler as well as doing my own game loop at 30fps as well as 60fps with VSync on.
Maybe rendering a window size bitmap for each frame is not the best way to go.

Is there a proper way to do this in OpenGL, maybe without managed Bitmaps?
I am new to OpenGL, so am just learning.

Thanks,
Rob.

OceanJeff40
09-19-2017, 09:48 PM
I'm fairly new to OpenGL, and the only stuff I know about .NET is from powershell.....

but I would draw colored triangles (two for a square ie. cell) and let OpenGL render to the back buffer for you, instead of going pixel by pixel.

Just my thoughts, and now my shameless plug for my youtube channel with opengl tutorials.

https://www.youtube.com/channel/UCzx8alrxVELz5h1dfCdkdfg?view_as=subscriber

Hope this helps,

Jeff

P.S. I would love to see some screen shots or your work!