1
#####################################################################
2
# -*- coding: iso-8859-1 -*- #
5
# Copyright (C) 2006 Sami Ky�stil� #
7
# This program is free software; you can redistribute it and/or #
8
# modify it under the terms of the GNU General Public License #
9
# as published by the Free Software Foundation; either version 2 #
10
# of the License, or (at your option) any later version. #
12
# This program is distributed in the hope that it will be useful, #
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15
# GNU General Public License for more details. #
17
# You should have received a copy of the GNU General Public License #
18
# along with this program; if not, write to the Free Software #
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, #
20
# MA 02110-1301, USA. #
21
#####################################################################
24
from GameEngine import GameEngine
25
from Texture import Texture
28
from OpenGL.GL import *
29
from OpenGL.GLU import *
31
class SvgTest(unittest.TestCase):
32
def testRendering(self):
33
self.svg.transform.translate(256, 256)
34
self.svg.transform.rotate(3.141592)
38
def testRenderToTexture(self):
40
fullwidth, fullheight = 512, 512
41
width, height = int(fullwidth / scale), int(fullheight / scale)
43
self.e.svg.setProjection((0, 0, fullwidth, fullheight))
45
glViewport(0, 0, width, height)
46
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
47
self.svg.transform.translate(width * scale / 2, height * scale / 2)
48
self.svg.transform.rotate(3.141592)
51
glViewport(0, 0, fullwidth, fullheight)
52
glMatrixMode(GL_PROJECTION)
54
gluOrtho2D(0.0, 1.0, 0.0, 1.0)
55
glMatrixMode(GL_MODELVIEW)
59
glEnable(GL_TEXTURE_2D)
60
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
62
glClear(GL_COLOR_BUFFER_BIT)
63
glColor3f(1.0, 1.0, 1.0)
64
glBegin(GL_TRIANGLE_STRIP)
65
glTexCoord2f(0.0, 0.0)
67
glTexCoord2f(1.0, 0.0)
69
glTexCoord2f(0.0, 1.0)
71
glTexCoord2f(1.0, 1.0)
80
config = Config.load(Version.appName() + ".ini", setAsDefault = True)
81
self.e = GameEngine(config)
82
self.e.loadImgDrawing(self, "svg", "mfhlogo.png")
87
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
89
if __name__ == "__main__":