|
|
| [A5] shouldn't al_set_clipping_rectangle use floats? |
|
axilmar
Member #1,204
April 2001
|
The function al_set_clipping_rectangle uses integers, however the drawing functions take floats as arguments. Matthew Leverton said in another thread that someone might setup the screen to go from (0,0)-(1,1). If someone does that, then what values should be passed to al_set_clipping_rectangle? |
|
Arthur Kalliokoski
Second in Command
February 2005
|
I'd imagine the function uses the reciprocal of the bitmap size. They all watch too much MSNBC... they get ideas. |
|
Elias
Member #358
May 2000
|
Arthur Kalliokoski said: I'd imagine the function uses the reciprocal of the bitmap size. Indeed. With bitmap being whatever is returned by al_get_target_bitmap. We only support aligned clipping rectangles, so using the transformations doesn't make sense (e.g. what if someone use a transformation to rotate by 45 degree). -- |
|
axilmar
Member #1,204
April 2001
|
So when one uses clipping, the screen coordinate system must not be transformed to (0,0)-(1,1)? |
|
Arthur Kalliokoski
Second in Command
February 2005
|
They all watch too much MSNBC... they get ideas. |
|
Todd Cope
Member #998
November 2000
|
Transformations do not affect the result of al_set_clipping_rectangle(). You can use transformations with clipping just remember that you will need to convert your clipping coordinates to "pixel" coordinates to use with al_set_clipping_rectangle(). |
|
SiegeLord
Member #7,827
October 2006
|
There's some confusion here. al_set_clipping_rectangle() sets the clipping rectangle of the target bitmap's pixels. "Setting up a screen to go from (0,0)-(1,1)" means that you'll create a transformation which maps input coordinates (like those you pass to al_draw_bitmap) ranging from (0,0)-(1,1) to what the target bitmap's dimensions are (e.g. (0,0)-(800,600)). So, to clip coordinates (0,0)-(0.5,0.5) you'd do: al_set_clipping_rectangle(0, 0, al_get_bitmap_width(al_get_target_bitmap()) * 0.5, al_get_bitmap_height(al_get_target_bitmap()) * 0.5); In other words, the clipping rectangle is applied only after all the transformations have been applied, not before. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
|
Matthew Leverton
Supreme Loser
January 1999
|
I was speaking of setting up a transformation on the back buffer such that a blit or primitive operation call to it would transformed. That would obviously affect your GUI's drawing operations. Things like the mouse will always be reported in integer screen x,y positions, etc. Clipping is always done in actual bitmap coordinates as well. So for your usage, I don't see how supporting such transformations would be practical. |
|
Mark Oates
Member #1,146
March 2001
|
Eventually, it may be a good idea to support draw_with_alpha routines. -- |
|
Elias
Member #358
May 2000
|
Mark Oates said: Eventually, it may be a good idea to support draw_with_alpha routines. What would those do? -- |
|
axilmar
Member #1,204
April 2001
|
Ok, thank you guys. My gui uses clipping to limit widget output, and since mouse coordinates are integers, I will stick to integer coordinates in my gui. This means that if a game uses my gui and does transformations on the coordinate system, there is going to be a problem, but I don't see a good solution to this. |
|
Todd Cope
Member #998
November 2000
|
You could use the state API (al_store_state(), al_restore_state()) to store the user's transformation and use the identity transformation when rendering your GUI. This way your GUI will always render correctly and the user's coordinate system will be restored and ready for them to use when your done. |
|
Matthew Leverton
Supreme Loser
January 1999
|
Right, but the programmer wouldn't be able to do something like: resize_widget(0.5, 0.5); But to me, that's not a big deal, because it really doesn't make much sense if you know what transformations are with respect to Allegro. |
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
There's nothing stopping you from doing gui_resize_widget_f(gui* g , widget* w , float w_percent , float h_percent); is there? The gui knows its dimensions, and applies the percentage to a secondary resize widget function call. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
|
Mark Oates
Member #1,146
March 2001
|
Elias said: What would those do I'm thinking of functions that draw anything to a bitmap, but only through an alpha mask (or just a grayscale bitmap.) As it is now, the effect can be done with offscreen renders and changing to alpha-only blending modes, but it seems like there would be a more proper low-level way to do it. OpenLayer had this feature, if I recall correctly. It's a feature I'll surely advocate for more in the future, when I get around to it. [edit]I'm thinking of something as simple as al_set_alpha_mask(ALLEGRO_BITMAP *b); al_unset_alpha_mask(); and any subsequent drawing operations would only draw the pixels through that mask. -- |
|
axilmar
Member #1,204
April 2001
|
Todd Cope said: You could use the state API (al_store_state(), al_restore_state()) to store the user's transformation and use the identity transformation when rendering your GUI. This way your GUI will always render correctly and the user's coordinate system will be restored and ready for them to use when your done. Thanks, that's what I'm gonna do. Matthew Leverton said: But to me, that's not a big deal, because it really doesn't make much sense if you know what transformations are with respect to Allegro. I agree. Edgar Reynaldo said: The gui knows its dimensions, and applies the percentage to a secondary resize widget function call. The problem is the sub-pixel clipping, not the widget resizing. |
|
Elias
Member #358
May 2000
|
Mark Oates said:
al_set_alpha_mask(ALLEGRO_BITMAP *b); Setting it to NULL could naturally do the unset so the extra unset function is probably not necessary. And maybe we should call it al_set_stencil_mask to make more clear what it would do. Also, I was thinking about something like: al_set_stencil_target(display); Which would allow drawing directly to the stencil buffer. The software renderer likely would not support this at all, or else it just would be an extra if() in the draw_pixel function. -- |
|
|