[osg-users] DatabasePager - A little confused

Alan Ott alan at signal11.us
Tue Sep 30 16:06:58 PDT 2008


After much trying and failing, I think I have a fundamental 
misunderstanding reagarding the DatabasePager. I have looked for 
examples or code snippets and it seems that there are none. So here's 
what I have.

I have a DatabasePager object that I use for terrain. When I need a new 
chunk of terrain, I call requestNodeFile() with the name of the tile of 
terrain that I want, and give it a group node to attach it to. Every 
frame, I check my group nodes to see if they have a piece of terrain 
attached to them (ie: see if the pager paged in the terrain and attached 
it to my group). If a new piece of terrain has been loaded, I then 
perform my initialization on it (lookup switch nodes, etc), and attach 
it to my main scene. This gets the job done.

The problem now, is that every time a new tile is attached to the main 
scene, the next frame takes a long time, and I have a missed frame. This 
has to do with the new tile getting compiled (texture sent to OpenGL, 
etc) when it's drawn the first time. To overcome this, I want 
DatabasePager to do this for me, which it seems to be able to support, 
but everything I try doesn't work in one way or another. I have 
something like the following (roughly):

// Set up the pager
pager = osgDB::DatabasePager::create();
pager->setCompileGLObjectsForContextID (0, true);

// My composite viewer
osgViewer::CompositeViewer *viewer = new osgViewer::CompositeViewer;

// Then for each View I have something like this.
view = new osgViewer::View;

So in this case, only what gets requested the first frame (before the 
first draw) gets paged in. Anything requested after that never gets 
loaded. If I take out the call to setCompileGLObjectsForContextID(), of 
course, no precompiling happens. Other things happen if I take out the 

 From some of the code regarding PagedLOD's, I get the feeling I might 
be going about this the wrong way entirely, and possibly using 
DatabasePager in a way in which it was not designed.

So I guess my question is, does anyone have anything they can tell me 
about how to use this class? Maybe some code snippets? Anything at all 
would help. I've spent a lot of time searching online and digging 
through the code, so if I've missed something obvious, please go easy :)


More information about the osg-users mailing list