1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import unittest
24 from GameEngine import GameEngine
25 from Texture import Texture
26
27 from OpenGL.GL import *
28 from OpenGL.GLU import *
29
36
38 scale = 4
39 fullwidth, fullheight = 512, 512
40 width, height = int(fullwidth / scale), int(fullheight / scale)
41 t = Texture()
42 self.e.svg.setProjection((0, 0, fullwidth, fullheight))
43
44 t.prepareRenderTarget(width, height)
45 t.setAsRenderTarget()
46 glViewport(0, 0, width, height)
47 glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
48 self.svg.transform.translate(width * scale / 2, height * scale / 2)
49 self.svg.transform.rotate(3.141592)
50 self.svg.draw()
51 t.resetDefaultRenderTarget()
52
53 glViewport(0, 0, fullwidth, fullheight)
54 glMatrixMode(GL_PROJECTION)
55 glLoadIdentity()
56 gluOrtho2D(0.0, 1.0, 0.0, 1.0)
57 glMatrixMode(GL_MODELVIEW)
58 glLoadIdentity()
59
60 t.bind()
61 glEnable(GL_TEXTURE_2D)
62 if not t.framebuffer.emulated:
63 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)
64 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
65
66 glClear(GL_COLOR_BUFFER_BIT)
67 glColor3f(1.0, 1.0, 1.0)
68 glBegin(GL_TRIANGLE_STRIP)
69 glTexCoord2f(0.0, 0.0)
70 glVertex2f(0.0, 0.0)
71 glTexCoord2f(1.0, 0.0)
72 glVertex2f(1.0, 0.0)
73 glTexCoord2f(0.0, 1.0)
74 glVertex2f(0.0, 1.0)
75 glTexCoord2f(1.0, 1.0)
76 glVertex2f(1.0, 1.0)
77 glEnd()
78
79 self.e.video.flip()
80 import time
81 time.sleep(2)
82
84 self.e = GameEngine()
85 self.e.loadSvgDrawing(self, "svg", "koopa.svg")
86
87 while not self.svg:
88 self.e.run()
89
90 glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
91
92 if __name__ == "__main__":
93 unittest.main()
94