comparison pytouhou/ui/opengl/texture.pyx @ 515:b3193b43a86c

Add an indirection layer for textures, to cope with drivers assigning them random names.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 06 Dec 2013 19:02:42 +0100
parents 5e3e0b09a531
children dec43940f092
comparison
equal deleted inserted replaced
514:3d4410de78e1 515:b3193b43a86c
92 new_image.set_alpha(new_alpha_file) 92 new_image.set_alpha(new_alpha_file)
93 93
94 return Texture(width, height, -4, new_image.pixels) 94 return Texture(width, height, -4, new_image.pixels)
95 95
96 96
97 cdef GLuint load_texture(thtx): 97 cdef GLuint load_texture(thtx) except? 65535:
98 cdef GLuint texture 98 cdef GLuint texture
99 cdef long fmt = thtx.fmt
99 100
100 if thtx.fmt == 1: 101 if fmt == 1:
101 format_ = GL_BGRA 102 format_ = GL_BGRA
102 type_ = GL_UNSIGNED_BYTE 103 type_ = GL_UNSIGNED_BYTE
103 composants = GL_RGBA 104 composants = GL_RGBA
104 elif thtx.fmt == 3: 105 elif fmt == 3:
105 format_ = GL_RGB 106 format_ = GL_RGB
106 type_ = GL_UNSIGNED_SHORT_5_6_5 107 type_ = GL_UNSIGNED_SHORT_5_6_5
107 composants = GL_RGB 108 composants = GL_RGB
108 elif thtx.fmt == 5: 109 elif fmt == 5:
109 format_ = GL_BGRA 110 format_ = GL_BGRA
110 type_ = GL_UNSIGNED_SHORT_4_4_4_4_REV 111 type_ = GL_UNSIGNED_SHORT_4_4_4_4_REV
111 composants = GL_RGBA 112 composants = GL_RGBA
112 elif thtx.fmt == 7: 113 elif fmt == 7:
113 format_ = GL_LUMINANCE 114 format_ = GL_LUMINANCE
114 type_ = GL_UNSIGNED_BYTE 115 type_ = GL_UNSIGNED_BYTE
115 composants = GL_LUMINANCE 116 composants = GL_LUMINANCE
116 elif thtx.fmt == -4: #XXX: non-standard 117 elif fmt == -4: #XXX: non-standard
117 format_ = GL_RGBA 118 format_ = GL_RGBA
118 type_ = GL_UNSIGNED_BYTE 119 type_ = GL_UNSIGNED_BYTE
119 composants = GL_RGBA 120 composants = GL_RGBA
120 else: 121 else:
121 raise Exception('Unknown texture type') 122 raise Exception('Unknown texture type')