1

Following the example given in the first code snippet of pyglet's official documentation about shapes I clearly get a jagged edge to the circle, it is clearly not anti-aliased in any successful way on my system at least. Here's my code and a screenshot:

import pyglet
from pyglet import shapes

window = pyglet.window.Window(fullscreen=True)
batch = pyglet.graphics.Batch()

circle = shapes.Circle(700, 150, 100, color=(50, 225, 30), batch=batch)

@window.event
def on_draw():
    window.clear()
    batch.draw()

pyglet.app.run()

So I am wondering whether it is so that pyglet does not directly cater for anti-aliasing with arcs, circles and lines.

And, how would you approach getting smooth circle/arc edges and smooth lines, using pyglet ― would you recommend a particular intervening (python) library for drawing smoothly-edged shapes? would you call OpenGL from pyglet's own OpenGL bindings to smoothly accomplish it?

A related discussion from over ten years ago: Pyglet OpenGL drawing anti-aliasing

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
matanster
  • 15,072
  • 19
  • 88
  • 167

1 Answers1

1

You have to create an OpenGL window with frame buffer configured for multisampling (see Creating an OpenGL context ans Specifying the OpenGL context properties):

import pyglet

config = pyglet.gl.Config()
config.sample_buffers = 1
config.samples = 4

indow = pyglet.window.Window(config=config)
Rabbid76
  • 202,892
  • 27
  • 131
  • 174