Exemple #1
0
def create_fbo(ctx: moderngl.Context,
               size: Size,
               components: int = 4) -> moderngl.Framebuffer:
    """Create a Frame Buffer Object (fbo) with the given size and
    color components"""
    return ctx.framebuffer(
        color_attachments=[ctx.renderbuffer(size, components)],
        depth_attachment=ctx.depth_renderbuffer(size))
Exemple #2
0
 def get_fbo(self,
             ctx: moderngl.Context,
             samples: int = 0) -> moderngl.Framebuffer:
     pw = self.pixel_width
     ph = self.pixel_height
     return ctx.framebuffer(color_attachments=ctx.texture(
         (pw, ph),
         components=self.n_channels,
         samples=samples,
     ),
                            depth_attachment=ctx.depth_renderbuffer(
                                (pw, ph), samples=samples))
Exemple #3
0
 def __init__(self, ctx: moderngl.Context, w: int, h: int, type: Tuple[int, str] = (1, 'f1'),
              use_depth: bool = False):
     self.w, self.h, self.type = w, h, type
     if use_depth:
         self.dbo = ctx.depth_texture((w,h))
     self.fbo = ctx.framebuffer([ctx.renderbuffer((w, h), type[0], dtype=type[1])], depth_attachment=self.dbo)