OffscreenRenderer Problem

OffscreenRenderer Problem

Post by Volker Enderlei » Fri, 09 May 2003 22:50:15



Hi all,

I'm using the ExaminerViewer to display the scene and the
OffscreenRenderer to get bitmaps from a scene for the creation of an AVI
movie. Running the renderer first and then the OffscreenRenderer after
some time my whole memory is eaten up and the app crashes with a memory
fault. If I stop the process early enough, my AVI file is written
properly. Closing the ExaminerViewer frees all memory correctly.
Doing the same procedure but creating single bitmaps with the
BigImageRenderer instead of the AVI file does not show this behavior.

The OffscreenRenderer is constructed once and reused every time.

the interesting part of the code follows

/* template because:
     SoBigImageRenderer and SoOffscreenRenderer are not derived from
each other but
         they are nearly equivalent (except getDC())
*/
template<class T>
BOOL OffscreenRenderScene(T *&rpRenderer, SoWinRenderArea *pViewer,
LPSIZE lpSize, int nNumPasses)
{
        ASSERT( pViewer );
        if( ! pViewer )
                return FALSE;

        // define a viewport region
        SbViewportRegion vpr( lpSize->cx, lpSize->cy );
        vpr.setWindowSize( lpSize->cx, lpSize->cy );

        // init the offscreen renderer
        if( NULL == rpRenderer )
        {
                rpRenderer = new T( vpr );
                ASSERT(rpRenderer);
        } else {
                // reset size in the case of no construction
                rpRenderer->setViewportRegion( vpr );
        }

        // set the right size for RA
        SoGLRenderAction GLRA( vpr );
        rpRenderer->setGLRenderAction( &GLRA );

        // setting from user request
        if( nNumPasses > 0 )
        {
                GLRA.setNumPasses( nNumPasses );
                GLRA.setSmoothing( TRUE );
        }

        // set somethings from the real viewer
        rpRenderer->setBackgroundColor(
pViewer->getSceneManager()->getBackgroundColor() );
        GLRA.setTransparencyType(
pViewer->getGLRenderAction()->getTransparencyType() );

        // render the real shown scenegraph offscreen
        rpRenderer->render( pViewer->getSceneManager()->getSceneGraph() );

        return TRUE;    // do not forget to delete rpRenderer outside !!!!

Quote:}

HDC CViewer::GetBitmapDC(LPSIZE lpSize, int nNumPasses)
{
        VERIFY( OffscreenRenderScene<SoOffscreenRenderer>( m_pVideoScreen,
m_pViewer, lpSize, nNumPasses ) );

        return m_pVideoScreen->getDC();

Quote:}

BOOL CDlgRecorder::GetCurrentBitmap(CBitmap &bitmap, int &nColorDepth)
{
        CSize size( m_nPicWidth, m_nPicHeight );
        CRect rect( CPoint(0, 0), size );
        CDC *pViewerDC;
        CDC memory;
        HDC hDC;
        int iPixel, iDeviceCaps;

        // get the dc of the rendered image
        hDC = m_pIvViewer->m_pViewer->GetBitmapDC( &size, m_nAA );
        ASSERT( hDC );

        pViewerDC = CDC::FromHandle( hDC );
        ASSERT( pViewerDC );

        nColorDepth = iPixel = pViewerDC->GetDeviceCaps( BITSPIXEL );
        iDeviceCaps = pViewerDC->GetDeviceCaps( RASTERCAPS  );

        VERIFY( memory.CreateCompatibleDC( pViewerDC ) );
        VERIFY( bitmap.CreateCompatibleBitmap( pViewerDC, rect.Width(),
rect.Height() ) );

        CBitmap* pOldBitmap = memory.SelectObject( &bitmap );
        memory.FillSolidRect( rect, pViewerDC->GetBkColor() );

        if ( iDeviceCaps & RC_BITBLT )              // check, if device is capable of
stretching
                memory.BitBlt(  rect.left, rect.top, rect.Width(), rect.Height(),
pViewerDC, 0, 0, SRCCOPY );

        memory.SelectObject( pOldBitmap );

        return TRUE;

Quote:}

Thanks for all input on this

Cheers Volker

--
Volker Enderlein                 Institut fuer Mechatronik e.V. an der
phone: +49 (0)371 5314680        Technischen Universitaet Chemnitz
fax  : +49 (0)371 5314669        Reichenhainer Strasse 88

 
 
 

OffscreenRenderer Problem

Post by Volker Enderlei » Fri, 09 May 2003 22:51:43


Oops, forgot to mention it

TGS OIV 3.1.1, W2K

Cheers Volker

--
Volker Enderlein                 Institut fuer Mechatronik e.V. an der
phone: +49 (0)371 5314680        Technischen Universitaet Chemnitz
fax  : +49 (0)371 5314669        Reichenhainer Strasse 88


 
 
 

1. Transparency in OffScreenRenderer

I want SoOffScreenRender to use
transparency-type Sorted blended.

In Inventor Menter, p 254 it's written:

<<<<<<<<<<<<
The render area provides the following:
...
Certain controls, such as the type of transparency
and the amount of antialising.
<<<<<<<<<<<<

Does this meen that transparency-type are not part
of the OpenGL state ?

The SoOffScreenRenderer does not provide methods for
setting the transparency-type.

Is there a way to do this ?
Is there a default value for the SoOffScreenRender

Regards

Even Oscar Andersen

2. need help altering image...

3. Transparency and OffscreenRenderer

4. how ?

5. X Pixmaps, OffScreenRenderer

6. MetaReyes Muscle Bulging??

7. Problems..Problems..Problems

8. halfedge documentation

9. UDO importation problem/POV-ray rendering problem?

10. (new Problems) FINAL: 8-bit colormap problems

11. TEXT PROBLEM: Unwanted grey box behind text and other problems

12. problem with rotating objects and other problems