Allegro.cc Forums » Programming Questions » [A5] shouldn't al_set_clipping_rectangle use floats?

Credits go to Matthew Leverton and Todd Cope for helping out!
 [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. “Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”― Robert A. Heinlein
 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). --"Either help out or stop whining" - Evert
 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 Use the prototype, Luke![EDIT]Trust them. Seriously. If it doesn't work, then post questions. “Throughout history, poverty is the normal condition of man. Advances which permit this norm to be exceeded — here and there, now and then — are the work of an extremely small minority, frequently despised, often condemned, and almost always opposed by all right-thinking people. Whenever this tiny minority is kept from creating, or (as sometimes happens) is driven out of a society, the people then slip back into abject poverty. This is known as "bad luck.”― Robert A. Heinlein
 Todd Cope Member #998 November 2000 Transformations do not affect the result of . You can use transformations with clipping just remember that you will need to convert your clipping coordinates to "pixel" coordinates to use with .
 SiegeLord Member #7,827 October 2006 There's some confusion here. 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: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[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]
 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? --"Either help out or stop whining" - Evert
 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 () 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 Member #8,592 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. Elizabeth Warren for President 2020! | Modern Allegro 4 and 5 binaries | Allegro 5 compile guideKing Piccolo will make it so
 Mark Oates Member #1,146 March 2001 Elias said:What would those doI'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. That and primitive drawing with filtering to off-screen bitmaps. With those two you could then combine them to get the equivalent of a sub-pixel clipping region, or any clipping shape for that matter.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);al_unset_alpha_mask(); 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. --"Either help out or stop whining" - Evert
 Go to: Allegro Development Installation, Setup & Configuration Allegro.cc Comments Off-Topic Ordeals The Depot Game Design & Concepts Programming Questions Recent Threads