Ejemplo n.º 1
0
    def destroy(self):
        """Must be called when this ``RenderTexture`` is no longer needed.
        Destroys the frame buffer and render buffer, and calls
        :meth:`.Texture2D.destroy`.
        """

        texture.Texture2D.destroy(self)

        log.debug('Deleting FBO{} [{}]'.format(self.__frameBuffer,
                                               self.__rttype))

        glfbo.glDeleteFramebuffersEXT(gltypes.GLuint(self.__frameBuffer))

        if self.__renderBuffer is not None:
            rb = gltypes.GLuint(self.__renderBuffer)
            glfbo.glDeleteRenderbuffersEXT(1, rb)

        if self.__depthTexture is not None:
            self.__depthTexture.destroy()

        self.__frameBuffer = None
        self.__renderBuffer = None
        self.__depthTexture = None
        self.__oldFrameBuffer = None
        self.__oldRenderBuffer = None
Ejemplo n.º 2
0
    def destroy(self):
        """Deletes all GL resources managed by this ``ARBPShader``. """

        if self.vertexProgram is not None:
            arbvp.glDeleteProgramsARB(1, gltypes.GLuint(self.vertexProgram))
        if self.fragmentProgram is not None:
            arbfp.glDeleteProgramsARB(1, gltypes.GLuint(self.fragmentProgram))

        self.vertexProgram = None
        self.fragmentProgram = None
Ejemplo n.º 3
0
    def destroy(self):
        """Deletes all GL resources managed by this ``GLSLShader``. """
        gl.glDeleteProgram(self.program)

        for buf in self.buffers.values():
            gl.glDeleteBuffers(1, gltypes.GLuint(buf))
        self.program = None
Ejemplo n.º 4
0
def _get_texture_level_dims(target,level):
    """Retrieve texture dims for given level and target"""
    dims = []
    dim = _types.GLuint()
    GL_1_1.glGetTexLevelParameteriv( target, level, GL_1_1.GL_TEXTURE_WIDTH, dim )
    dims = [dim.value]
    if target != GL_1_1.GL_TEXTURE_1D:
        GL_1_1.glGetTexLevelParameteriv( target, level, GL_1_1.GL_TEXTURE_HEIGHT, dim )
        dims.append( dim.value )
        if target != GL_1_1.GL_TEXTURE_2D:
            GL_1_1.glGetTexLevelParameteriv( target, level, GL_1_1.GL_TEXTURE_DEPTH, dim )
            dims.append( dim.value )
    return dims
Ejemplo n.º 5
0
 def _get_texture_level_dims(target, level):
     dim = _types.GLuint()
     GL_1_1.glGetTexLevelParameteriv(target, level, GL_1_1.GL_TEXTURE_WIDTH,
                                     dim)
     dims = [dim.value]
     if target != GL_1_1.GL_TEXTURE_1D:
         GL_1_1.glGetTexLevelParameteriv(target, level,
                                         GL_1_1.GL_TEXTURE_HEIGHT, dim)
         dims.append(dim.value)
         if target != GL_1_1.GL_TEXTURE_2D:
             # bug fixed : GL_1_1.GL_TEXTURE_DEPTH -> GL_1_2.GL_TEXTURE_DEPTH
             GL_1_1.glGetTexLevelParameteriv(target, level,
                                             GL_1_2.GL_TEXTURE_DEPTH, dim)
             dims.append(dim.value)
     return dims
Ejemplo n.º 6
0
def glGenTextures(baseFunction, count, textures=None):
    """Generate count new texture names

    Note: for compatibility with PyOpenGL 2.x and below,
    a count of 1 will return a single integer, rather than
    an array of integers.
    """
    if count <= 0:
        raise ValueError("""Can't generate 0 or fewer textures""")
    elif count == 1 and _configflags.SIZE_1_ARRAY_UNPACK:
        # this traditionally returned a single int/long, so we'll continue to
        # do so, even though it would be easier not to bother.
        textures = _types.GLuint(0)
        baseFunction(count, textures)
        return textures.value
    else:
        textures = arrays.GLuintArray.zeros((count, ))
        baseFunction(count, textures)
        return textures