Пример #1
0
    def __init__(self, type, size, colorDepth=32):
        if type == Float:
            self.type = RImage
        elif type == Float2:
            self.type = RGImage
        elif type == Float3:
            self.type = RGBImage
        elif type == Float4:
            self.type = RGBAImage
        else:
            raise RuntimeError("bork!")

        internalFormat = ATIFramebuffer.typeToOpenGL(type, colorDepth)
        Texture.__init__(self, internalFormat, size,
                         ATIFramebuffer.TextureTarget)
        self.bind()

        w, h = size
        self.frameBuffer = glGenFramebuffersEXT(1)
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, self.frameBuffer)
        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
                                  self.target, self.texNo, 0)

        ## depth buffer
        self.depthBuffer = glGenRenderbuffersEXT(1)
        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, self.depthBuffer)
        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, w,
                                 h)
        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
                                     GL_DEPTH_ATTACHMENT_EXT,
                                     GL_RENDERBUFFER_EXT, self.depthBuffer)

        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)
Пример #2
0
    def __init__(self, type, size, colorDepth = 32):
        if type == Float:
            self.type = RImage
        elif type == Float2:
            self.type = RGImage
        elif type == Float3:
            self.type = RGBImage
        elif type == Float4:
            self.type = RGBAImage
        else:
            raise RuntimeError("bork!")
            
     
        internalFormat = ATIFramebuffer.typeToOpenGL(type, colorDepth)
        Texture.__init__(self, internalFormat, size, ATIFramebuffer.TextureTarget)
        self.bind()
            
        w,h = size
        self.frameBuffer = glGenFramebuffersEXT(1);
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, self.frameBuffer);
        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
                                  GL_COLOR_ATTACHMENT0_EXT,
                                  self.target, self.texNo, 0);

        ## depth buffer
        self.depthBuffer = glGenRenderbuffersEXT(1);
        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, self.depthBuffer);
        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
                                 GL_DEPTH_COMPONENT24, w, h);
        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
                                     GL_DEPTH_ATTACHMENT_EXT,
                                     GL_RENDERBUFFER_EXT, self.depthBuffer);
  
        glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
Пример #3
0
    def typeToOpenGL(type, colorDepth):
        if colorDepth == 8:
            return Texture.typeToOpenGL(type)

        elif colorDepth == 32:
            if type == Float:
                return GL_ALPHA_FLOAT32_ATI
            elif type == Float3:
                return GL_RGB_FLOAT32_ATI
            elif type == Float4:
                return GL_RGBA_FLOAT32_ATI
            else:
                assert False

        else:
            assert False
Пример #4
0
    def typeToOpenGL(type, colorDepth):
        if colorDepth == 8:
            return Texture.typeToOpenGL(type)

        elif colorDepth == 32:
            if type == Float:
                return GL_ALPHA_FLOAT32_ATI
            elif type == Float3:
                return GL_RGB_FLOAT32_ATI
            elif type == Float4:
                return GL_RGBA_FLOAT32_ATI
            else:
                assert False

        else:
            assert False
Пример #5
0
    def typeToOpenGL(type, colorDepth):
        if colorDepth == 8:
            return Texture.typeToOpenGL(type)

        elif colorDepth == 32:
            if type == Float:
                return GL_FLOAT_R32_NV
            elif type == Float2:
                return GL_FLOAT_RG32_NV
            elif type == Float3:
                return GL_FLOAT_RGB32_NV
            elif type == Float4:
                return GL_FLOAT_RGBA32_NV
            else:
                assert False

        else:
            assert False
Пример #6
0
    def typeToOpenGL(type, colorDepth):
        if colorDepth == 8:
            return Texture.typeToOpenGL(type)

        elif colorDepth == 32:
            if type == Float:
                return GL_FLOAT_R32_NV
            elif type == Float2:
                return GL_FLOAT_RG32_NV
            elif type == Float3:
                return GL_FLOAT_RGB32_NV
            elif type == Float4:
                return GL_FLOAT_RGBA32_NV
            else:
                assert False

        else:
            assert False
Пример #7
0
 def __del__(self):
     if hasattr(self, 'depthBuffer'):
         glDeleteRenderbuffersEXT(1, [self.depthBuffer])
     if hasattr(self, 'frameBuffer'):
         glDeleteFramebuffersEXT(1, [self.frameBuffer])
     Texture.__del__(self)
Пример #8
0
 def __del__(self):
     if hasattr(self, 'depthBuffer'):
         glDeleteRenderbuffersEXT(1, [self.depthBuffer])
     if hasattr(self, 'frameBuffer'):
         glDeleteFramebuffersEXT(1, [self.frameBuffer])
     Texture.__del__(self)