Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: How to scroll a drawn texture

  1. #1
    Newbie Newbie
    Join Date
    Sep 2017
    Posts
    1

    How to scroll a drawn texture

    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.

  2. #2
    Intern Contributor
    Join Date
    Dec 2016
    Posts
    55
    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/UCzx..._as=subscriber

    Hope this helps,

    Jeff

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •