Index: README.md
===================================================================
--- README.md	(revision 1d1c77e4e45598881a617b58774128a8dbdf592d)
+++ README.md	(revision e79c83311eeb205e74f8040166dba5c9dcbc891c)
@@ -1,4 +1,5 @@
 On linux, you need to install tkinter:
 sudo apt-get install python3-tk
+sudo apt-get install python3-opengl
 
 On mac, install pygame like this:
@@ -11,2 +12,5 @@
 pip3 install pygame
 pip3 install pyobjc
+
+Run the game with:
+python3 game.py
Index: game.py
===================================================================
--- game.py	(revision 1d1c77e4e45598881a617b58774128a8dbdf592d)
+++ game.py	(revision e79c83311eeb205e74f8040166dba5c9dcbc891c)
@@ -1,7 +1,114 @@
-import pygame, platform
+import pygame, OpenGL, math
+
+from OpenGL.GLU import *
+from OpenGL.GL import *
+
+import platform
+
+[w, h] = [0, 0]
+
+def render(surface, overlay, font, state):
+   #surface.fill((0, 0, 0))
+
+   #glEnable (GL_BLEND); glBlendFunc (GL_ONE, GL_ONE);
+
+   if state:
+      renderOverlay(overlay, font)
+      projectOverlay(surface, overlay)
+   else:
+      render3d(surface)
+
+
+def renderOverlay(overlay, font):
+   #pygame.draw.rect(overlay, (0, 0, 255), pygame.Rect(0, 0, w, h))
+   #pygame.draw.circle(overlay, (255, 0, 0), (int(w/2), int(h/2)), 540)
+   #overlay.set_colorkey((255,0,0))
+
+   text = font.render("2D drawing", True, (0, 128, 0))
+
+   pygame.draw.rect(overlay, (0, 128, 255), pygame.Rect(30, 30, 60, 60))
+   overlay.blit(text, (500, 100))
+
+def projectOverlay(surface, overlay):
+   
+   glPushMatrix()
+   glTranslatef(0.0,0.0,-zNear)
+
+   textureData = pygame.image.tostring(overlay, "RGBA", 1)
+   width = overlay.get_width()
+   height = overlay.get_height()
+
+   glEnable(GL_TEXTURE_2D)
+
+   glBindTexture(GL_TEXTURE_2D, glGenTextures(1))
+   # maybe use GL_RGBA here instead
+   #glPixelStorei(GL_UNPACK_ALIGNMENT,1)
+   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData)
+
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
+   glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
+
+   glBegin(GL_QUADS)
+
+   glTexCoord2f(0.0, 0.0)
+   glVertex2f(-(w/h), -1)
+
+   glTexCoord2f(1.0, 0.0)
+   glVertex2f((w/h), -1)
+
+   glTexCoord2f(1.0, 1.0)
+   glVertex2f((w/h), 1)
+
+   glTexCoord2f(0.0, 1.0)
+   glVertex2f(-(w/h), 1)
+
+   glEnd()
+
+   glPopMatrix()
+
+def render3d(surface):
+   vertices = (
+      (1, -1, -1),
+      (1, 1, -1),
+      (-1, 1, -1),
+      (-1, -1, -1),
+      (1, -1, 1),
+      (1, 1, 1),
+      (-1, -1, 1),
+      (-1, 1, 1)
+   )
+   edges = (
+      (0,1),
+      (0,3),
+      (0,4),
+      (2,1),
+      (2,3),
+      (2,7),
+      (6,3),
+      (6,4),
+      (6,7),
+      (5,1),
+      (5,4),
+      (5,7)
+   )
+   
+   glPushMatrix()
+
+   glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
+
+   glTranslatef(0.0,0.0,-2*zNear)
+   glColor3f(1.0, 1.0, 1.0)
+
+   glBegin(GL_LINES)
+   for edge in edges:
+      for vertex in edge:
+         glVertex3fv(vertices[vertex])
+   glEnd()
+
+   glPopMatrix()
 
 system = platform.system()
-
-[w, h] = [0, 0]
 
 if system == 'Windows':
@@ -37,11 +144,26 @@
    gameDisplay = pygame.display.set_mode((800, 600))
 else:
-   gameDisplay = pygame.display.set_mode((w, h), pygame.FULLSCREEN)
+   gameDisplay = pygame.display.set_mode((w, h), pygame.FULLSCREEN|pygame.DOUBLEBUF|pygame.OPENGL)
+
+overlay = pygame.Surface((w, h))
 
 pygame.display.set_caption('Space Game')
 
 clock = pygame.time.Clock()
+   
+font = pygame.font.SysFont("comicsansms", 48)
 
 running = True
+state = False
+
+zNear = 1.0/math.tan(math.radians(45.0/2))
+gluPerspective(45, (w/h), zNear, 500.0)
+
+'''
+# Use glFrustum to focus the camera at a point other than the screen center
+zNear = 1.0
+glFrustum(-1.5, 0.5, -1.0, 1.0, zNear, 500.0)
+glTranslatef(0.0,0.0,-5.0)
+'''
 
 while running:
@@ -52,8 +174,12 @@
          if event.key == pygame.K_ESCAPE:
             running = False
+         elif event.key == pygame.K_SPACE:
+            state = not state
 
       #print(event)
 
-   pygame.display.update()
+   render(gameDisplay, overlay, font, state)
+
+   pygame.display.flip()
    clock.tick(60)
 
