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

  • From: Philippe Houdoin <philippe.houdoin@xxxxxxxxx>
  • To: haiku-3rdparty-dev@xxxxxxxxxxxxx
  • Date: Tue, 15 May 2012 18:42:37 +0200

Hi,

> Ive got a problem with BGLView subclass - I cannot change its background 
> colour.
> It is always opaque black regardless of what I try.

The default clear color or any GL view is opaque black, indeed.
See glClearColor() documentation to change it when it make sense (once
if it's always the same in each frame, at each frame if it's not).

> Calls to SetViewColor(rgb_color) which work fine for normal BViews have no
> effect with BGLView.

It does change the background view color, but as each SwapBuffers()
will draw new buffer over the whole area, you won't see it, except
maybe when in single buffer mode and something was overlapping your
view.

> Is this normal or am I doing something wrong? I can paint over the black using
> OpenGL itself, but the actual
> view insists on being opaque black.

The whole GLView content should be draw using GL calls, clearing the
color buffer included.
Not that using native BView API wont works, but as soon as you call
SwapBuffers you will lost whatever was paint there, replaced by what
was drawn in the OpenGL color buffer.

Philippe.

Other related posts: