Example #1
0
def glGetTexImage( target, level,format,type, outputType=str ):
    """Get a texture-level as an image

    target -- enum constant for the texture engine to be read
    level -- the mip-map level to read
    format -- image format to read out the data
    type -- data-type into which to read the data

    outputType -- default (str) provides string output of the
        results iff OpenGL.UNSIGNED_BYTE_IMAGES_AS_STRING is True
        and type == GL_UNSIGNED_BYTE.  Any other value will cause
        output in the default array output format.

    returns the pixel data array in the format defined by the
    format, type and outputType
    """
    from OpenGL.GL import glget
    dims = [glget.glGetTexLevelParameteriv( target, level, GL_1_1.GL_TEXTURE_WIDTH )]
    if target != GL_1_1.GL_TEXTURE_1D:
        dims.append( glget.glGetTexLevelParameteriv( target, level, GL_1_1.GL_TEXTURE_HEIGHT ) )
        if target != GL_1_1.GL_TEXTURE_2D:
            dims.append( glget.glGetTexLevelParameteriv( target, level, GL_1_2.GL_TEXTURE_DEPTH ) )
    array = images.SetupPixelRead( format, tuple(dims), type )
    arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[ images.TYPE_TO_ARRAYTYPE.get(type,type) ]
    GL_1_1.glGetTexImage(
        target, level, format, type, ctypes.c_void_p( arrayType.dataPointer(array))
    )
    if outputType is str:
        return images.returnFormat( array, type )
    else:
        return array
Example #2
0
def glGetTexImage(target, level, format, type, array=None, outputType=bytes):
    """Get a texture-level as an image

    target -- enum constant for the texture engine to be read
    level -- the mip-map level to read
    format -- image format to read out the data
    type -- data-type into which to read the data
    array -- optional array/offset into which to store the value

    outputType -- default (bytes) provides string output of the
        results iff OpenGL.UNSIGNED_BYTE_IMAGES_AS_STRING is True
        and type == GL_UNSIGNED_BYTE.  Any other value will cause
        output in the default array output format.

    returns the pixel data array in the format defined by the
    format, type and outputType
    """
    arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[images.TYPE_TO_ARRAYTYPE.get(
        type, type)]
    if array is None:
        dims = _get_texture_level_dims(target, level)
        array = imageData = images.SetupPixelRead(format, tuple(dims), type)
        owned = True
    else:
        if isinstance(array, integer_types):
            imageData = ctypes.c_void_p(array)
        else:
            array = arrayType.asArray(array)
            imageData = arrayType.voidDataPointer(array)
        owned = False
    GL_1_1.glGetTexImage(target, level, format, type, imageData)
    if outputType is bytes:
        return images.returnFormat(array, type)
    else:
        return array
Example #3
0
    def glGetTexImage(target,
                      level,
                      format,
                      type,
                      array=None,
                      outputType=bytes):
        """bug fixed overwirte version"""
        arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[
            images.TYPE_TO_ARRAYTYPE.get(type, type)]
        if array is None:
            dims = OpenGLContext._get_texture_level_dims(target, level)
            imageData = images.SetupPixelRead(format, tuple(dims), type)
            array = imageData
        else:
            if isinstance(array, integer_types):
                imageData = ctypes.c_void_p(array)
            else:
                array = arrayType.asArray(array)
                imageData = arrayType.voidDataPointer(array)

        GL_1_1.glGetTexImage(target, level, format, type, imageData)

        if outputType is bytes:
            return images.returnFormat(array, type)
        else:
            return array
Example #4
0
def glGetTexImage(target, level, format, type, array=None, outputType=bytes):
    """Get a texture-level as an image

    target -- enum constant for the texture engine to be read
    level -- the mip-map level to read
    format -- image format to read out the data
    type -- data-type into which to read the data
    array -- optional array/offset into which to store the value

    outputType -- default (bytes) provides string output of the
        results iff OpenGL.UNSIGNED_BYTE_IMAGES_AS_STRING is True
        and type == GL_UNSIGNED_BYTE.  Any other value will cause
        output in the default array output format.

    returns the pixel data array in the format defined by the
    format, type and outputType
    """
    arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[images.TYPE_TO_ARRAYTYPE.get(type, type)]
    if array is None:
        dims = _get_texture_level_dims(target, level)
        array = imageData = images.SetupPixelRead(format, tuple(dims), type)
        owned = True
    else:
        if isinstance(array, integer_types):
            imageData = ctypes.c_void_p(array)
        else:
            array = arrayType.asArray(array)
            imageData = arrayType.voidDataPointer(array)
        owned = False
    GL_1_1.glGetTexImage(target, level, format, type, imageData)
    if outputType is bytes:
        return images.returnFormat(array, type)
    else:
        return array
Example #5
0
 def glGetTexImage( target, level,format,type=type ):
     """Get a texture-level as an image"""
     from OpenGL.GL import glget
     dims = [glget.glGetTexLevelParameteriv( target, level, GL_1_1.GL_TEXTURE_WIDTH )]
     if target != GL_1_1.GL_TEXTURE_1D:
         dims.append( glget.glGetTexLevelParameteriv( target, level, GL_1_1.GL_TEXTURE_HEIGHT ) )
         if target != GL_1_1.GL_TEXTURE_2D:
             dims.append( glget.glGetTexLevelParameteriv( target, level, GL_1_2.GL_TEXTURE_DEPTH ) )
     array = images.SetupPixelRead( format, tuple(dims), type )
     arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[ images.TYPE_TO_ARRAYTYPE.get(type,type) ]
     GL_1_1.glGetTexImage(
         target, level, format, type, ctypes.c_void_p( arrayType.dataPointer(array))
     )
     return array
Example #6
0
 def glGetTexImage(target, level, format, type=type):
     """Get a texture-level as an image"""
     from OpenGL.GL import glget
     dims = [
         glget.glGetTexLevelParameteriv(target, level,
                                        GL_1_1.GL_TEXTURE_WIDTH)
     ]
     if target != GL_1_1.GL_TEXTURE_1D:
         dims.append(
             glget.glGetTexLevelParameteriv(target, level,
                                            GL_1_1.GL_TEXTURE_HEIGHT))
         if target != GL_1_1.GL_TEXTURE_2D:
             dims.append(
                 glget.glGetTexLevelParameteriv(target, level,
                                                GL_1_2.GL_TEXTURE_DEPTH))
     array = images.SetupPixelRead(format, tuple(dims), type)
     arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[
         images.TYPE_TO_ARRAYTYPE.get(type, type)]
     GL_1_1.glGetTexImage(target, level, format, type,
                          ctypes.c_void_p(arrayType.dataPointer(array)))
     return array
Example #7
0
def glGetTexImage(target, level, format, type, outputType=str):
    """Get a texture-level as an image

    target -- enum constant for the texture engine to be read
    level -- the mip-map level to read
    format -- image format to read out the data
    type -- data-type into which to read the data

    outputType -- default (str) provides string output of the
        results iff OpenGL.UNSIGNED_BYTE_IMAGES_AS_STRING is True
        and type == GL_UNSIGNED_BYTE.  Any other value will cause
        output in the default array output format.

    returns the pixel data array in the format defined by the
    format, type and outputType
    """
    from OpenGL.GL import glget
    dims = [
        glget.glGetTexLevelParameteriv(target, level, GL_1_1.GL_TEXTURE_WIDTH)
    ]
    if target != GL_1_1.GL_TEXTURE_1D:
        dims.append(
            glget.glGetTexLevelParameteriv(target, level,
                                           GL_1_1.GL_TEXTURE_HEIGHT))
        if target != GL_1_1.GL_TEXTURE_2D:
            dims.append(
                glget.glGetTexLevelParameteriv(target, level,
                                               GL_1_2.GL_TEXTURE_DEPTH))
    array = images.SetupPixelRead(format, tuple(dims), type)
    arrayType = arrays.GL_CONSTANT_TO_ARRAY_TYPE[images.TYPE_TO_ARRAYTYPE.get(
        type, type)]
    GL_1_1.glGetTexImage(target, level, format, type,
                         ctypes.c_void_p(arrayType.dataPointer(array)))
    if outputType is str:
        return images.returnFormat(array, type)
    else:
        return array