Author: ArcRiley Date: 2008-05-19 22:26:36 -0400 (Mon, 19 May 2008) New Revision: 1282
Modified: trunk/pysoy/src/textures/Texture.pym Log: '''Quick fix:''' * added support for cubemaps to textures.Texture - enabled with z=6 Modified: trunk/pysoy/src/textures/Texture.pym =================================================================== --- trunk/pysoy/src/textures/Texture.pym 2008-05-20 01:34:10 UTC (rev 1281) +++ trunk/pysoy/src/textures/Texture.pym 2008-05-20 02:26:36 UTC (rev 1282) @@ -137,7 +137,10 @@ else : self._target = gl.GL_TEXTURE_2D else : - self._target = gl.GL_TEXTURE_3D + if _z == 6 : + self._target = gl.GL_TEXTURE_CUBE_MAP + else : + self._target = gl.GL_TEXTURE_3D # # Have we already alloc'ed? if self._width : @@ -178,25 +181,15 @@ # cdef void _enable(self) nogil : + cdef int _size + if self._target == 0 : + return # # Lock to prevent resizing while we render py.PyThread_acquire_lock(self._mutex, 1) # # Enable our texture target - if self._target == gl.GL_TEXTURE_1D : - gl.glEnable(gl.GL_TEXTURE_1D) - elif self._target == gl.GL_TEXTURE_2D : - gl.glEnable(gl.GL_TEXTURE_2D) - elif self._target == gl.GL_TEXTURE_3D : - gl.glEnable(gl.GL_TEXTURE_3D) - else : - return - #if self._chans & 1 : - # gl.glDisable(gl.GL_BLEND) - #else : - # gl.glEnable(gl.GL_BLEND) - # gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA) - # + gl.glEnable(self._target) if self._textureID == 0 : # # If we haven't generated this texture yet @@ -227,6 +220,32 @@ self._width, self._height, 0, self._formats[self._chans], self._types[self._bytes], self._texels) + elif self._target == gl.GL_TEXTURE_CUBE_MAP : + _size = self._bytes * self._chans * self._width * self._height + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, self._chans, + self._width, self._height, 0, + self._formats[self._chans], self._types[self._bytes], + self._texels) + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, self._chans, + self._width, self._height, 0, + self._formats[self._chans], self._types[self._bytes], + self._texels + _size) + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, self._chans, + self._width, self._height, 0, + self._formats[self._chans], self._types[self._bytes], + self._texels + (_size*2)) + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, self._chans, + self._width, self._height, 0, + self._formats[self._chans], self._types[self._bytes], + self._texels + (_size*3)) + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, self._chans, + self._width, self._height, 0, + self._formats[self._chans], self._types[self._bytes], + self._texels + (_size*4)) + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, self._chans, + self._width, self._height, 0, + self._formats[self._chans], self._types[self._bytes], + self._texels + (_size*5)) else : gl.glTexImage3D(gl.GL_TEXTURE_3D, 0, self._chans, self._width, self._height, self._depth, 0, @@ -250,12 +269,9 @@ cdef void _disable(self) nogil : - if self._target == gl.GL_TEXTURE_1D : - gl.glDisable(gl.GL_TEXTURE_1D) - elif self._target == gl.GL_TEXTURE_2D : - gl.glDisable(gl.GL_TEXTURE_2D) - elif self._target == gl.GL_TEXTURE_3D : - gl.glDisable(gl.GL_TEXTURE_3D) + if self._target == 0 : + return + gl.glDisable(self._target) if self._scaleX : # # Reset texture scaling _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn