Hello Marco,
Marco Spoerl wrote:
Dirk
Attached you'll find a small sample application which mimics the
problematic part of my application.
thank you for sending the program. For testing I converted it to glut
(please see attached) and ran it under valgrind. The only significant
leak is 262,140 bytes in the driver, but that seems to be present
independent of the number of iterations in the leak() function.
Could you try the glut program [1] on your side, so we can see if it
still reproduces the problem for you ?
Thanks,
Carsten
[1] for convenience I turned it into a test program that lives in
Source/WindowSystem/GLUT
#include <OSGConfig.h>
#include <OSGRefPtr.h>
#include <OSGGLUTWindow.h>
#include <OSGRenderAction.h>
#include <OSGPerspectiveCamera.h>
#include <OSGViewport.h>
#include <OSGPassiveBackground.h>
#include <OSGTransform.h>
#include <OSGGroup.h>
#include <OSGOrthographicCamera.h>
#include <OSGFBOViewport.h>
#include <OSGSolidBackground.h>
#include <OSGImage.h>
#include <OSGTextureChunk.h>
#include <OSGGLUT.h>
//-----------------------------------------------------------------------------
static const int TEX_SIZE = 256;
//-----------------------------------------------------------------------------
OSG::GLUTWindowRefPtr g_pWindow(OSG::NullFC);
OSG::RenderAction* g_pAction = 0;
OSG::FBOViewportRefPtr g_pFboViewport(OSG::NullFC);
void reshape(int w, int h);
void display(void );
void key (unsigned char key, int, int);
void onCreateMain(int *argc, char *argv[])
{
// OSG init
OSG::osgInit(*argc, argv);
// GLUT init
glutInit(argc, argv);
glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
int winid = glutCreateWindow("OpenSG");
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutKeyboardFunc(key);
g_pWindow = OSG::GLUTWindow ::create();
g_pAction = OSG::RenderAction::create();
// create viewport
OSG::NodePtr pCameraBeacon = OSG::makeCoredNode<OSG::Transform>();
OSG::PerspectiveCameraPtr pPerspectiveCam = OSG::PerspectiveCamera::create();
OSG::beginEditCP(pPerspectiveCam);
pPerspectiveCam->setBeacon(pCameraBeacon);
pPerspectiveCam->setFov(OSG::deg2rad(90));
pPerspectiveCam->setNear(100);
pPerspectiveCam->setFar(1000);
OSG::endEditCP(pPerspectiveCam);
OSG::PassiveBackgroundPtr pPassiveBackground = OSG::PassiveBackground::create();
OSG::NodePtr pDummyRoot = OSG::makeCoredNode<OSG::Group>();
OSG::ViewportPtr pViewport = OSG::Viewport::create();
OSG::beginEditCP(pViewport);
pViewport->setCamera(pPerspectiveCam);
pViewport->setBackground(pPassiveBackground);
pViewport->setRoot(pDummyRoot);
pViewport->setSize(0, 0, 1, 1);
OSG::endEditCP(pViewport);
// init OpenSG window
OSG::beginEditCP(g_pWindow);
g_pWindow->addPort(pViewport);
g_pWindow->setId(winid);
g_pWindow->init();
g_pWindow->deactivate();
OSG::endEditCP(g_pWindow);
}
void onCreateFbo()
{
// create nodes
OSG::NodePtr pCameraBeacon = OSG::makeCoredNode<OSG::Transform>();
OSG::NodePtr pGeometryNode = OSG::makeCoredNode<OSG::Group>();
// create root node
OSG::NodePtr pRootNode = OSG::makeCoredNode<OSG::Group>();
OSG::beginEditCP(pRootNode);
pRootNode->addChild(pCameraBeacon);
pRootNode->addChild(pGeometryNode);
OSG::endEditCP(pRootNode);
// create camera
OSG::OrthographicCameraPtr pCamera = OSG::OrthographicCamera::create();
OSG::beginEditCP(pCamera);
pCamera->setBeacon(pCameraBeacon);
pCamera->setNear(-1);
pCamera->setFar(1);
pCamera->setAspect(1);
pCamera->setVerticalSize(TEX_SIZE);
OSG::endEditCP(pCamera);
// create background
OSG::SolidBackgroundPtr pBackground = OSG::SolidBackground::create();
OSG::beginEditCP(pBackground);
pBackground->setColor(OSG::Color3f(1,0,0));
OSG::endEditCP(pBackground);
// create viewport
g_pFboViewport = OSG::FBOViewport::create();
OSG::beginEditCP(g_pFboViewport);
g_pFboViewport->setParent(g_pWindow);
g_pFboViewport->setRoot(pRootNode);
g_pFboViewport->setBackground(pBackground);
g_pFboViewport->setCamera(pCamera);
g_pFboViewport->setSize(0, 0, TEX_SIZE - 1, TEX_SIZE - 1);
g_pFboViewport->setStorageWidth(TEX_SIZE);
g_pFboViewport->setStorageHeight(TEX_SIZE);
g_pFboViewport->setGenCubemaps(false);
g_pFboViewport->setGenDepthmaps(false);
g_pFboViewport->setFboOn(true);
g_pFboViewport->setDirty(true);
OSG::endEditCP(g_pFboViewport);
}
// Standard GLUT callback functions
void display( void )
{
if (g_pWindow != OSG::NullFC)
{
g_pWindow->render(g_pAction);
}
}
void reshape( int w, int h )
{
if (g_pWindow != OSG::NullFC)
{
g_pWindow->resize(w, h);
}
glutPostRedisplay();
}
//-----------------------------------------------------------------------------
void grab(OSG::TextureChunkPtr pTexture)
{
if (g_pFboViewport != OSG::NullFC)
{
OSG::ImagePtr pImage = OSG::Image::create();
OSG::beginEditCP(pImage);
pImage->set(OSG::Image::OSG_RGBA_PF, TEX_SIZE, TEX_SIZE);
OSG::endEditCP(pImage);
OSG::beginEditCP(pTexture, OSG::TextureChunk::ImageFieldMask);
pTexture->setImage(pImage);
OSG::endEditCP(pTexture, OSG::TextureChunk::ImageFieldMask);
g_pAction->setAutoFrustum(false);
g_pAction->setCorrectTwoSidedLighting(false);
g_pAction->setFrustumCulling(false);
g_pAction->setOcclusionCulling(false);
g_pAction->setSmallFeatureCulling(false);
g_pAction->setSortTrans(false);
g_pAction->setStateSorting(false);
g_pAction->setStatistics(false);
g_pAction->setVolumeDrawing(false);
g_pAction->setZWriteTrans(false);
OSG::beginEditCP(g_pFboViewport);
g_pFboViewport->editMFTextures()->push_back(pTexture);
OSG::endEditCP(g_pFboViewport);
g_pFboViewport->render(g_pAction);
OSG::beginEditCP(g_pFboViewport);
g_pFboViewport->editMFTextures()->clear();
OSG::endEditCP(g_pFboViewport);
}
}
//-----------------------------------------------------------------------------
OSG::TextureChunkPtr createTexture()
{
OSG::Real32 maximumAnistropy;
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maximumAnistropy);
maximumAnistropy = OSG::osgMin(maximumAnistropy, OSG::Real32(8.0));
OSG::TextureChunkPtr pTexture = OSG::TextureChunk::create();
OSG::beginEditCP(pTexture);
pTexture->setAnisotropy(maximumAnistropy);
pTexture->setMinFilter(GL_LINEAR);
pTexture->setMagFilter(GL_LINEAR);
pTexture->setWrapS(GL_CLAMP_TO_EDGE);
pTexture->setWrapT(GL_CLAMP_TO_EDGE);
pTexture->setTarget(GL_TEXTURE_2D);
pTexture->setInternalFormat(GL_RGBA8);
OSG::endEditCP(pTexture);
return pTexture;
}
//-----------------------------------------------------------------------------
void leak()
{
std::cout << "calling 'leak'" << std::endl;
OSG::RefPtr<OSG::TextureChunkPtr> pTexture(OSG::NullFC);
for(OSG::UInt32 i = 0; i < 100; ++i)
{
pTexture = createTexture();
grab(pTexture);
}
std::cout << "exiting 'leak'" << std::endl;
}
void
key(unsigned char key, int , int )
{
switch(key)
{
case 27: g_pWindow = OSG::NullFC;
g_pFboViewport = OSG::NullFC;
delete g_pAction;
g_pAction = NULL;
exit(1);
case 'l': leak();
break;
}
glutPostRedisplay();
}
// Initialize GLUT & OpenSG and set up the scene
int main (int argc, char **argv)
{
onCreateMain(&argc, argv);
onCreateFbo();
// GLUT main loop
glutMainLoop();
return 0;
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users