COffscreencontext difficulties (from 3.6 to 4.3)[SOLVED]

A user interface toolkit mainly for audio plug-ins (VST, AudioUnit, etc).
Post Reply
xavier
Posts: 9
Joined: Thu Jul 21, 2016 9:46 am

COffscreencontext difficulties (from 3.6 to 4.3)[SOLVED]

Post 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
Last edited by xavier on Thu Sep 08, 2016 2:05 pm, edited 1 time in total.

Arne Scheffler
Posts: 373
Joined: Mon Jun 20, 2016 7:53 am

Re: COffscreencontext difficulties (from 3.6 to 4.3)

Post by Arne Scheffler »

Have you read the documentation for COffscreenContext ?

xavier
Posts: 9
Joined: Thu Jul 21, 2016 9:46 am

Re: COffscreencontext difficulties (from 3.6 to 4.3)

Post 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

Arne Scheffler
Posts: 373
Joined: Mon Jun 20, 2016 7:53 am

Re: COffscreencontext difficulties (from 3.6 to 4.3)

Post 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

 */

xavier
Posts: 9
Joined: Thu Jul 21, 2016 9:46 am

Re: COffscreencontext difficulties (from 3.6 to 4.3)

Post by xavier »

Thanks Arne,

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

Best regards
Xavier

xavier
Posts: 9
Joined: Thu Jul 21, 2016 9:46 am

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

Post 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

Post Reply