[haiku-3rdparty-dev] Re: Setting background colour of BGLView

  • From: Andrew Wood <andrew@xxxxxxxxxxxxxxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Fri, 11 May 2012 18:16:20 +0100

Ok Thanks for the replies. What Im trying to do is I've got a BBitmap image displayed in a BView and I want to be able to place another BBitmap ontop of it but with some areas transparent and then rotate the top image at will whilst allowing the underneath image to show through the transparent bit.


I can use a single BView to draw the two BBitmaps ontop of each other with transparency but cant see any way of rotating them so what I was trying to do was use a BGLView for the top most image so I can use OpenGL to draw the bitmap and do the rotation, but seemingly that wont give me the transparency.






On 09/05/2012 15:12, Stephan Aßmus wrote:
Am 09.05.2012 14:59, schrieb Andrew Wood:
Ive got a problem with BGLView subclass - I cannot change its background colour.
[...]

Unfortunately, I cannot comment on this.

On a related note, although I can change the colour of a normal BView to an opaque colour I cannot get the alpha channel to have any effect even though Ive set the drawing& blending mode:

SetDrawingMode(B_OP_ALPHA);
SetBlendingMode(B_PIXEL_ALPHA,B_ALPHA_OVERLAY);
rgb_color transparentBlackColor;
//black but totally transparent
transparentBlackColor.red=0;
transparentBlackColor.green=0;
transparentBlackColor.blue=0;
transparentBlackColor.alpha=0; //has no effect
SetViewColor(transparentBlackColor);

Am I doing something wrong here? As I understand the BeBook that should work.

BeOS never supported "transparent" BViews. Neither does Haiku (well somewhat, I'll get to that). The drawing order and hierarchy is (almost) entirely clipping based. Not even overlapping BView siblings are supported (i.e. no defined drawing order). As such, a BView will always clip it's parent BView.

There is however one way out as long as you are not trying to achieve a transparent BWindow. (No transparent windows in Haiku, at all.) But you can give a BView the flag "B_DRAWS_ON_CHILDREN" (if memory serves). If you also specify SetViewColor(B_TRANSPARENT_COLOR) on the child view, you can avoid the child view clipping the parent and also the app_server from painting the background of the child view before Draw() is called. In that case, in your child view's Draw() method, the parent view has drawn before your child view, i.e. you can draw on top the parent view contents (with transparency, if you like). For examples, see the code to some of the apps that support being embedded on the Desktop in Haiku, DeskCalc and ActivityMonitor have that feature. (The B_DRAWS_ON_CHILDREN flag also triggers DrawAfterChildren() to be called on the parent view, but that's not important in the child views.)

Best regards,
-Stephan


Other related posts: