[osg-users] Fast cycling of textured rectangles

Christoph Heindl christoph.heindl at gmail.com
Sun Nov 15 06:58:44 PST 2015


Hi Sebastian,

thanks for coming back to me.

Changing texture coordinates or switching binding is fast enough.
>

Will give that a try for sure! I guess the reason I'm trying to still push
further is to understand how to translate raw OpenGL to osg.


> Rasterizing has to be done in any case you want to put it to screen.
>

I'm not so sure here. Assuming a static scene with only three viewpoints
,couldn't I render each viewpoint to an 'image' ? Then depending on the
user's choice all I would have to do is copy the pixels of the image to the
screen. That would not require rasterization, would it?

The way I'd like to implement this is to render each CPU image using a
textured quad to a custom FBO with a renderbuffer attached. Then, upon user
request copy the pixels of the FBO to the default DRAW buffer.

Here's a sketch in raw OpenGL

// Initialization: Called n-times for each image to be pre-rendered.
GLuint uploadImageGPU(const char *imgdata)
{
    GLuint fb;

    glGenFramebuffers(1, &fb);
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fb);

    GLuint rb;
    glGenRenderbuffers(1,&rb);
    glBindRenderbuffer(GL_RENDERBUFFER, rb);
    glRenderbufferStorage(GL_RENDERBUFFER,GL_RGBA8, resX, resY);

    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_RENDERBUFFER, rb);
    // Check state...

    // Generate textured quad
    glTexImage2D(GL_TEXTURE_2D, ..., imgdata);
    glBegin(GL_QUADS);
        // ... Skipped for readability
    glEnd();

    return fb;
}

// Run-time: Quickly switch between pre-rendered images (textured quads)
void showImageGPU(GLuint fbo)
{
    glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
    glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
    glBlitFramebuffer(0, 0, resX, resY, 0, 0, resX, resY,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
    // Swap buffers, glFinish();
}

As I would like to use the convenience of osg as far as setting up windows
and other things, I would love to translate this to osg if possible.

Best,
Christoph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20151115/6474d569/attachment-0002.htm>


More information about the osg-users mailing list