Page 1 of 1

COffscreencontext difficulties (from 3.6 to 4.3)[SOLVED]

Posted: Mon Sep 05, 2016 1:57 pm
by xavier
Hi,

I have difficulties using COffscreencontext after updating 3.6 to 4.3

In a component, I'm using COffscreencontext for drawing the full frame of the current GUI :

...
frame->draw(TotalOffScreen );
...

Then I copy a part of this Offscreencontext to an other one :

..
TotalOffScreen->copyFrom (mPartOffScreen, SizePart,Point);
..

Then, when needed, I draw a part of this context in the current draw context :
..
mPartOffScreen->copyFrom (pContext, rect,Point);
..

With 3.6, everything works fine but with 4.3, I only can see a black rectangle (default Offscrenn color is black)


I tried to use a static bitmap, but without success, same black drawing

What am I missing there ?
Thanks in advance for your help

Best
Xavier

Re: COffscreencontext difficulties (from 3.6 to 4.3)

Posted: Mon Sep 05, 2016 3:26 pm
by Arne Scheffler
Have you read the documentation for COffscreenContext ?

Re: COffscreencontext difficulties (from 3.6 to 4.3)

Posted: Mon Sep 05, 2016 3:55 pm
by xavier
I've read the deoxygen doc, on which there is only an example for drawing a line (I tried it and that works)

I read that COffscreenContest is not working the same n 4.x than in 3.6, but without more explanation or sample (just saying it's no use for reducing flicker, but that's not my purpose)

Maybe there is an other document, but I didn't find it (I'm searching around since a few days though)

Best
Xavier

Re: COffscreencontext difficulties (from 3.6 to 4.3)

Posted: Mon Sep 05, 2016 4:59 pm
by Arne Scheffler
from coffscreencontext.h :

Code: Select all

//-----------------------------------------------------------------------------
// COffscreenContext Declaration
//! @brief A draw context using a bitmap as it's back buffer
/*! @class COffscreenContext
There are two usage scenarios :
@section offscreen_usage1 Drawing into a bitmap and then push the contents into another draw context

@code
COffscreenContext* offscreen = COffscreenContext::create (frame, 100, 100);
if (offscreen)
{
	offscreen->beginDraw ();
	// ... 
	// draw into offscreen
	// ...
	offscreen->endDraw ();
	offscreen->copyFrom (otherContext, destRect);
	offscreen->forget ();
}
@endcode

@section offscreen_usage2 Drawing static content into a bitmap and reuse the bitmap for drawing

@code
if (cachedBitmap == 0)
{
	COffscreenContext* offscreen = COffscreenContext::create (frame, 100, 100);
	if (offscreen)
	{
		offscreen->beginDraw ();
		// ... 
		// draw into offscreen
		// ...
		offscreen->endDraw ();
		cachedBitmap = offscreen->getBitmap ();
		if (cachedBitmap)
			cachedBitmap->remember ();
		offscreen->forget ();
	}
}
if (cachedBitmap)
{
	// ...
}

@endcode

 */

Re: COffscreencontext difficulties (from 3.6 to 4.3)

Posted: Tue Sep 06, 2016 6:53 am
by xavier
Thanks Arne,

That's the document I found, read and tried before.
Anyway, I will try again

Best regards
Xavier

Re: COffscreencontext difficulties (from 3.6 to 4.3)[SOLVED]

Posted: Thu Sep 08, 2016 2:11 pm
by xavier
Everything is working fine, thanks

the trick was to use as much as COffscreenContext than needed, getting the corresponding bitmaps and memorizing them (and not to forget to "remember" them)

(in my 3.6 classes, it was the COffscreenContext pointer which was memorized, instead of the bitmap)

Thanks for your help

Best
Xavier