May 2019
Intermediate to advanced
542 pages
13h 37m
English
Now that our OpenGL environment is initialized, we can move on to the paintGL() method. This method will contain all the code for drawing our 3D object and will be called whenever the widget needs to be updated.
The first thing we'll do when painting is clear the canvas:
def paintGL(self): self.gl.glClearColor(0.1, 0, 0.2, 1) self.gl.glClear( self.gl.GL_COLOR_BUFFER_BIT | self.gl.GL_DEPTH_BUFFER_BIT) self.program.bind()
glClearColor() is used to fill the background of the drawing with a solid color, as specified by our arguments. Colors in OpenGL are specified using three or four values. In the case of three values, they represent red, green, and blue. A fourth value, when used, represents the alpha, or opacity, of ...
Read now
Unlock full access