PDA

View Full Version : how to detect the outline of a drawing drawn by CL_Draw?



jckhoa
07-15-2010, 08:06 AM
I want to create a circle, then assign an outline to it for collision detection. That is basically the idea but I don't know how to go about that. Anyone can help?

I use Clanlib 2.1.1 and it's my first time to use Clanlib. My game has one window and one graphic context gc1, for eg, provided by it.
I draw background picture via gc1
I draw sprites via gc1
I draw a circle using CL_Draw::circle() via gc1
--> I'm stuck here.

In SDL, I could achieve this by drawing my circle in a separate surface, then make my surface transparent. However in Clanlib 2.1.1, since everything is drawn by gc I can't isolate my circle from the rest. I tried searching for another function to draw a circle but was in vain.
I would appreciate if anybody give some light.

rombust
07-15-2010, 09:35 AM
You can draw it to a framebuffer.

And use "gc.get_pixeldata" to obtain the CL_PixelBuffer for use in the collisions.

See Examples/Canvas

(I have not tried this)

jckhoa
07-16-2010, 02:29 AM
See Examples/Canvas

(I have not tried this)

Thanks for your reply . I visited clanlib.org/wiki/Canvas but there's no codes there, just the picture :(

rombust
07-16-2010, 06:48 AM
Download the ClanLib 2.1.1 source at: http://clanlib.org/wiki/Download
The examples can be found inside that package

jckhoa
07-16-2010, 09:24 AM
Download the ClanLib 2.1.1 source at: http://clanlib.org/wiki/Download
The examples can be found inside that package

Thanks a lot. I will study the codes and hopefully I'll get the solution soon.

Have a great weekend :)