Skip to content

Commit

Permalink
upadte headless example
Browse files Browse the repository at this point in the history
  • Loading branch information
szabolcsdombi committed Jul 1, 2024
1 parent 43b0d1f commit b32b3a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ __pycache__
*.pyc
*.pyd
*.so

/*.png
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

ctx = moderngl.create_standalone_context()

fbo1 = ctx.framebuffer([ctx.renderbuffer((800, 800), components=4, samples=16)])
fbo2 = ctx.framebuffer([ctx.renderbuffer((800, 800), components=4)])
fbo = ctx.framebuffer([ctx.renderbuffer((800, 800), components=4, samples=16)])
output = ctx.framebuffer([ctx.renderbuffer((800, 800), components=4)])

prog = ctx.program(
vertex_shader='''
Expand Down Expand Up @@ -42,14 +42,14 @@
)

vao = ctx.vertex_array(prog, [])
vao.scope = ctx.scope(fbo1)
vao.instances = 9
vao.vertices = 3

fbo1.clear(0.0, 0.0, 0.0, 0.0)
fbo.use()
ctx.clear()
vao.render()

ctx.copy_framebuffer(fbo2, fbo1)
ctx.copy_framebuffer(output, fbo)

img = Image.frombuffer('RGBA', fbo2.size, fbo2.read(components=4)).transpose(Image.Transpose.FLIP_TOP_BOTTOM)
img = Image.frombuffer('RGBA', output.size, output.read(components=4)).transpose(Image.Transpose.FLIP_TOP_BOTTOM)
img.save('logo.png')

0 comments on commit b32b3a6

Please sign in to comment.