Hi everyone, I'm trying to setup an pure OpenGL FBO with render to texture target in an OSG drawable. But I just can't figure out how to do that "properly" (eg. how to "isolate those pure openGL calls from the rest of the OSG scene).
in my drawa implementation I just have: virtual void drawImplementation(osg::RenderInfo& info) const { OSG_NOTICE << "Drawing PingPongDrawable..."; osg::State* state = info.getState(); const unsigned int contextID = state->getContextID(); if(!_initialized && !init(contextID,*state)) { OSG_WARN << "Failed FBO setup!"; return; } state->checkGLErrors("end of PingPongDrawable drawing."); } So i'm really just calling an "init" function once to jus try to *create* an FBO... I didn't even start using it..., the code of the init function is as follow: bool init(unsigned int contextID, osg::State& state) const { const FBOExtensions* fbo_ext = FBOExtensions::instance(contextID,true); const osg::Texture2DArray::Extensions* t2darray_ext = osg::Texture2DArray::getExtensions(contextID,true); // Push attribs to avoid collisions with existing OSG scene ? glPushAttrib(GL_VIEWPORT_BIT | GL_COLOR_BUFFER_BIT | GL_TEXTURE_BIT | GL_ENABLE_BIT); state.checkGLErrors("Before PPD init."); // Prepare the target texture for the FBO: state.setActiveTextureUnit(1); state.checkGLErrors("Activating texture slot 1"); int FFT_SIZE=256; GLuint fftaTex = 0; glGenTextures(1, &fftaTex); glBindTexture(GL_TEXTURE_2D_ARRAY_EXT, fftaTex); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameterf(GL_TEXTURE_2D_ARRAY_EXT, GL_TEXTURE_MAX_ANISOTROPY_EXT, 16); t2darray_ext->glTexImage3D(GL_TEXTURE_2D_ARRAY_EXT, 0, GL_RGBA16F_ARB, FFT_SIZE, FFT_SIZE, 5, 0, GL_RGBA, GL_FLOAT, NULL); fbo_ext->glGenerateMipmap(GL_TEXTURE_2D_ARRAY_EXT); state.checkGLErrors("preparing target texture"); // Initialize the FBO fbo_ext->glGenFramebuffers(1, &_fftFbo); state.checkGLErrors("Generating FBO"); fbo_ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, _fftFbo); state.checkGLErrors("Bind Framebuffer in init."); #ifdef ATTACH_TEXTURE fbo_ext->glFramebufferTexture(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, fftaTex, 0); state.checkGLErrors("FramebufferTexture setup"); #endif GLuint fboId = state.getGraphicsContext() ? state.getGraphicsContext()->getDefaultFboId() : 0; fbo_ext->glBindFramebuffer(GL_FRAMEBUFFER_EXT, fboId); if(fbo_ext->glCheckFramebufferStatus(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) { OSG_WARN << "Error while setting up Pingpong FBO."; } state.checkGLErrors("end of Framebuffer settings"); glBindTexture( GL_TEXTURE_2D_ARRAY_EXT, 0 ); glPopAttrib(); _initialized = true; return true; } Adding such a drawable in my scene, i don't have any problem as long as ATTACH_TEXTURE is *undefined*. But when I define this, I still don't have any error reported by the drawable itself (all the checkGLErrors I inserted). But then getcontinous list of " Warning: detected OpenGL error 'invalid operation' at after RenderBin::draw(..)" messages :-( => Any idea what I'm doing wrong here ? How can I "enforce" the isolation between those openGL calls and what's left from the OSG scene ? after all, since this init function is called only once, there should not be any continous warning report if it didn't have a side effect outside of this drawable encapsulation... Thanks for you help !! I really feel desperated now... :'( Manu.
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org