comparison pytouhou/ui/opengl/texture.pyx @ 559:1be60813f7cb

Get OpenGL ES 2.0 to work thanks to libepoxy. PCB textures will need swizzle in the shaders since BGRA isn’t natively supported on GLES.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 30 May 2014 16:40:36 +0200
parents 43ecf0f98f4d
children b8df946d394d
comparison
equal deleted inserted replaced
558:94725968dabb 559:1be60813f7cb
13 ## 13 ##
14 14
15 from pytouhou.lib.opengl cimport \ 15 from pytouhou.lib.opengl cimport \
16 (glTexParameteri, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER, 16 (glTexParameteri, GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER,
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, GL_UNSIGNED_SHORT_4_4_4_4,
19 glGenTextures, glBindTexture, glTexImage2D, GL_TEXTURE_2D, GLuint) 19 glGenTextures, glBindTexture, glTexImage2D, GL_TEXTURE_2D, GLuint)
20 20
21 from pytouhou.lib.sdl cimport load_png, create_rgb_surface 21 from pytouhou.lib.sdl cimport load_png, create_rgb_surface
22 from pytouhou.lib.sdl import SDLError 22 from pytouhou.lib.sdl import SDLError
23 from pytouhou.formats.thtx import Texture #TODO: perhaps define that elsewhere? 23 from pytouhou.formats.thtx import Texture #TODO: perhaps define that elsewhere?
107 cdef GLuint load_texture(thtx) except? 65535: 107 cdef GLuint load_texture(thtx) except? 65535:
108 cdef GLuint texture 108 cdef GLuint texture
109 cdef long fmt = thtx.fmt 109 cdef long fmt = thtx.fmt
110 110
111 if fmt == 1: 111 if fmt == 1:
112 format_ = GL_BGRA 112 #format_ = GL_BGRA
113 format_ = GL_RGBA #XXX: should be GL_BGRA
113 type_ = GL_UNSIGNED_BYTE 114 type_ = GL_UNSIGNED_BYTE
114 composants = GL_RGBA 115 composants = GL_RGBA
115 elif fmt == 3: 116 elif fmt == 3:
116 format_ = GL_RGB 117 format_ = GL_RGB
117 type_ = GL_UNSIGNED_SHORT_5_6_5 118 type_ = GL_UNSIGNED_SHORT_5_6_5
118 composants = GL_RGB 119 composants = GL_RGB
119 elif fmt == 5: 120 elif fmt == 5:
120 format_ = GL_BGRA 121 #format_ = GL_BGRA
121 type_ = GL_UNSIGNED_SHORT_4_4_4_4_REV 122 format_ = GL_RGBA #XXX: should be GL_BGRA
123 #type_ = GL_UNSIGNED_SHORT_4_4_4_4_REV
124 type_ = GL_UNSIGNED_SHORT_4_4_4_4 #XXX: should be GL_UNSIGNED_SHORT_4_4_4_4_REV
122 composants = GL_RGBA 125 composants = GL_RGBA
123 elif fmt == 7: 126 elif fmt == 7:
124 format_ = GL_LUMINANCE 127 format_ = GL_LUMINANCE
125 type_ = GL_UNSIGNED_BYTE 128 type_ = GL_UNSIGNED_BYTE
126 composants = GL_LUMINANCE 129 composants = GL_LUMINANCE