1

I have written a small program that displays a heat-map of roughly 1024X1024 pixels which lie on the surface of a sphere.
Each pixel is a Quad.
The vertices as well as the Colors are stored in a VBO (vc_VBO).
A separate Index VBO is used to draw the Quads.

The draw code looks like this:

self.vc_VBO.bind()
self.index_VBO.bind()
gl.glEnableClientState(gl.GL_VERTEX_ARRAY)
gl.glEnableClientState(gl.GL_COLOR_ARRAY)
        
gl.glColorPointer(4, gl.GL_FLOAT, 28, self.vc_VBO+12)
gl.glVertexPointer(3, gl.GL_FLOAT, 28, self.vc_VBO)
        
gl.glDrawElements(gl.GL_QUADS, len(self._indices), gl.GL_UNSIGNED_INT, None)

The problem I have is that I want each Quad to have a uniform(i.e. constant) color which is defined by the color of its upper left vertice, how can I achieve this ?
Am I on the right track or should I do things completely different ?

Here is a sample picture of how the program looks,right now: image

Tim
  • 111
  • 6
  • 2
    You might find [this](https://stackoverflow.com/questions/60022613/how-to-implement-flat-shading-in-opengl-without-duplicate-vertices) Q&A useful. It might require you to move to core profile functionality, however. – Brett Hale Oct 06 '21 at 11:30
  • 1
    If you understand shaders, you can set a uniform (a constant variable that each draw call references), and use this uniform to colour your quad. This is a great resource for everything opengl. https://learnopengl.com/Getting-started/Shaders – Jaan Oct 06 '21 at 20:47
  • Thanks a bunch for the comments. I was totally oblivious to the fact that there is the glShadeModel(GL_FLAT) option. That solved it. @BrettHale If you post your remark as answer I'll gladly accept it. – Tim Oct 06 '21 at 21:19

0 Answers0