On 07.10.2015 09:27, Gerrit Voß wrote:
>
> a passive background might help. It can take a clear callback
> where you can do the blitting. Another option in there
> is to blit the current framebuffer into an FBO (which is not directly
> what you are looking for). Adding blitting from another FBO should not
> be to difficult, well depending on how accurate the 'what to blit'
> settings have to be. I'll have a look.
>
Great :-)

I'm also playing around with an example with a PolygonBackground, but I 
have problems getting it to run. What I'm trying is to create a viewport
with a PolygonBackground that is painting the texture image from a FBO 
that I have rendered prior to that. In that simple setup the image is 
rendered perfectly fine. However, when I add a shader program chunk to 
the material of the PolygonBackground that shader code is never called.
I debugged the relevant code places where GL_COMPILE_STATUS and 
GL_LINK_STATUS is checked, but the example program did not stop at these 
places. Additionally, I debugged the State::activate(...) function. The 
TextureObjChunk, TextureEnvChunk and the MaterialChunk get activated but 
not so the ShaderProgramChunk.

The poor man's idea with the shader is, that I can adapt the depth 
buffer beside of the color buffer in the fragment shader.

Below you can find part of the example. Could you take a brief look? Is 
shader code in the PolygonBackground forbidden generally? In case it 
helps I can post or upload the complete example code.


However, I would prefer some infrastructure that is easier to setup. 
Maybe we could come up with a FancyBackground that takes a FBO and 
manages the blitting (color, depth, stencil) internally. Especially, I 
do not like a solution involving a shader in the first place.

Best,
Johannes


static void createDynamicViewport()
{
     win->subPortByObj(staticVp);

     ChunkMaterialUnrecPtr mat = ChunkMaterial::create();

     MaterialChunkUnrecPtr matChunk = MaterialChunk::create();
     matChunk->setDiffuse(Color4f(1.f,1.f,1.f,1.f));

     TextureObjChunkUnrecPtr texObjChunk = spSimpleFBO->colorTexObj();

     TextureEnvChunkUnrecPtr texEnvChunk = TextureEnvChunk::create();
     texEnvChunk->setEnvMode(GL_REPLACE);

     ShaderProgramChunkUnrecPtr shaderProgramChunk = 
ShaderProgramChunk::create();

     ShaderProgramUnrecPtr vertShader = ShaderProgram::createVertexShader();
     ShaderProgramUnrecPtr fragShader = 
ShaderProgram::createFragmentShader();

     vertShader->setProgram(vertexShaderStr);
     fragShader->setProgram(fragmentShaderStr);

     fragShader->addUniformVariable("texUnit", 0);

     shaderProgramChunk->addShader(vertShader);
     shaderProgramChunk->addShader(fragShader);

     mat->addChunk(matChunk);
     mat->addChunk(texObjChunk);
     mat->addChunk(texEnvChunk);
     mat->addChunk(shaderProgramChunk);

     PolygonBackgroundUnrecPtr polyBckgnd = PolygonBackground::create();
     polyBckgnd->setMaterial(mat);
     polyBckgnd->setClearColor(true);
     polyBckgnd->setClearDepth(true);
     polyBckgnd->setClearStencilBit(true);
     polyBckgnd->setNormalizedX(true);
     polyBckgnd->setNormalizedY(true);

     polyBckgnd->editMFTexCoords()->push_back(Vec3f(0.f,0.f,0.f));
     polyBckgnd->editMFTexCoords()->push_back(Vec3f(1.f,0.f,0.f));
     polyBckgnd->editMFTexCoords()->push_back(Vec3f(1.f,1.f,0.f));
     polyBckgnd->editMFTexCoords()->push_back(Vec3f(0.f,1.f,0.f));

     polyBckgnd->editMFPositions()->push_back(Pnt2f(0.f,0.f));
     polyBckgnd->editMFPositions()->push_back(Pnt2f(1.f,0.f));
     polyBckgnd->editMFPositions()->push_back(Pnt2f(1.f,1.f));
     polyBckgnd->editMFPositions()->push_back(Pnt2f(0.f,1.f));

     NodeUnrecPtr root = makeCoredNode<Group>();
     root->addChild(dynamicScene);

     mgr->setRoot(root);

     dynamicVp = Viewport::create();
     dynamicVp->setRoot      (rootNode(root));
     dynamicVp->setBackground(polyBckgnd);
     dynamicVp->setCamera    (camera);
     dynamicVp->setSize      (0,0, 1,1);

     mgr->getNavigator()->setViewport(dynamicVp);

     win->addPort(dynamicVp);

     mgr->update();
}



------------------------------------------------------------------------------
Full-scale, agent-less Infrastructure Monitoring from a single dashboard
Integrate with 40+ ManageEngine ITSM Solutions for complete visibility
Physical-Virtual-Cloud Infrastructure monitoring from one console
Real user monitoring with APM Insights and performance trend reports 
Learn More http://pubads.g.doubleclick.net/gampad/clk?id=247754911&iu=/4140
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to