Example #1
0
 def draw(self, projection, view, width, height):
     if self._draw_mode == self.DRAW_PIXELS:
         np_type = self._framebuffer.color_attachments[
             self._color_index].dtype
         gl_type = opengl_utils.get_gl_type(np_type)
         pixels = self._framebuffer.read_rgba_pixels(self._color_index)
         if self._color_scale != 1.0:
             pixels *= self._color_scale
         if self._color_offset != 1.0:
             pixels += self._color_offset
         width = min(width, self._framebuffer.width)
         height = min(height, self._framebuffer.height)
         gl.glDrawPixels(width, height, gl.GL_RGBA, gl_type, pixels)
     elif self._draw_mode == self.DRAW_QUAD:
         gl.glDisable(gl.GL_DEPTH_TEST)
         gl.glDisable(gl.GL_CULL_FACE)
         with self._quad.activate():
             self._quad["u_color_offset"] = self._color_offset
             self._quad["u_color_scale"] = self._color_scale
             self._quad.draw(gl.GL_TRIANGLE_STRIP)
         gl.glEnable(gl.GL_CULL_FACE)
         gl.glEnable(gl.GL_DEPTH_TEST)
     elif self._draw_mode == self.BLIT:
         gl.glBindFramebuffer(gl.GL_READ_FRAMEBUFFER,
                              self._framebuffer.native_framebuffer.handle)
         gl.glReadBuffer(gl.GL_COLOR_ATTACHMENT0 + self._color_index)
         gl.glBindFramebuffer(gl.GL_DRAW_FRAMEBUFFER, 0)
         gl.glBlitFramebuffer(0, 0, self._framebuffer.width,
                              self._framebuffer.height, 0, 0, width, height,
                              gl.GL_COLOR_BUFFER_BIT, gl.GL_LINEAR)
     else:
         raise RuntimeError("Unknown drawing mode")
Example #2
0
 def activate(self, clear=False):
     gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0)
     gl.glViewport(0, 0, self.width, self.height)
     if clear:
         # self._win.clear()
         gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
     gl.glEnable(gl.GL_DEPTH_TEST)
     yield self
Example #3
0
    def _activate(self):
        """ Activate framebuffer on GPU """

        log.debug("GPU: Activate render framebuffer")
        gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self._handle)
        if self._need_attach:
            self._attach()
            self._need_attach = False
Example #4
0
    def _activate(self):
        """ Activate framebuffer on GPU """

        log.debug("GPU: Activate render framebuffer")
        gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self._handle)

        if self._need_attach:
            self._attach()
            self._need_attach = False
        attachments = [gl.GL_COLOR_ATTACHMENT0+i for i in range(len(self.color))]
        gl.glDrawBuffers(np.array(attachments,dtype=np.uint32))
Example #5
0
    def _activate(self):
        """ Activate framebuffer on GPU """

        log.debug("GPU: Activate render framebuffer")
        gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, self._handle)

        if self._need_attach:
            self._attach()
            self._need_attach = False
        attachments = [
            gl.GL_COLOR_ATTACHMENT0 + i for i in range(len(self.color))
        ]
        gl.glDrawBuffers(np.array(attachments, dtype=np.uint32))
Example #6
0
    def _deactivate(self):
        """ Deactivate framebuffer on GPU """

        log.debug("GPU: Deactivate render framebuffer")
        gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0)
Example #7
0
    def _deactivate(self):
        """ Deactivate framebuffer on GPU """

        log.debug("GPU: Deactivate render framebuffer")
        gl.glBindFramebuffer(gl.GL_FRAMEBUFFER, 0)