Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Could not set the background color #48

Closed
leonsal opened this issue Jun 12, 2019 · 5 comments
Closed

Could not set the background color #48

leonsal opened this issue Jun 12, 2019 · 5 comments

Comments

@leonsal
Copy link

leonsal commented Jun 12, 2019

Hi,

In my tests after generating the drawing commands for several rectangles,
the framebuffer is cleared to white, but the background of my window remains black.
Please see the screenshot.

Commands executed after drawing the rectangles:

...
mPainter->end();
// Make sure we are rendering to the default fraembuffer of GL
fastuidraw_glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);

// Clear the framebuffer
fastuidraw_glClearColor(1.0, 1.0, 1.0, 1.0);
fastuidraw_glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

// blit the contents of m_surface to the default framebuffer with nearest filtering
mSurface->blit_surface(GL_NEAREST);
...

Any ideas of what could be wrong ?

@krogueintel
Copy link
Contributor

The function blit_surface() copies the contents of the surface to the framebuffer which completely overwrites the contents of the framebuffer; you need to give the PainterSurfaceGL object the white background. This is done by the method clear_color() of PainterSurface: https://intel.github.io/fastuidraw/docs/html/d5/d60/classfastuidraw_1_1_painter_surface.html#a7faefd57636f4c98b13ed6aab6744cab .

@leonsal
Copy link
Author

leonsal commented Jun 16, 2019

It worked, but when I continuously resize the window, the background color alternates between
black and white in a flickering effect. Please see this.

@krogueintel
Copy link
Contributor

You need to set the clear color before Painter::begin(). That function clears the surface with it's clear color.

@krogueintel
Copy link
Contributor

If setting he clear color resolved the issue, we should close it.

@leonsal
Copy link
Author

leonsal commented Jun 17, 2019

It is much better, though there are still some artifacts. I will continue testing. Thanks.

@leonsal leonsal closed this as completed Jun 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants