[osg-users] OSG in Gtk3 GLArea

Steve Hardy osgforum at tevs.eu
Tue Jun 5 19:42:19 PDT 2018


So far, the kludge solution is almost working.  I needed to add

    glPixelStorei(GL_PACK_ALIGNMENT, 1);

before glReadPixels() otherwise it broke if the window width wasn't a multiple of 8.

Problems remaining:

1. the aspect ratio does not adjust properly on window size changes, so that the scene just stretches like rubber.

2. there is a truly horrendous amount of copying data.

For (1), I was assuming that 

    camera->setViewport(new osg::Viewport(0,0,width,height));
    camera->setProjectionMatrixAsPerspective(30.0f, 1.*width/height, 1.0f, 10000.0f);

on the slave and main (?) cameras would fix that up, but no.  Maybe there's something cached somewhere, even though I am completely reconstructing the slave camera on each resize.

Any suggestions where to look?

For (2), after the hardware renders the scene, and the PBO is mapped back into userspace RAM, the following copies occur:

- memcpy to the osg::Image data
- image->flipVertical()  since 2D library has Y inverted w.r.t GL.
- copy to a new Python string object
- copy to a new GdkPixbuf object
- copy to the cairo context (that's the Gtk 2D graphics engine).

I think a lot of this could be eliminated by creating the GdkPixbuf directly from the PBO map, flipping the row order in this copy.  Although it performs OK, we have to run on low-end systems.

Cheers,
Steve

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=73985#73985







More information about the osg-users mailing list