Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » BUG REPORT: polygon(,,,,)

This thread is locked; no one can reply to it. rss feed Print
BUG REPORT: polygon(,,,,)
fuzinavl
Member #4,105
December 2003
avatar

2d polygon(,,,,) function does not render the lowest row of pixels.

I'm using allegro 4.1 and devc++.

__________________________
fuzinavl@hotmail.com (Pittsburgh)
__http://fuzinavl.tripod.com/__

Fiddler
Member #5,385
January 2005

Please, try the latest version of Allegro (4.2.0 beta1) and see if the problem persits.

The Open Toolkit: a game development library for .Net/Mono.
http://www.opentk.com

gillius
Member #119
April 2000

I don't know about this specific case, but please note that almost all graphics libraries on purpose do not draw the left-most or right-most or whatever-most pixel of a polygon, because if you paste together polygons you want to be able to prevent any overdraw (which becomes extremely critical if the polys are transparent -- if you drew all pixels you would see 1 pixel lines at the poly borders).

Gillius
Gillius's Programming -- https://gillius.org/

fuzinavl
Member #4,105
December 2003
avatar

Stephen: I will once the download is available in a precompiled mingw library & alleg42.dll. ( I'm lazy :)

Gillius: If that is the case, then the right-most pixels should not be drawn either; but they are.

Suggestion: If transparency drawing is on, then do not draw right-most and bottom-most pixels of the 2d polygon. Otherwise, fill the 2d polygon completely.

__________________________
fuzinavl@hotmail.com (Pittsburgh)
__http://fuzinavl.tripod.com/__

Elias
Member #358
May 2000

polygon3d_f draws neither the right nor the bottom pixels.

So probably, since triangle and polygon draw the right pixels, they should draw the bottom pixels as well.

Do you have a patch to correct this? If not, I'll have a look at polygon.c.

--
"Either help out or stop whining" - Evert

Fladimir da Gorf
Member #1,565
October 2001
avatar

I think there should be a parameter that tells if the right and leftmost lines should be skipped.

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Elias
Member #358
May 2000

I see no need. You use polygon if you don't want them skipped, polygon3d otherwise.

--
"Either help out or stop whining" - Evert

Evert
Member #794
November 2000
avatar

This issue has come up and been discussed before. I don't know if a patch was ever submitted or if any reason has been given why this should not be done.
A search with the right keywords might be worthwhile, but I don't have time to do one myself at the moment.

Elias
Member #358
May 2000

I also seem to remember something, but a search revealed nothing. Anyway, there's no reason to make it not either skip the right pixels, or draw the bottom ones. And seeing how we have line, rectangle, triangle, polygon all together in the docs, they should all behave the same (so draw the right and bottom pixels).

--
"Either help out or stop whining" - Evert

ReyBrujo
Moderator
January 2001
avatar

Here is a post where it is pointed that, besides that thread, there were two others talking about somewhat the same problem.

And it seems the patch was never made.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Elias
Member #358
May 2000

Ah, yes, that explains it.. must have read one of those threads on the forums. Nothing ever went through to [AD] though. I'll make a patch later to fix it (well, assuming, it is a quite simple case of changing a y < height to y <= height in a for loop).

--
"Either help out or stop whining" - Evert

fuzinavl
Member #4,105
December 2003
avatar

I found a thread with possible {code} solutions:
[url http://www.allegro.cc/forums/view_thread.php?_id=381581]

Elias' avatar :D

__________________________
fuzinavl@hotmail.com (Pittsburgh)
__http://fuzinavl.tripod.com/__

Elias
Member #358
May 2000

Quote:

I found a thread with possible {code} solutions:

Ah, great. I wonder how that was missed.. someone really should have forwarded it to [AD] when no devs noticed it. Luckily I didn't get around yet to look at it, so now can just create a patch from Surt's code :) Thanks for finding it!

Quote:

Elias' avatar :D

:) [that is, i had the same avatar since years.. me looks puzzled]

[Edit:]
Hm, the patch by Surt doesn't work.. it overdraws parts of the polygon, which is not acceptable.

[Edit2:]
Seems hard to fix. The polygon renderer constructs a list of edges, sorts them, then draws them line by line from above. It always skips the last line, in order not to overlap with the next edge below an edge.
Of course, this breaks everytime a lowest edge is reached. (E.g. in a W shape, it forgets the 2 bottom pixels, or in a box shape, the entire bottom line.) I don't see how an algorithm for this would work.. anyone has experience with writing software polygon renderers?

--
"Either help out or stop whining" - Evert

fuzinavl
Member #4,105
December 2003
avatar

I know it's tempting to want to do all scanlines in a single, perfect pass.

Is there any major reason why the very bottom scanline couldn't be done as a
seperate operation? (are the poly edges already sorted vertically?)

__________________________
fuzinavl@hotmail.com (Pittsburgh)
__http://fuzinavl.tripod.com/__

Elias
Member #358
May 2000

They are sorted as far as I see. So yeah, they could be done as a separate pass. Maybe it's the best. So, it would mean, walking the polygon edges, detecting minima, and figuring out the length of a hfill to draw at every such minimum.

--
"Either help out or stop whining" - Evert

fuzinavl
Member #4,105
December 2003
avatar

I'm not sure how the algorithm works, but is there a way
to test only against the poly edges used for the previous scanline?

If so, the last scanline won't take any more work than the
second-to-last scanline.

__________________________
fuzinavl@hotmail.com (Pittsburgh)
__http://fuzinavl.tripod.com/__

Elias
Member #358
May 2000

There can be multiple last scanlines (e.g. an M shaped polygon has 3 minima), so it's not completely easy. It's easy enough once the algorithm used is understood, I guess.

--
"Either help out or stop whining" - Evert

fuzinavl
Member #4,105
December 2003
avatar

I like Fladimir's idea of a separate boolean parameter to fill out the right and bottom edges or not.

Another way is to let
polygon(,,,) fill out automatically, and have a separate function like
polygon_shaved(,,,) to omit the right and bottom scanlines. That way, people
won't have to change their existing code.

__________________________
fuzinavl@hotmail.com (Pittsburgh)
__http://fuzinavl.tripod.com/__

Elias
Member #358
May 2000

Yes, I like the idea as well.. it gets one step closer to OpenGL polygons :) But anyway, maybe we should think about making polygon a simple wrapper around polygon3d, and add the possibility for borders to that. It doesn't look like anyone is up to fixing the code in polygon.c anyway.

Now if it's easier to add optional right and bottom edges to the polygon3d code, I have no idea..

--
"Either help out or stop whining" - Evert

fuzinavl
Member #4,105
December 2003
avatar

What would people use "unshaved" 3D polygons for?

__________________________
fuzinavl@hotmail.com (Pittsburgh)
__http://fuzinavl.tripod.com/__

Elias
Member #358
May 2000

For example, I often use rectangle.

--
"Either help out or stop whining" - Evert

Go to: