|
|
|
@ -10,12 +10,43 @@ here are imported as overrides to the OpenGL functions of
|
|
|
|
|
that widget. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
from OpenGL.GL import glClearColor, glEnable |
|
|
|
|
from enum import Enum |
|
|
|
|
|
|
|
|
|
from OpenGL.GL import glClearColor, glEnable, GL_LIGHT0, GL_LIGHTING |
|
|
|
|
|
|
|
|
|
class Color(Enum): |
|
|
|
|
BLUE = 0 |
|
|
|
|
|
|
|
|
|
# A simple map from Color -> RGBA 4-Tuple |
|
|
|
|
COLOR_TO_RGBA = { |
|
|
|
|
Color.BLUE: (0, 128, 255, 255) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
def initialize_gl(): |
|
|
|
|
""" |
|
|
|
|
Initializes the OpenGL context on the Window. |
|
|
|
|
""" |
|
|
|
|
# Since we aren't using shaders lighting needs to be |
|
|
|
|
# enabled. |
|
|
|
|
glEnable(GL_LIGHTING); |
|
|
|
|
glEnable(GL_LIGHT0); |
|
|
|
|
|
|
|
|
|
# Set white background |
|
|
|
|
glClearColor(255, 255, 255, 0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def draw_point(x, y, color): |
|
|
|
|
""" |
|
|
|
|
Simple point drawing function. |
|
|
|
|
|
|
|
|
|
Given a coordinate (x, y), and a Color enum this |
|
|
|
|
function will draw the given point with the given |
|
|
|
|
color. |
|
|
|
|
|
|
|
|
|
@param x The x-coordinate. |
|
|
|
|
@param y The y-coordinate. |
|
|
|
|
@param color The Color Enum. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
if not isinstance(color, Color): |
|
|
|
|
raise ValueError("Color must exist in the Color enumeration") |
|
|
|
|