def glGetConvolutionFilter(baseFunction, target, format, type): """Retrieve 1 or 2D convolution parameter "kernels" as pixel data""" from OpenGL.error import glCheckError glCheckError(None) dims = (glGetConvolutionParameteriv(target, GL_CONVOLUTION_WIDTH)[0], ) if target != GL_CONVOLUTION_1D: dims += (glGetConvolutionParameteriv(target, GL_CONVOLUTION_HEIGHT)[0], ) # is it always 4? Seems to be, but the spec/man-page isn't really clear about it... dims += (4, ) array = images.images.SetupPixelRead(format, dims, type) arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[ images.images.TYPE_TO_ARRAYTYPE.get(type, type)] baseFunction(target, format, type, ctypes.c_void_p(arrayType.dataPointer(array))) return array
def GLSLCheckError(result, baseOperation=None, cArguments=None, *args): result = error.glCheckError(result, baseOperation, cArguments, *args) status = glGetObjectParameterivARB(cArguments[0], key) if not status: raise error.GLError(result=result, baseOperation=baseOperation, cArguments=cArguments, description=glGetInfoLogARB(cArguments[0])) return result
def test_glAreTexturesResident( self ): """Test that PyOpenGL api for glAreTexturesResident is working Note: not currently working on AMD64 Linux for some reason """ import numpy textures = glGenTextures(2) residents = [] for texture in textures: glBindTexture( GL_TEXTURE_2D,int(texture) ) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1, 1, 0, GL_RGB, GL_INT, self.someData) residents.append( glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_RESIDENT ) ) error.glCheckError(None) result = glAreTexturesResident( textures) assert len(result) == 2 for (tex,expected,found) in zip( textures, residents, result ): if expected != found: print 'Warning: texture %s residence expected %s got %s'%( tex, expected, found )
def GLSLCheckError(result, baseOperation=None, cArguments=None, *args): result = error.glCheckError(result, baseOperation, cArguments, *args) status = ctypes.c_int() getter(cArguments[0], key, ctypes.byref(status)) status = status.value if not status: raise error.GLError(result=result, baseOperation=baseOperation, cArguments=cArguments, description=glGetInfoLog(cArguments[0])) return result
def GLSLCheckError(result, baseOperation=None, cArguments=None, *args): result = error.glCheckError(result, baseOperation, cArguments, *args) status = glGetObjectParameterivARB(cArguments[0], key) if not status: raise error.GLError( result=result, baseOperation=baseOperation, cArguments=cArguments, description=glGetInfoLogARB(cArguments[0]), ) return result
def test_glAreTexturesResident( self ): """Test that PyOpenGL api for glAreTexturesResident is working Note: not currently working on AMD64 Linux for some reason """ import numpy textures = glGenTextures(2) residents = [] data = numpy.array( self.someData,'i' ) for texture in textures: glBindTexture( GL_TEXTURE_2D,int(texture) ) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, 1, 1, 0, GL_RGB, GL_INT, data) residents.append( glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_RESIDENT ) ) error.glCheckError(None) result = glAreTexturesResident( textures) assert len(result) == 2 for (tex,expected,found) in zip( textures, residents, result ): if expected != found: print('Warning: texture %s residence expected %s got %s'%( tex, expected, found ))
def glGetConvolutionFilter( baseFunction, target, format, type ): """Retrieve 1 or 2D convolution parameter "kernels" as pixel data""" from OpenGL.error import glCheckError glCheckError(None) dims = ( glGetConvolutionParameteriv( target, GL_CONVOLUTION_WIDTH )[0], ) if target != GL_CONVOLUTION_1D: dims += ( glGetConvolutionParameteriv( target, GL_CONVOLUTION_HEIGHT )[0], ) # is it always 4? Seems to be, but the spec/man-page isn't really clear about it... dims += (4,) array = images.images.SetupPixelRead( format, dims, type ) arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[ images.images.TYPE_TO_ARRAYTYPE.get(type,type) ] baseFunction( target, format, type, ctypes.c_void_p( arrayType.dataPointer(array)) ) return array
def GLSLCheckError( result, baseOperation=None, cArguments=None, *args ): result = error.glCheckError( result, baseOperation, cArguments, *args ) status = ctypes.c_int() getter( cArguments[0], key, ctypes.byref(status)) status = status.value if not status: raise error.GLError( result = result, baseOperation = baseOperation, cArguments = cArguments, description= glGetInfoLog( cArguments[0] ) ) return result