A question about draw-polygon and draw-filled-polygon

28 views
Skip to first unread message

若凡陈

unread,
Jun 6, 2015, 5:08:00 AM6/6/15
to lispb...@googlegroups.com
I tried to plot a hexagon using draw-polygon, here a hexagon is defined six vertices

(defparameter hexagon 
                        (list (sdl:point :x (* -10 (cos (/ pi 6))) :y -5)
                              (sdl:point :x (* -10 (cos (/ pi 6))) :y 5)
                              (sdl:point :x 0 :y 10)
                              (sdl:point :x (* 10 (cos (/ pi 6))) :y 5)
                              (sdl:point :x (* 10 (cos (/ pi 6))) :y -5)
                              (sdl:point :x 0 :y -10)))

When I called (sdl:draw-polygon hexagon), I expected to have a close hexagon. However,
one of computer gave me close hexagon and another gave me a open hexagon that
one of edges was missing.

Also, when I called (sdl:draw-filled-polygon hexagon), one gave me what I want and another 
drew nothing at all. So I'm wondering whether my code is not rigorous or it is a bug.

Could someone tell me what's going on? Thanks a lot.

Elliott Slaughter

unread,
Jun 6, 2015, 6:17:17 PM6/6/15
to lispb...@googlegroups.com
Does the bug go away if you repeat the first point at the end? I suspect that you are not actually closing the polygon.

I find it strange that you would get different results on different systems though. What OS/Lisp/Lispbuilder/SDL versions are we talking about?

--
You received this message because you are subscribed to the Google Groups "Lispbuilder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lispbuilder...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Elliott Slaughter

"Don't worry about what anybody else is going to do. The best way to predict the future is to invent it." - Alan Kay

若凡陈

unread,
Jun 6, 2015, 9:25:00 PM6/6/15
to lispb...@googlegroups.com
Yeah, I'm not closing the polygon. In fact I have tried closing the hexagon, indeed it would gave a close 
hexagon for both computer, but it won't make any difference for draw-filled-polygon.

Both machine use Kubuntu 14.04 and Clisp, I use Quicklisp for both to install lispbuilder. I also tried SBCL
but the results are the same.

The machine which has problem is using Intel Integrated Graphics Cards, another is using Nvdia GTX650Ti.

在 2015年6月7日星期日 UTC+8上午6:17:17,Elliott Slaughter写道:

若凡陈

unread,
Jun 7, 2015, 1:48:31 AM6/7/15
to lispb...@googlegroups.com
I'm sorry that the problem may be at other part of my code, some coordinate are not integer when I shift it.
Now it works fine.

Anyway thank you, Mr Slaughter.

By the way, your blackthorn library looks cool :)


在 2015年6月7日星期日 UTC+8上午6:17:17,Elliott Slaughter写道:
Does the bug go away if you repeat the first point at the end? I suspect that you are not actually closing the polygon.

Elliott Slaughter

unread,
Jun 7, 2015, 2:01:36 AM6/7/15
to lispb...@googlegroups.com
Glad you were able to fix it.
Reply all
Reply to author
Forward
0 new messages