comparison pytouhou/ui/texture.pyx @ 455:6864a38b2413

Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 02 Sep 2013 22:16:38 +0200
parents d56536ef28e8
children cae1ae9de430
comparison
equal deleted inserted replaced
454:a502887557ac 455:6864a38b2413
17 GL_LINEAR, GL_BGRA, GL_RGBA, GL_RGB, GL_LUMINANCE, GL_UNSIGNED_BYTE, 17 GL_LINEAR, GL_BGRA, GL_RGBA, GL_RGB, GL_LUMINANCE, GL_UNSIGNED_BYTE,
18 GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_4_4_4_4_REV, 18 GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_SHORT_4_4_4_4_REV,
19 glGenTextures, glBindTexture, glTexImage2D, GL_TEXTURE_2D, GLuint, 19 glGenTextures, glBindTexture, glTexImage2D, GL_TEXTURE_2D, GLuint,
20 glDeleteTextures) 20 glDeleteTextures)
21 21
22 from pytouhou.lib.sdl import load_png, create_rgb_surface 22 from pytouhou.lib.sdl cimport load_png, create_rgb_surface
23 from pytouhou.formats.thtx import Texture #TODO: perhaps define that elsewhere? 23 from pytouhou.formats.thtx import Texture #TODO: perhaps define that elsewhere?
24 24
25 import os 25 import os
26 26
27 27
50 entry.texture.renderer = self.renderer 50 entry.texture.renderer = self.renderer
51 51
52 52
53 cdef decode_png(loader, first_name, secondary_name): 53 cdef decode_png(loader, first_name, secondary_name):
54 image_file = load_png(loader.get_file(os.path.basename(first_name))) 54 image_file = load_png(loader.get_file(os.path.basename(first_name)))
55 width, height = image_file.width, image_file.height 55 width, height = image_file.surface.w, image_file.surface.h
56 56
57 # Support only 32 bits RGBA. Paletted surfaces are awful to work with. 57 # Support only 32 bits RGBA. Paletted surfaces are awful to work with.
58 #TODO: verify it doesn’t blow up on big-endian systems. 58 #TODO: verify it doesn’t blow up on big-endian systems.
59 new_image = create_rgb_surface(width, height, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000) 59 new_image = create_rgb_surface(width, height, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000)
60 new_image.blit(image_file) 60 new_image.blit(image_file)
61 61
62 if secondary_name: 62 if secondary_name:
63 alpha_file = load_png(loader.get_file(os.path.basename(secondary_name))) 63 alpha_file = load_png(loader.get_file(os.path.basename(secondary_name)))
64 assert (width == alpha_file.width and height == alpha_file.height) 64 assert (width == alpha_file.surface.w and height == alpha_file.surface.h)
65 65
66 new_alpha_file = create_rgb_surface(width, height, 24) 66 new_alpha_file = create_rgb_surface(width, height, 24)
67 new_alpha_file.blit(alpha_file) 67 new_alpha_file.blit(alpha_file)
68 68
69 new_image.set_alpha(new_alpha_file) 69 new_image.set_alpha(new_alpha_file)