Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » primitives glitches

Credits go to Elias and SiegeLord for helping out!
This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
primitives glitches
Matthew Leverton
Supreme Loser
January 1999
avatar

SiegeLord said:

It's no more of a bug than the coordinates for al_draw_rectangle and al_draw_filled_rectangle not lining up.

It's not a bug if it does what it's documented to do. But right now it says:

al_draw_line said:

x1, y1, x2, y2 - Start and end points of the line

al_draw_rectangle said:

x1, y1, x2, y2 - Upper left and lower right points of the rectangle

al_draw_filled_rectangle said:

x1, y1, x2, y2 - Upper left and lower right points of the rectangle

They all sound identical, so I'd expect identical behavior when passing the same values. If there are valid technical reasons that force the programmer to use different numbers for seemingly identical coordinates, then so be it.

But the documentation and all the various explanations here are not clear (and in some cases contradicting).

Thomas Fjellstrom
Member #476
June 2000
avatar

Yes things probably are inconsistent in the primitives addon.. Personally I'd like to see them act purely as pixel perfect a4 like routines. If you want anything fancier, use GL or something.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

SiegeLord
Member #7,827
October 2006
avatar

Okay, we (the devs) discussed this at lengths, and decided that the current semantics of the functions are the least evil of all the alternatives we proposed. Thus, moving forward, we (I) will be doing this:

Somebody who knows how this works just needs to update the documentation that tells you how to draw a line/box/triangle/etc from a to b.

...with <marque><blink>pictures!</marque></blink>

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Thomas Fjellstrom
Member #476
June 2000
avatar

Lets just say I don't agree ;) I don't think the point of allegro was to emulate GL's semantics, but rather to be more sane and easier to grasp.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Matthew Leverton
Supreme Loser
January 1999
avatar

It's okay. I'll just create a new "Line Drawing" forum to handle all of the questions. 8-)

SiegeLord
Member #7,827
October 2006
avatar

Okay, I added a section to the documentation explaining how the things work... hopefully it should make things clear for everyone. Here's a preview courtesy of Thomas Fjellstrom: Linky.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Matthew Leverton
Supreme Loser
January 1999
avatar

What about al_draw/put_pixel? Does that always set a single pixel as closest to the specified coordinates?

William Labbett
Member #4,486
March 2004
avatar

I can vouch for that.

Trouble is al_put_pixel is only useful on memory bitmaps. al_draw_pixel is slow too althought I don't know if it is on memory bitmaps.

Trent Gamblin
Member #261
April 2000
avatar

If you lock the bitmap, al_put_pixel is not too slow, if you don't use it too much.

Matthew Leverton
Supreme Loser
January 1999
avatar

I don't care much about speed, because the bitmap is only generated once. I want to make sure that the pixel is drawn where I expect it to be.

Right now I'm using (x+0.5,y+0.5), where (x,y) represents an integer coordinate system.

Elias
Member #358
May 2000

al_put_pixel takes integer coordinates so it just uses a pixel index. It also should not be affected by transformations or blending. (If that's not how it actually works it's probably a bug.)

al_draw_pixel I guess is equivalent to drawing a 1x1 filled rectangle, so I'd say using 0.5/0.5 is the right thing to do for it.

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

SiegeLord
Member #7,827
October 2006
avatar

Elias said:

al_put_pixel takes integer coordinates so it just uses a pixel index. It also should not be affected by transformations or blending. (If that's not how it actually works it's probably a bug.)

al_draw_pixel I guess is equivalent to drawing a 1x1 filled rectangle, so I'd say using 0.5/0.5 is the right thing to do for it.

Yes, that's how it works.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Matthew Leverton
Supreme Loser
January 1999
avatar

Quote:

/* blue vertical line */
al_draw_line(0.5, 0, 0.5, 6, color_blue, 1);

Why use 0 and 6 for y? Does the thickness only extend perpendicular to the line?

SiegeLord
Member #7,827
October 2006
avatar

Yes, that it does.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

William Labbett
Member #4,486
March 2004
avatar

I want to say - although it's slowed down my game's development because I had to learn the new API, I love allegro 5. I don't care much for whether the scheme follows the openGL way or the old allegro style. Either way, both can do everything, you just have to get used to how to do what you want.

Mark Oates
Member #1,146
March 2001
avatar

SiegeLord said:

Here's a preview courtesy of Thomas Fjellstrom: Linky [alleg.strangesoft.net].

Nice illustrations.... which gives me an idea! Let me help by doing illustrations for the manual. Since I can't help much with the actual coding, and I have this constant uncontrollable urge to do graphics for no reason, I'd like to volunteer for that job. Several functions, like the al_draw_arc() function would really benefit with a nice illustration. Another example is the al_draw_font_* and metrics routines.

Most importantly, we should agree to standardize the illustration style. I really like the line weights, proportion to document text size, fonts, and conventions you used (cross hairs, pointer arrow to coordinates, dashed line (not transparent line), Verdana italic for axis, etc). And unless you already have it planned out, we should start with that as a design reference. What program did you use and can you send me the file? I would like to write up an illustration standards in the wiki.

I really believe we should do this. It would be a great key to the appearance, quality, and usability of A5. I can see it and I believe in it.

I love allegro 5.

Totally agree. I'm getting to know the the event system, It's pretty powerful.

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

BAF
Member #2,981
December 2002
avatar

Just skimming over this thread, I tend to agree with Tomasu. Why the hell should it be this obscure? If I created something this hard to understand at work, I wouldn't have my job for long. :-/

Matthew Leverton
Supreme Loser
January 1999
avatar

BAF said:

I wouldn't have my job for long

You'd be fired for skimming the documentation. :o

It's annoying, but understandable (I suppose) due to the transformation system. I've just created a few macros to help me remember, e.g.:

#define _algui_draw_hline(x, y, w, c) al_draw_line((x), (y) + 0.5, (x) + (w), (y) + 0.5, c, 1.0)

If the API is well documented and works the same across all platforms, there's really not much to complain about.

Elias
Member #358
May 2000

Nice illustrations.... which gives me an idea! Let me help by doing illustrations for the manual.

I like the idea of more pictures. We were talking about it in #allegro yesterday, some other obvious places would be placing the logo on the front page and replacing any ASCII-art. Except, it would probably be good for ASCII art to stay in the man docs. Not sure if pandoc allows man-only sections though.

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

Thomas Fjellstrom
Member #476
June 2000
avatar

Damnit, now I know I was being unreasonable. BAF Agreed with me :-X

;)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

weapon_S
Member #7,859
October 2006
avatar

There are no inconsistencies between platforms? Good :)
Will the green rectangle in the first example have any output, when multisampling is turned on?

Elias
Member #358
May 2000

weapon_S said:

Will the green rectangle in the first example have any output, when multisampling is turned on?

Yes. Depends on the multisample settings what exactly happens though.

[edit]

OpenGL ES 2.0 specification said:

Multisample rasterization of all primitives differs substantially from single-
sample rasterization. It is understood that each pixel in the framebuffer has
SAMPLES locations associated with it. These locations are exact positions, rather
than regions or areas, and each is referred to as a sample point. The sample points
associated with a pixel may be located inside or outside of the unit square that is
considered to bound the pixel. Furthermore, the relative locations of sample points
may be identical for each pixel in the framebuffer, or they may differ.

So it depends on how many of those sample points hit the shape. If you use 4x4 samples and one hits the shape, its color will contribute 1/16th to the final color of the pixel.

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

SiegeLord
Member #7,827
October 2006
avatar

What program did you use and can you send me the file? I would like to write up an illustration standards in the wiki.

I used Inkscape 0.47, although I'm sure anything that can draw vector grahics can work. The source SVG files can be found in the Allegro SVN in the /docs/src/refman/images folder.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

 1   2   3 


Go to: