Am 15.11.2015 18:58, schrieb Christoph Heindl:
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?
Putting anything to the screen is "rasterizing".
Scanning through your example I got what you are trying to achieve. But
seriously I'd call this premature optimization.
For presenting anything to an output device you will have a lot of time
(~16ms at 60Hz), so simply rendering a fullscreen quad with an image
will definitely fit in a frame, so your optimization is not really
useful except for some caching that might occur by uploading the
texture beforehand.
Usually you solve a problem, benchmark it, see if it fits your needs and
optimize it if it doesn't...
Cheers
Sebastian
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
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org