drawing circles and arcs with pyglet?

1,804 views
Skip to first unread message

altern

unread,
Jul 9, 2008, 2:02:30 PM7/9/08
to pyglet...@googlegroups.com
hi

sorry to keep asking questions, but i have couple of days to explore
pyglet so loads of questions keep popping up...

this time i would like to know how to draw circles and arcs. I know i
can do it with OpenGL but is there some pyglet way to do it? I mean some
way so that i can add the circle/arc/ellipse to a batch. Or maybe this
is only possible with vertex based shapes?

thanks once again

enrike

Colin Bean

unread,
Jul 9, 2008, 2:21:11 PM7/9/08
to pyglet...@googlegroups.com


Your circles / arcs are going to be vertex based shapes, there's
really no other way. I'd suggest adding your circle geometry to a
vertex list, then you can add that vertex list to a batch.

Colin

altern

unread,
Jul 9, 2008, 2:47:31 PM7/9/08
to pyglet...@googlegroups.com
Colin Bean(e)k dio:

could you please give some hints on how to add circle geometry to a
vertex list? I dont know at all where to start from. So far i always
solved this by using gluDisk()

thanks

enrike

altern

unread,
Jul 9, 2008, 2:54:17 PM7/9/08
to pyglet...@googlegroups.com
Colin Bean(e)k dio:

just thinking about this ... do you mean i would have to calculate the
position of certain number of points within a circle around a center and
then add this to the batch?

enrike

Colin Bean

unread,
Jul 9, 2008, 3:40:01 PM7/9/08
to pyglet...@googlegroups.com


Right, that's what I was thinking if you were willing to roll your own
circle functions (didn't know you were using gluDisk). Not sure if
this is the way you want to do it, but that would be the easiest way
to add circle geometry to a Pyglet batch.

Otherwise, I'd stick with gluDisk and display lists... Seems like you
could create a subclass of Batch that can hold and call display lists,
but I don't know if you'd gain anything from that besides cleaner
code.

Colin

altern

unread,
Jul 9, 2008, 4:25:40 PM7/9/08
to pyglet...@googlegroups.com
Colin Bean(e)k dio:
> On Wed, Jul 9, 2008 at 11:54 AM, altern <alt...@gmail.com> wrote:
>> Colin Bean(e)k dio:
>>> On Wed, Jul 9, 2008 at 11:02 AM, altern <alt...@gmail.com> wrote:
>>>> hi
>>>>
>>>> sorry to keep asking questions, but i have couple of days to explore
>>>> pyglet so loads of questions keep popping up...
>>>>
>>>> this time i would like to know how to draw circles and arcs. I know i
>>>> can do it with OpenGL but is there some pyglet way to do it? I mean some
>>>> way so that i can add the circle/arc/ellipse to a batch. Or maybe this
>>>> is only possible with vertex based shapes?
>>>>
>>>> thanks once again
>>>>
>>>> enrike
>>>>
>>>
>>> Your circles / arcs are going to be vertex based shapes, there's
>>> really no other way. I'd suggest adding your circle geometry to a
>>> vertex list, then you can add that vertex list to a batch.
>> just thinking about this ... do you mean i would have to calculate the
>> position of certain number of points within a circle around a center and
>> then add this to the batch?
>>
>> enrike
>>
>
>
> Right, that's what I was thinking if you were willing to roll your own
> circle functions (didn't know you were using gluDisk). Not sure if
> this is the way you want to do it, but that would be the easiest way
> to add circle geometry to a Pyglet batch.

sorry, maybe i was not clear. I have used gluDisk before but i would
like now if possible to use Batch and vertex lists to draw circles. I
understand that this should be faster and more efficient. it is way
faster at least with polygons.

> Otherwise, I'd stick with gluDisk and display lists... Seems like you
> could create a subclass of Batch that can hold and call display lists,
> but I don't know if you'd gain anything from that besides cleaner
> code.

nice to know that about subclassing batch, but i dont think this would
be any good for me, i need to draw a circle that (potentially) changes
location every frame. I understand that there is no much use of using
display lists in cases like that. Mostly because changing the display
list (potentially) every frame takes away all the performance benefit
gained with precompiling the display list.

enrike

Colin Bean

unread,
Jul 9, 2008, 4:44:39 PM7/9/08
to pyglet...@googlegroups.com

As far as I know, if you want to use vertex lists you'll have to
calculate the circle coordinates yourself (then add them to a vertex
list).
This might be a helpful starting point:
http://basiccomputergraphics.googlecode.com/svn/python/circle.py

Colin

altern

unread,
Jul 9, 2008, 4:55:29 PM7/9/08
to pyglet...@googlegroups.com

ok, thanks!

enrike

Reply all
Reply to author
Forward
0 new messages