Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Best way to render a "rectangle matrix"

  1. #1
    Newbie Newbie
    Join Date
    Jul 2013

    Question Best way to render a "rectangle matrix"


    I'm new to OpenGL programming and I'm working on a 2-d heatmap style animation.
    - got 2-d array of double values (say 800x800 max)
    - points should be represented as "big pixels" (rectangles, color-coded)
    - goal is to display at around 30 FPS

    First, I tried to visualize the array using GDI on Windows. Sure got 3-4 FPS...
    Now trying to render using Qt/OpenGL I build a large amount of rectangles,
    one for every point of the 2-d array. My naive approach with only
    glColor() and glRect() calls works much better (about 20-30 FPS) if the
    array stays small (300x300).

    However, obviously there are smarter ways to do this. So please, give me
    some optimization advice.

    Some things I already thought about:
    - rect grid does not change -> move it to the GPU once (how?), update colors only
    - draw a bitmap texture (CPU pixel-wise access to a bitmap might be even slower
    than drawing thousands of rects on GPU)

    Any suggestions are welcome!
    Thank you.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    rect grid does not change -> move it to the GPU once (how?), update colors only

    This is the right approach but since you are new to OpenGL you should wander your way through this it will answer the how-to

Posting Permissions

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