![]() |
Tutorial 3: A splash of color Learn how to fill polygons with color. |
![]() |
![]() |
![]() |
![]() |
![]() |
Control | Name | DoubleBuffer | Left | Top | Maximize Button |
Window | SurfaceWindow | - | - | - | ON |
OpenGLSurface | Surface | ON | 0 | 0 | - |
![]() |
Self.MouseCursor = System.Cursors.StandardPointer |
Surface.Render |
X3_SetPerspective Surface |
OpenGL.glPushMatrix OpenGL.glClearColor(0, 0, 0, 1) OpenGL.glClear(OpenGL.GL_COLOR_BUFFER_BIT) OpenGL.glTranslatef 0.0, 0.0, -5.0 OpenGL.glBegin OpenGL.GL_TRIANGLES OpenGL.glColor3d 1, 0, 0 OpenGL.glVertex3d -1, 1, 1 OpenGL.glVertex3d -2, 0, 1 OpenGL.glVertex3d 0, 0, 1 OpenGL.glColor3d 0, 1, 0 OpenGL.glVertex3d 1.5, 1, 1 OpenGL.glVertex3d 0.5, 0, 1 OpenGL.glVertex3d 2.5, 0, 1 OpenGL.glEnd OpenGL.glPopMatrix |
OpenGL.glPushMatrix OpenGL.glClearColor(0, 0, 0, 1) OpenGL.glClear(OpenGL.GL_COLOR_BUFFER_BIT) OpenGL.glTranslatef 0.0, 0.0, -5.0 OpenGL.glBegin OpenGL.GL_TRIANGLES OpenGL.glColor3d 1, 0, 0 OpenGL.glVertex3d -1, 1, 1 OpenGL.glVertex3d -2, 0, 1 OpenGL.glVertex3d 0, 0, 1 OpenGL.glColor3d 0, 1, 0 OpenGL.glVertex3d 1.5, 1, 1 OpenGL.glVertex3d 0.5, 0, 1 OpenGL.glVertex3d 2.5, 0, 1 OpenGL.glEnd OpenGL.glPopMatrix |
We use glColor3d to set the red, green and blue components of the drawing color, prior to drawing each polygon. After calling glColor3d, all subsequent vertices are drawn with this color, until the color is changed again with glColor3d. |
![]() |
![]() |