def gl_init_textures(self):
     assert self.offscreen_fbo is None
     assert self.shaders is None
     self.textures = glGenTextures(N_TEXTURES)
     self.offscreen_fbo = glGenFramebuffers(1)
     self.tmp_fbo = glGenFramebuffers(1)
     log("%s.gl_init_textures() textures: %s, offscreen fbo: %s, tmp fbo: %s", self, self.textures, self.offscreen_fbo, self.tmp_fbo)
 def _gen_fbo(self):
     if hasattr(glGenFramebuffers, "pyConverters") and len(glGenFramebuffers.pyConverters)==1:
         #single argument syntax:
         return glGenFramebuffers(1)
     fbo = c_uint(1)
     glGenFramebuffers(1, fbo)
     return fbo
 def _gen_fbo(self):
     if hasattr(glGenFramebuffers, "pyConverters") and len(glGenFramebuffers.pyConverters)==1:
         #single argument syntax:
         return glGenFramebuffers(1)
     fbo = c_uint(1)
     glGenFramebuffers(1, fbo)
     return fbo
 def gl_init_textures(self):
     assert self.offscreen_fbo is None
     assert self.shaders is None
     self.textures = glGenTextures(5)
     if hasattr(glGenFramebuffers, "pyConverters") and len(glGenFramebuffers.pyConverters)==1:
         #single argument syntax:
         self.offscreen_fbo = glGenFramebuffers(1)
     else:
         self.offscreen_fbo = c_uint(1)
         glGenFramebuffers(1, self.offscreen_fbo)
     log("%s.gl_init_textures() textures: %s, offscreen fbo: %s", self, self.textures, self.offscreen_fbo)
 def gl_init_textures(self):
     assert self.offscreen_fbo is None
     assert self.shaders is None
     self.textures = glGenTextures(5)
     if hasattr(glGenFramebuffers, "pyConverters") and len(glGenFramebuffers.pyConverters)==1:
         #single argument syntax:
         self.offscreen_fbo = glGenFramebuffers(1)
     else:
         self.offscreen_fbo = c_uint(1)
         glGenFramebuffers(1, self.offscreen_fbo)
     log("%s.gl_init_textures() textures: %s, offscreen fbo: %s", self, self.textures, self.offscreen_fbo)
Exemple #6
0
 def gl_init_textures(self):
     assert self.offscreen_fbo is None
     assert self.shaders is None
     self.textures = glGenTextures(5)
     self.offscreen_fbo = glGenFramebuffers(1)
     debug("%s.gl_init_textures() textures: %s, offscreen fbo: %s", self,
           self.textures, self.offscreen_fbo)
Exemple #7
0
    def gl_init(self):
        drawable = self.gl_begin()
        w, h = self.size
        debug("GL Pixmap backing size: %d x %d, drawable=%s", w, h, drawable)
        if not drawable:
            return  None
        if not self.gl_setup:
            # Ask GL to send us all debug messages
            if GL_DEBUG_OUTPUT and gl_debug_callback and glInitDebugKHR() == True:
                glEnable(GL_DEBUG_OUTPUT)
                glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS)
                glDebugMessageCallback(gl_debug_callback, None)
                glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, None, GL_TRUE)
            # Initialize string_marker GL debugging extension if available
            if glInitStringMarkerGREMEDY and glInitStringMarkerGREMEDY() == True:
                log.info("Extension GL_GREMEDY_string_marker available. Will output detailed information about each frame.")
            else:
                # General case - running without debugger, extension not available
                glStringMarkerGREMEDY = None
            # Initialize frame_terminator GL debugging extension if available
            if glInitFrameTerminatorGREMEDY and glInitFrameTerminatorGREMEDY() == True:
                glFrameTerminatorGREMEDY = None



            self.gl_marker("Initializing GL context for window size %d x %d" % (w, h))
            # Initialize viewport and matrices for 2D rendering
            glViewport(0, 0, w, h)
            glMatrixMode(GL_PROJECTION)
            glLoadIdentity()
            glOrtho(0.0, w, h, 0.0, -1.0, 1.0)
            glMatrixMode(GL_MODELVIEW)
            #TODO glEnableClientState(GL_VERTEX_ARRAY)
            #TODO glEnableClientState(GL_TEXTURE_COORD_ARRAY)

            # Clear to white
            glClearColor(1.0, 1.0, 1.0, 1.0)

            # Default state is good for YUV painting:
            #  - fragment program enabled
            #  - render to offscreen FBO
            glEnable(GL_FRAGMENT_PROGRAM_ARB)
            if self.textures is None:
                self.textures = glGenTextures(5)
                debug("textures for wid=%s of size %s : %s", self.wid, self.size, self.textures)
            if self.offscreen_fbo is None:
                self.offscreen_fbo = glGenFramebuffers(1)

            # Define empty FBO texture and set rendering to FBO
            glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.textures[TEX_FBO])
            glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, 0)

            glBindFramebuffer(GL_FRAMEBUFFER, self.offscreen_fbo)
            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, self.textures[TEX_FBO], 0)
            glClear(GL_COLOR_BUFFER_BIT)

            self.gl_setup = True
        return drawable
def main():
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)	
    glutInitWindowSize(640, 480)	
    glutInitWindowPosition(0, 0)	
    window = glutCreateWindow("Framebuffer bug demo")

    for i in range( 200 ):
        fbo = EXT.glGenFramebuffersEXT(1)
        print "FBO = ", fbo
        EXT.glDeleteFramebuffersEXT (int(fbo))
        fbo = ARB.glGenFramebuffers(1)
        print "FBO = ", fbo
        ARB.glDeleteFramebuffers(int(fbo))
        glFlush()
Exemple #9
0
def main():
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)
    glutInitWindowSize(640, 480)
    glutInitWindowPosition(0, 0)
    window = glutCreateWindow("Framebuffer bug demo")

    for i in range(200):
        fbo = EXT.glGenFramebuffersEXT(1)
        print "FBO = ", fbo
        EXT.glDeleteFramebuffersEXT(int(fbo))
        fbo = ARB.glGenFramebuffers(1)
        print "FBO = ", fbo
        ARB.glDeleteFramebuffers(int(fbo))
        glFlush()
Exemple #10
0
def main():
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)	
    glutInitWindowSize(640, 480)	
    glutInitWindowPosition(0, 0)	
    glutCreateWindow("Framebuffer bug demo")

    for i in range( 200 ):
        fbo = EXT.glGenFramebuffersEXT(1)
        print("FBO = ", fbo)
        EXT.glDeleteFramebuffersEXT (int(fbo))
        fbo = ARB.glGenFramebuffers(1)
        print("FBO = ", fbo)
        ARB.glDeleteFramebuffers(int(fbo))
        glFlush()
    try:
        if fgDeinitialize: fgDeinitialize(False)
    except NameError:
        pass # Older PyOpenGL, you may see a seg-fault here...
Exemple #11
0
def main():
    glutInit(sys.argv)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)	
    glutInitWindowSize(640, 480)	
    glutInitWindowPosition(0, 0)	
    window = glutCreateWindow("Framebuffer bug demo")

    for i in range( 200 ):
        fbo = EXT.glGenFramebuffersEXT(1)
        print("FBO = ", fbo)
        EXT.glDeleteFramebuffersEXT (int(fbo))
        fbo = ARB.glGenFramebuffers(1)
        print("FBO = ", fbo)
        ARB.glDeleteFramebuffers(int(fbo))
        glFlush()
    try:
        if fgDeinitialize: fgDeinitialize(False)
    except NameError as err:
        pass # Older PyOpenGL, you may see a seg-fault here...
Exemple #12
0
 def gl_init_textures(self):
     assert self.offscreen_fbo is None
     assert self.shaders is None
     self.textures = glGenTextures(5)
     self.offscreen_fbo = glGenFramebuffers(1)
     debug("%s.gl_init_textures() textures: %s, offscreen fbo: %s", self, self.textures, self.offscreen_fbo)
Exemple #13
0
    def gl_init(self):
        drawable = self.gl_begin()
        w, h = self.size
        debug("%s.gl_init() GL Pixmap backing size: %d x %d, drawable=%s", self, w, h, drawable)
        if not drawable:
            return  None
        if not self.gl_setup:
            #ensure python knows which scope we're talking about:
            global glInitStringMarkerGREMEDY, glStringMarkerGREMEDY
            global glInitFrameTerminatorGREMEDY, glFrameTerminatorGREMEDY
            # Ask GL to send us all debug messages
            if GL_DEBUG_OUTPUT and gl_debug_callback and glInitDebugKHR() == True:
                glEnable(GL_DEBUG_OUTPUT)
                glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS)
                glDebugMessageCallback(gl_debug_callback, None)
                glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, None, GL_TRUE)
            # Initialize string_marker GL debugging extension if available
            if glInitStringMarkerGREMEDY and glInitStringMarkerGREMEDY() == True:
                log.info("Extension GL_GREMEDY_string_marker available. Will output detailed information about each frame.")
            else:
                # General case - running without debugger, extension not available
                glStringMarkerGREMEDY = None
                #don't bother trying again for another window:
                glInitStringMarkerGREMEDY = None
            # Initialize frame_terminator GL debugging extension if available
            if glInitFrameTerminatorGREMEDY and glInitFrameTerminatorGREMEDY() == True:
                log.info("Enabling GL frame terminator debugging.")
            else:
                glFrameTerminatorGREMEDY = None
                #don't bother trying again for another window:
                glInitFrameTerminatorGREMEDY = None

            self.gl_marker("Initializing GL context for window size %d x %d" % (w, h))
            # Initialize viewport and matrices for 2D rendering
            glViewport(0, 0, w, h)
            glMatrixMode(GL_PROJECTION)
            glLoadIdentity()
            glOrtho(0.0, w, h, 0.0, -1.0, 1.0)
            glMatrixMode(GL_MODELVIEW)
            #TODO glEnableClientState(GL_VERTEX_ARRAY)
            #TODO glEnableClientState(GL_TEXTURE_COORD_ARRAY)

            # Clear to white
            glClearColor(1.0, 1.0, 1.0, 1.0)

            # Default state is good for YUV painting:
            #  - fragment program enabled
            #  - YUV fragment program bound
            #  - render to offscreen FBO
            glEnable(GL_FRAGMENT_PROGRAM_ARB)
            if self.textures is None:
                self.textures = glGenTextures(5)
                debug("%s.gl_init() textures of size %s : %s", self, self.size, self.textures)
            if self.offscreen_fbo is None:
                self.offscreen_fbo = glGenFramebuffers(1)

            # Define empty FBO texture and set rendering to FBO
            glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.textures[TEX_FBO])
            # nvidia needs this even though we don't use mipmaps (repeated through this file):
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0)
            glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, None)
            glBindFramebuffer(GL_FRAMEBUFFER, self.offscreen_fbo)
            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, self.textures[TEX_FBO], 0)
            glClear(GL_COLOR_BUFFER_BIT)

            # Create and assign fragment programs
            if not self.shaders:
                self.shaders = [ 1, 2 ]
                glGenProgramsARB(2, self.shaders)
                for progid, progstr in ((0, YUV2RGB_shader), (1, RGBP2RGB_shader)):
                    glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, self.shaders[progid])
                    glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, len(progstr), progstr)
                    err = glGetString(GL_PROGRAM_ERROR_STRING_ARB)
                    if err:
                        #FIXME: maybe we should do something else here?
                        log.error(err)

            # Bind program 0 for YUV painting by default
            glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, self.shaders[0])
            self.gl_setup = True
        return drawable
Exemple #14
0
    def gl_init(self):
        drawable = self.gl_begin()
        w, h = self.size
        debug("%s.gl_init() GL Pixmap backing size: %d x %d, drawable=%s",
              self, w, h, drawable)
        if not drawable:
            return None
        if not self.gl_setup:
            #ensure python knows which scope we're talking about:
            global glInitStringMarkerGREMEDY, glStringMarkerGREMEDY
            global glInitFrameTerminatorGREMEDY, glFrameTerminatorGREMEDY
            # Ask GL to send us all debug messages
            if GL_DEBUG_OUTPUT and gl_debug_callback and glInitDebugKHR(
            ) == True:
                glEnable(GL_DEBUG_OUTPUT)
                glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS)
                glDebugMessageCallback(gl_debug_callback, None)
                glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE,
                                      0, None, GL_TRUE)
            # Initialize string_marker GL debugging extension if available
            if glInitStringMarkerGREMEDY and glInitStringMarkerGREMEDY(
            ) == True:
                log.info(
                    "Extension GL_GREMEDY_string_marker available. Will output detailed information about each frame."
                )
            else:
                # General case - running without debugger, extension not available
                glStringMarkerGREMEDY = None
                #don't bother trying again for another window:
                glInitStringMarkerGREMEDY = None
            # Initialize frame_terminator GL debugging extension if available
            if glInitFrameTerminatorGREMEDY and glInitFrameTerminatorGREMEDY(
            ) == True:
                log.info("Enabling GL frame terminator debugging.")
            else:
                glFrameTerminatorGREMEDY = None
                #don't bother trying again for another window:
                glInitFrameTerminatorGREMEDY = None

            self.gl_marker("Initializing GL context for window size %d x %d" %
                           (w, h))
            # Initialize viewport and matrices for 2D rendering
            glViewport(0, 0, w, h)
            glMatrixMode(GL_PROJECTION)
            glLoadIdentity()
            glOrtho(0.0, w, h, 0.0, -1.0, 1.0)
            glMatrixMode(GL_MODELVIEW)
            #TODO glEnableClientState(GL_VERTEX_ARRAY)
            #TODO glEnableClientState(GL_TEXTURE_COORD_ARRAY)

            # Clear to white
            glClearColor(1.0, 1.0, 1.0, 1.0)

            # Default state is good for YUV painting:
            #  - fragment program enabled
            #  - YUV fragment program bound
            #  - render to offscreen FBO
            glEnable(GL_FRAGMENT_PROGRAM_ARB)
            if self.textures is None:
                self.textures = glGenTextures(5)
                debug("%s.gl_init() textures of size %s : %s", self, self.size,
                      self.textures)
            if self.offscreen_fbo is None:
                self.offscreen_fbo = glGenFramebuffers(1)

            # Define empty FBO texture and set rendering to FBO
            glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.textures[TEX_FBO])
            # nvidia needs this even though we don't use mipmaps (repeated through this file):
            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0)
            glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, w, h, 0, GL_RGB,
                         GL_UNSIGNED_BYTE, None)
            glBindFramebuffer(GL_FRAMEBUFFER, self.offscreen_fbo)
            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                                   GL_TEXTURE_RECTANGLE_ARB,
                                   self.textures[TEX_FBO], 0)
            glClear(GL_COLOR_BUFFER_BIT)

            # Create and assign fragment programs
            if not self.shaders:
                self.shaders = [1, 2]
                glGenProgramsARB(2, self.shaders)
                for progid, progstr in ((0, YUV2RGB_shader),
                                        (1, RGBP2RGB_shader)):
                    glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB,
                                     self.shaders[progid])
                    glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB,
                                       GL_PROGRAM_FORMAT_ASCII_ARB,
                                       len(progstr), progstr)
                    err = glGetString(GL_PROGRAM_ERROR_STRING_ARB)
                    if err:
                        #FIXME: maybe we should do something else here?
                        log.error(err)

            # Bind program 0 for YUV painting by default
            glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, self.shaders[0])
            self.gl_setup = True
        return drawable
Exemple #15
0
    def gl_init(self):
        drawable = self.gl_begin()
        w, h = self.size
        debug("GL Pixmap backing size: %d x %d, drawable=%s", w, h, drawable)
        if not drawable:
            return None
        if not self.gl_setup:
            # Ask GL to send us all debug messages
            if GL_DEBUG_OUTPUT and gl_debug_callback and glInitDebugKHR(
            ) == True:
                glEnable(GL_DEBUG_OUTPUT)
                glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS)
                glDebugMessageCallback(gl_debug_callback, None)
                glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE,
                                      0, None, GL_TRUE)
            # Initialize string_marker GL debugging extension if available
            if glInitStringMarkerGREMEDY and glInitStringMarkerGREMEDY(
            ) == True:
                log.info(
                    "Extension GL_GREMEDY_string_marker available. Will output detailed information about each frame."
                )
            else:
                # General case - running without debugger, extension not available
                glStringMarkerGREMEDY = None
            # Initialize frame_terminator GL debugging extension if available
            if glInitFrameTerminatorGREMEDY and glInitFrameTerminatorGREMEDY(
            ) == True:
                glFrameTerminatorGREMEDY = None

            self.gl_marker("Initializing GL context for window size %d x %d" %
                           (w, h))
            # Initialize viewport and matrices for 2D rendering
            glViewport(0, 0, w, h)
            glMatrixMode(GL_PROJECTION)
            glLoadIdentity()
            glOrtho(0.0, w, h, 0.0, -1.0, 1.0)
            glMatrixMode(GL_MODELVIEW)
            #TODO glEnableClientState(GL_VERTEX_ARRAY)
            #TODO glEnableClientState(GL_TEXTURE_COORD_ARRAY)

            # Clear to white
            glClearColor(1.0, 1.0, 1.0, 1.0)

            # Default state is good for YUV painting:
            #  - fragment program enabled
            #  - render to offscreen FBO
            glEnable(GL_FRAGMENT_PROGRAM_ARB)
            if self.textures is None:
                self.textures = glGenTextures(5)
                debug("textures for wid=%s of size %s : %s", self.wid,
                      self.size, self.textures)
            if self.offscreen_fbo is None:
                self.offscreen_fbo = glGenFramebuffers(1)

            # Define empty FBO texture and set rendering to FBO
            glBindTexture(GL_TEXTURE_RECTANGLE_ARB, self.textures[TEX_FBO])
            glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, w, h, 0, GL_RGB,
                         GL_UNSIGNED_BYTE, 0)

            glBindFramebuffer(GL_FRAMEBUFFER, self.offscreen_fbo)
            glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
                                   GL_TEXTURE_RECTANGLE_ARB,
                                   self.textures[TEX_FBO], 0)
            glClear(GL_COLOR_BUFFER_BIT)

            self.gl_setup = True
        return drawable