Author: DerekRhodes Date: 2008-03-08 13:17:04 -0500 (Sat, 08 Mar 2008) New Revision: 1101
Modified: trunk/pysoy/src/textures/NormalisationCubeMap.pxi Log: fixed indentatation, tested with build Modified: trunk/pysoy/src/textures/NormalisationCubeMap.pxi =================================================================== --- trunk/pysoy/src/textures/NormalisationCubeMap.pxi 2008-03-08 17:09:23 UTC (rev 1100) +++ trunk/pysoy/src/textures/NormalisationCubeMap.pxi 2008-03-08 18:17:04 UTC (rev 1101) @@ -1,210 +1,210 @@ cimport stdlib cdef class NormalisationCubeMap(Texture): - def __cinit__(self): - self._mutex = py.PyThread_allocate_lock() - self._was_created = 0 + def __cinit__(self): + self._mutex = py.PyThread_allocate_lock() + self._was_created = 0 - def generate(self,x,y): - self._generate(x,y) - + def generate(self,x,y): + self._generate(x,y) + - cdef void _generate(self, int x_size, int y_size): - self._was_created = 1 - self._textureTarget = gl.GL_TEXTURE_CUBE_MAP - self._chans = 3 - gl.glGenTextures(1, &self._textureID) - gl.glBindTexture(self._textureTarget, self._textureID) + cdef void _generate(self, int x_size, int y_size): + self._was_created = 1 + self._textureTarget = gl.GL_TEXTURE_CUBE_MAP + self._chans = 3 + gl.glGenTextures(1, &self._textureID) + gl.glBindTexture(self._textureTarget, self._textureID) - #cdef int size = 32 - cdef float offset - cdef float halfSizeX - cdef unsigned char* data - cdef unsigned char* bytePtr - cdef int i,j - cdef float temp_vector[3] - cdef float length + #cdef int size = 32 + cdef float offset + cdef float halfSizeX + cdef unsigned char* data + cdef unsigned char* bytePtr + cdef int i,j + cdef float temp_vector[3] + cdef float length - data = <unsigned char*>stdlib.malloc(x_size*x_size*3) - halfSizeX = <float>x_size / 2.0 - offset = 0.5 + data = <unsigned char*>stdlib.malloc(x_size*x_size*3) + halfSizeX = <float>x_size / 2.0 + offset = 0.5 - #+X - bytePtr = data - for j from 0 < j <= x_size: - for i from 0 < i <= x_size: - temp_vector[0] = (halfSizeX) - temp_vector[1] = (-(j+offset-halfSizeX)) - temp_vector[2] = (-(i+offset-halfSizeX)) + #+X + bytePtr = data + for j from 0 < j <= x_size: + for i from 0 < i <= x_size: + temp_vector[0] = (halfSizeX) + temp_vector[1] = (-(j+offset-halfSizeX)) + temp_vector[2] = (-(i+offset-halfSizeX)) - length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) + length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) - temp_vector[0] = temp_vector[0] / length - temp_vector[1] = temp_vector[1] / length - temp_vector[2] = temp_vector[2] / length + temp_vector[0] = temp_vector[0] / length + temp_vector[1] = temp_vector[1] / length + temp_vector[2] = temp_vector[2] / length - temp_vector[0] = 0.5 * temp_vector[0] + 0.5 - temp_vector[1] = 0.5 * temp_vector[1] + 0.5 - temp_vector[2] = 0.5 * temp_vector[2] + 0.5 + temp_vector[0] = 0.5 * temp_vector[0] + 0.5 + temp_vector[1] = 0.5 * temp_vector[1] + 0.5 + temp_vector[2] = 0.5 * temp_vector[2] + 0.5 - bytePtr[0] = <unsigned char>(temp_vector[0]*255); - bytePtr[1] = <unsigned char>(temp_vector[1]*255); - bytePtr[2] = <unsigned char>(temp_vector[2]*255); - bytePtr = bytePtr + 3; + bytePtr[0] = <unsigned char>(temp_vector[0]*255); + bytePtr[1] = <unsigned char>(temp_vector[1]*255); + bytePtr[2] = <unsigned char>(temp_vector[2]*255); + bytePtr = bytePtr + 3; - gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.GL_RGBA8, x_size, x_size, - 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, gl.GL_RGBA8, x_size, x_size, + 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) - #-X - bytePtr = data - for j from 0 < j <= x_size: - for i from 0 < i <= x_size: - temp_vector[0] = (-halfSizeX) - temp_vector[1] = (-(j+offset-halfSizeX)) - temp_vector[2] = ((i+offset-halfSizeX)) + #-X + bytePtr = data + for j from 0 < j <= x_size: + for i from 0 < i <= x_size: + temp_vector[0] = (-halfSizeX) + temp_vector[1] = (-(j+offset-halfSizeX)) + temp_vector[2] = ((i+offset-halfSizeX)) - length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) + length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) - temp_vector[0] = temp_vector[0] / length - temp_vector[1] = temp_vector[1] / length - temp_vector[2] = temp_vector[2] / length + temp_vector[0] = temp_vector[0] / length + temp_vector[1] = temp_vector[1] / length + temp_vector[2] = temp_vector[2] / length - temp_vector[0] = 0.5 * temp_vector[0] + 0.5 - temp_vector[1] = 0.5 * temp_vector[1] + 0.5 - temp_vector[2] = 0.5 * temp_vector[2] + 0.5 + temp_vector[0] = 0.5 * temp_vector[0] + 0.5 + temp_vector[1] = 0.5 * temp_vector[1] + 0.5 + temp_vector[2] = 0.5 * temp_vector[2] + 0.5 - bytePtr[0] = <unsigned char>(temp_vector[0]*255); - bytePtr[1] = <unsigned char>(temp_vector[1]*255); - bytePtr[2] = <unsigned char>(temp_vector[2]*255); - bytePtr = bytePtr + 3; - - gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.GL_RGBA8, x_size, x_size, - 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) + bytePtr[0] = <unsigned char>(temp_vector[0]*255); + bytePtr[1] = <unsigned char>(temp_vector[1]*255); + bytePtr[2] = <unsigned char>(temp_vector[2]*255); + bytePtr = bytePtr + 3; + + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, gl.GL_RGBA8, x_size, x_size, + 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) - #+Y - bytePtr = data - for j from 0 < j <= x_size: - for i from 0 < i <= x_size: - temp_vector[0] = i+offset-halfSizeX - temp_vector[1] = halfSizeX - temp_vector[2] = j+offset - halfSizeX + #+Y + bytePtr = data + for j from 0 < j <= x_size: + for i from 0 < i <= x_size: + temp_vector[0] = i+offset-halfSizeX + temp_vector[1] = halfSizeX + temp_vector[2] = j+offset - halfSizeX - length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) + length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) - temp_vector[0] = temp_vector[0] / length - temp_vector[1] = temp_vector[1] / length - temp_vector[2] = temp_vector[2] / length + temp_vector[0] = temp_vector[0] / length + temp_vector[1] = temp_vector[1] / length + temp_vector[2] = temp_vector[2] / length - temp_vector[0] = 0.5 * temp_vector[0] + 0.5 - temp_vector[1] = 0.5 * temp_vector[1] + 0.5 - temp_vector[2] = 0.5 * temp_vector[2] + 0.5 + temp_vector[0] = 0.5 * temp_vector[0] + 0.5 + temp_vector[1] = 0.5 * temp_vector[1] + 0.5 + temp_vector[2] = 0.5 * temp_vector[2] + 0.5 - bytePtr[0] = <unsigned char>(temp_vector[0]*255); - bytePtr[1] = <unsigned char>(temp_vector[1]*255); - bytePtr[2] = <unsigned char>(temp_vector[2]*255); - bytePtr = bytePtr + 3; - - gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.GL_RGBA8, x_size, x_size, - 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) + bytePtr[0] = <unsigned char>(temp_vector[0]*255); + bytePtr[1] = <unsigned char>(temp_vector[1]*255); + bytePtr[2] = <unsigned char>(temp_vector[2]*255); + bytePtr = bytePtr + 3; + + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, gl.GL_RGBA8, x_size, x_size, + 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) - #-Y - bytePtr = data - for j from 0 < j <= x_size: - for i from 0 < i <= x_size: - temp_vector[0] = (i+offset-halfSizeX) - temp_vector[1] =-(halfSizeX) - temp_vector[2] =-(j+offset - halfSizeX) + #-Y + bytePtr = data + for j from 0 < j <= x_size: + for i from 0 < i <= x_size: + temp_vector[0] = (i+offset-halfSizeX) + temp_vector[1] =-(halfSizeX) + temp_vector[2] =-(j+offset - halfSizeX) - length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) + length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) - temp_vector[0] = temp_vector[0] / length - temp_vector[1] = temp_vector[1] / length - temp_vector[2] = temp_vector[2] / length + temp_vector[0] = temp_vector[0] / length + temp_vector[1] = temp_vector[1] / length + temp_vector[2] = temp_vector[2] / length - temp_vector[0] = 0.5 * temp_vector[0] + 0.5 - temp_vector[1] = 0.5 * temp_vector[1] + 0.5 - temp_vector[2] = 0.5 * temp_vector[2] + 0.5 + temp_vector[0] = 0.5 * temp_vector[0] + 0.5 + temp_vector[1] = 0.5 * temp_vector[1] + 0.5 + temp_vector[2] = 0.5 * temp_vector[2] + 0.5 - bytePtr[0] = <unsigned char>(temp_vector[0]*255); - bytePtr[1] = <unsigned char>(temp_vector[1]*255); - bytePtr[2] = <unsigned char>(temp_vector[2]*255); - bytePtr = bytePtr + 3; - - gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.GL_RGBA8, x_size, x_size, - 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) + bytePtr[0] = <unsigned char>(temp_vector[0]*255); + bytePtr[1] = <unsigned char>(temp_vector[1]*255); + bytePtr[2] = <unsigned char>(temp_vector[2]*255); + bytePtr = bytePtr + 3; + + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, gl.GL_RGBA8, x_size, x_size, + 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) - #+Z - bytePtr = data - for j from 0 < j <= x_size: - for i from 0 < i <= x_size: - temp_vector[0] = (i+offset-halfSizeX) - temp_vector[1] = (j+offset-halfSizeX) - temp_vector[2] = (halfSizeX) + #+Z + bytePtr = data + for j from 0 < j <= x_size: + for i from 0 < i <= x_size: + temp_vector[0] = (i+offset-halfSizeX) + temp_vector[1] = (j+offset-halfSizeX) + temp_vector[2] = (halfSizeX) - length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) + length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) - temp_vector[0] = temp_vector[0] / length - temp_vector[1] = temp_vector[1] / length - temp_vector[2] = temp_vector[2] / length + temp_vector[0] = temp_vector[0] / length + temp_vector[1] = temp_vector[1] / length + temp_vector[2] = temp_vector[2] / length - temp_vector[0] = 0.5 * temp_vector[0] + 0.5 - temp_vector[1] = 0.5 * temp_vector[1] + 0.5 - temp_vector[2] = 0.5 * temp_vector[2] + 0.5 + temp_vector[0] = 0.5 * temp_vector[0] + 0.5 + temp_vector[1] = 0.5 * temp_vector[1] + 0.5 + temp_vector[2] = 0.5 * temp_vector[2] + 0.5 - bytePtr[0] = <unsigned char>(temp_vector[0]*255); - bytePtr[1] = <unsigned char>(temp_vector[1]*255); - bytePtr[2] = <unsigned char>(temp_vector[2]*255); - bytePtr = bytePtr + 3; - - gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.GL_RGBA8, x_size, x_size, - 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) + bytePtr[0] = <unsigned char>(temp_vector[0]*255); + bytePtr[1] = <unsigned char>(temp_vector[1]*255); + bytePtr[2] = <unsigned char>(temp_vector[2]*255); + bytePtr = bytePtr + 3; + + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, gl.GL_RGBA8, x_size, x_size, + 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) - #-Z - bytePtr = data - for j from 0 < j <= x_size: - for i from 0 < i <= x_size: - temp_vector[0] = (i+offset-halfSizeX) - temp_vector[1] =-(j+offset-halfSizeX) - temp_vector[2] =-(halfSizeX) + #-Z + bytePtr = data + for j from 0 < j <= x_size: + for i from 0 < i <= x_size: + temp_vector[0] = (i+offset-halfSizeX) + temp_vector[1] =-(j+offset-halfSizeX) + temp_vector[2] =-(halfSizeX) - length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) + length = stdlib.sqrtf(temp_vector[0]*temp_vector[0] + temp_vector[1] * temp_vector[1] + temp_vector[2]*temp_vector[2]) - temp_vector[0] = temp_vector[0] / length - temp_vector[1] = temp_vector[1] / length - temp_vector[2] = temp_vector[2] / length + temp_vector[0] = temp_vector[0] / length + temp_vector[1] = temp_vector[1] / length + temp_vector[2] = temp_vector[2] / length - temp_vector[0] = 0.5 * temp_vector[0] + 0.5 - temp_vector[1] = 0.5 * temp_vector[1] + 0.5 - temp_vector[2] = 0.5 * temp_vector[2] + 0.5 + temp_vector[0] = 0.5 * temp_vector[0] + 0.5 + temp_vector[1] = 0.5 * temp_vector[1] + 0.5 + temp_vector[2] = 0.5 * temp_vector[2] + 0.5 - bytePtr[0] = <unsigned char>(temp_vector[0]*255); - bytePtr[1] = <unsigned char>(temp_vector[1]*255); - bytePtr[2] = <unsigned char>(temp_vector[2]*255); - bytePtr = bytePtr + 3; - - gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.GL_RGBA8, x_size, x_size, - 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) + bytePtr[0] = <unsigned char>(temp_vector[0]*255); + bytePtr[1] = <unsigned char>(temp_vector[1]*255); + bytePtr[2] = <unsigned char>(temp_vector[2]*255); + bytePtr = bytePtr + 3; + + gl.glTexImage2D(gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, gl.GL_RGBA8, x_size, x_size, + 0, gl.GL_RGB, gl.GL_UNSIGNED_BYTE, data) - stdlib.free(data) + stdlib.free(data) - gl.glTexParameteri(self._textureTarget, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR); - gl.glTexParameteri(self._textureTarget, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR); - gl.glTexParameteri(self._textureTarget, gl.GL_TEXTURE_WRAP_S , gl.GL_CLAMP_TO_EDGE); - gl.glTexParameteri(self._textureTarget, gl.GL_TEXTURE_WRAP_T , gl.GL_CLAMP_TO_EDGE); - gl.glTexParameteri(self._textureTarget, gl.GL_TEXTURE_WRAP_R , gl.GL_CLAMP_TO_EDGE); + gl.glTexParameteri(self._textureTarget, gl.GL_TEXTURE_MAG_FILTER, gl.GL_LINEAR); + gl.glTexParameteri(self._textureTarget, gl.GL_TEXTURE_MIN_FILTER, gl.GL_LINEAR); + gl.glTexParameteri(self._textureTarget, gl.GL_TEXTURE_WRAP_S , gl.GL_CLAMP_TO_EDGE); + gl.glTexParameteri(self._textureTarget, gl.GL_TEXTURE_WRAP_T , gl.GL_CLAMP_TO_EDGE); + gl.glTexParameteri(self._textureTarget, gl.GL_TEXTURE_WRAP_R , gl.GL_CLAMP_TO_EDGE); - cdef void _coreBind(self): - py.PyThread_acquire_lock(self._mutex,1) + cdef void _coreBind(self): + py.PyThread_acquire_lock(self._mutex,1) - gl.glEnable(self._textureTarget) - gl.glBindTexture(self._textureTarget, self._textureID) + gl.glEnable(self._textureTarget) + gl.glBindTexture(self._textureTarget, self._textureID) - cdef void _coreUnBind(self): - gl.glDisable(self._textureTarget) - gl.glBindTexture(self._textureTarget, 0) + cdef void _coreUnBind(self): + gl.glDisable(self._textureTarget) + gl.glBindTexture(self._textureTarget, 0) - py.PyThread_release_lock(self._mutex) + py.PyThread_release_lock(self._mutex) _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn