Example #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))
Example #2
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)