[osg-users] Multiple cameras with setRenderOrder(PRE_RENDER, i)

Paul Martz pmartz at skew-matrix.com
Sun Nov 22 13:36:38 PST 2009


Ross Bohner wrote:
> Hi,
> 
> Thank you for the code snippet.  Looking it over I see two differences from my implementation which have been giving me a headache.  These are not necessarily related to camera render orders so it might be appropriate to send these as separate threads.  
> 
> First difference from your code and mine is the lack of you needing to allocate an image to the render in order to place the texture within a stateset:

Consider the following OpenGL call:
     glTexImage2D(..., width, height, ..., NULL );
Note I'm passing in a width and height but no data. According to the 
OpenGL spec, this allocates an undefined texture image with dimensions 
width x height.

This is essentially what my posted example is causing to happen when I 
create an osg::Texture2D with width and height, but no osg::Image data. 
I don't care that the texture is undefined, because my app initializes 
it in the first render pass.

> In my experience, this is required or else a seg fault occurs when the draw traversal references "_texture".  I am confused on how you are able to pass the texture without allocating an image inside the texture.  I have included a code snippet below to fully clarify what I see occurring.

Try my code; if it segfaults, let me know. :-)

> The second difference is your code uses non power of 2 dimensions for your texture to be rendered by your camera.  Whenever I have tried to do this I have run into the error : 
> "Warning: detected OpenGL error 'invalid value' after RenderBin::draw(,)"  during every draw call to the geometry containing the texture

Wow. GLView shows that even the old GeForce 6xxx series supports the 
NPOT extension. Do you have really old hardware, or perhaps you haven't 
updated your driver recently?

Your code is incomplete so it's impossible to tell what you're doing. 
You have a pre-render camera with a texture attached; you also have a 
Geode to render a textured primitive. But I don't see how your code adds 
them to a scene graph. Nor do I see anything added to your pre-render 
camera, so as far as I can see there is nothing for it to render.

Have you tried compiling and running the code I sent you? How about the 
osgprerender example? (osgprerender is a little complex, which is why I 
wrote the more concise rtt.cpp example that I posted.)
    -Paul



More information about the osg-users mailing list