Best way to render a "rectangle matrix"

Hi

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.

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 http://www.opengl-tutorial.org/ it will answer the how-to