roc/roc.py
2011-06-15 19:21:13 -06:00

86 lines
1.7 KiB
Python
Executable file

import pygame
from pygame.locals import *
import gamedata
import gametimer
import video
import shader
import inputs
from OpenGL.GL import *
def init2d():
init(videoinit=video.init2d)
def init3d():
init(videoinit=video.init3d)
def init(videoinit):
pygame.init()
size = width, height = (1600,1200)
size = width, height = (1024,768)
video.set_res(size)
videoinit()
video.enable_vsync()
def test_frame():
from PIL import Image
# pink triangle
glBegin(GL_TRIANGLE_STRIP)
glNormal3f(0.0, 0.0, 1.0)
glColor4f(1.0, 0.0, 0.5, 1.0)
glVertex3f( 20.0, 50.0, 1.0)
glVertex3f( 20.0, 600.0, 1.0)
glVertex3f( 400.0, 50.0, 1.0)
glEnd()
# yellow square
glBegin(GL_TRIANGLE_STRIP)
glNormal3f(0.0, 0.0, 1.0)
glColor4f(1.0, 1.0, 0.0, 1.0)
glVertex3f( 150.0, 20.0, -50.0)
glVertex3f( 150.0, 400.0, -50.0)
glVertex3f( 360.0, 20.0, -50.0)
glVertex3f( 360.0, 400.0, -50.0)
glEnd()
# texture test
glBegin(GL_TRIANGLE_STRIP)
glNormal3f(0.0, 0.0, 1.0)
glColor4f(1.0, 1.0, 1.0, 1.0)
glVertex3f( 500.0, 300.0, 5.0)
glVertex3f( 500.0, 500.0, 5.0)
glVertex3f( 700.0, 300.0, 5.0)
glVertex3f( 700.0, 500.0, 5.0)
glEnd()
def main():
gametimer.start_loop()
while True:
events = pygame.event.get()
gametimer.next_frame()
pygame.event.pump()
for ev in events:
if ev.type == QUIT:
inputs.add_command('exit')
break
elif ev.type == KEYUP:
inputs.keyup(ev.key)
elif ev.type == KEYDOWN:
inputs.keydown(ev.key)
#elif ev.type == VIDEOEXPOSE:
# video.force_redraw()
elif ev.type in (MOUSEBUTTONDOWN, MOUSEBUTTONUP):
pass
if 'exit' in inputs.commands:
break
video.predraw()
test_frame()
video.next_frame()