-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_square.py
51 lines (37 loc) · 969 Bytes
/
test_square.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
import pygame
from pygame.locals import *
from pyglew import *
pygame.display.init()
surface = pygame.display.set_mode((512,512), OPENGL|DOUBLEBUF)
glewInit()
from pygpu import *
from pygpu.functions import float2
from pygpu.types import *
initPyGPU()
@gpu(size = lambda *args: (512,512))
def square(p=Position):
x,y = p
if (128.0 < x and x < 384.0) and\
(128.0 < y and y < 384.0):
res = float3(1,1,1)
else:
res = float3(0,0,0)
return res
glDisable(GL_DEPTH_TEST)
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho(0, 512, 0, 512, -1, 1)
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
while True:
#check for quit'n events
event = pygame.event.poll()
if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
break
glClear(GL_COLOR_BUFFER_BIT)
# res = columnSumDynamic(image,100)
res = square()
print res
res.show()
pygame.display.flip()