comparison pytouhou/lib/sdl.pyx @ 604:aca9551ee8b4

Fix compiling issues with Cython 0.20 ; don't pretend to concat shader sources
author Thibaut Girka <thib@sitedethib.com>
date Tue, 11 Nov 2014 15:46:31 +0100
parents 19d930f9e3f0
children 3c2f96f1d715
comparison
equal deleted inserted replaced
603:e9300aae4b24 604:aca9551ee8b4
93 SDL_Quit() 93 SDL_Quit()
94 94
95 95
96 cdef class Window: 96 cdef class Window:
97 def __init__(self, str title, int x, int y, int w, int h, Uint32 flags): 97 def __init__(self, str title, int x, int y, int w, int h, Uint32 flags):
98 self.window = SDL_CreateWindow(title.encode(), x, y, w, h, flags) 98 title_bytes = title.encode()
99 self.window = SDL_CreateWindow(title_bytes, x, y, w, h, flags)
99 if self.window == NULL: 100 if self.window == NULL:
100 raise SDLError() 101 raise SDLError()
101 102
102 def __dealloc__(self): 103 def __dealloc__(self):
103 if self.context != NULL: 104 if self.context != NULL:
239 Mix_VolumeChunk(self.chunk, int(volume * 128)) 240 Mix_VolumeChunk(self.chunk, int(volume * 128))
240 241
241 242
242 cdef class Font: 243 cdef class Font:
243 def __init__(self, str filename, int ptsize): 244 def __init__(self, str filename, int ptsize):
244 self.font = TTF_OpenFont(filename.encode(), ptsize) 245 path = filename.encode()
246 self.font = TTF_OpenFont(path, ptsize)
245 if self.font == NULL: 247 if self.font == NULL:
246 raise SDLError() 248 raise SDLError()
247 249
248 def __dealloc__(self): 250 def __dealloc__(self):
249 if self.font != NULL: 251 if self.font != NULL:
339 return Mix_VolumeMusic(int(volume * 128)) 341 return Mix_VolumeMusic(int(volume * 128))
340 342
341 343
342 cdef Music load_music(str filename): 344 cdef Music load_music(str filename):
343 music = Music() 345 music = Music()
344 music.music = Mix_LoadMUS(filename.encode()) 346 path = filename.encode()
347 music.music = Mix_LoadMUS(path)
345 if music.music == NULL: 348 if music.music == NULL:
346 raise SDLError() 349 raise SDLError()
347 return music 350 return music
348 351
349 352