GLvoid FrameBufferObject::attachDepth(GLuint width, GLuint height) { std::shared_ptr<Texture> depth = std::make_shared<Texture>(getGLContext(), width, height, GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, GL_LINEAR, GL_LINEAR, GL_REPLACE, GL_REPEAT); attachDepth(depth); }
/** * Process any change in depth setup. * The clauses could cause the attachments to be bound every frame * but since we only end up in this function when something has * changed this wount happen. */ void SoXipFbo::processDepthMods() { if (mFboMod.hasModDepth) { if (mIsDepthAllocated) deallocateInternalDepth(); attachDepth(); //SoDebugError::postInfo("SoXipFbo", "Attached external depth"); } else if (!mFboMod.hasModDepth) { if (!mIsDepthAllocated) { allocateInternalDepth(); attachDepth(); //SoDebugError::postInfo("SoXipFbo", "Attached internal depth"); } } }
bool ccFrameBufferObject::initDepth(GLint wrapParam/*=GL_CLAMP_TO_BORDER*/, GLenum internalFormat/*=GL_DEPTH_COMPONENT32*/, GLint minMagFilter/*=GL_NEAREST*/, GLenum target/*=GL_TEXTURE_2D*/) { if (!m_isValid || m_fboId == 0) { assert(false); return false; } if (!start()) { return false; } //create the depth texture m_glFunc.glPushAttrib(GL_ENABLE_BIT); m_glFunc.glEnable(GL_TEXTURE_2D); GLuint texID = 0; m_glFunc.glGenTextures(1, &texID); m_glFunc.glBindTexture(target, texID); m_glFunc.glTexParameteri(target, GL_TEXTURE_WRAP_S, wrapParam); m_glFunc.glTexParameteri(target, GL_TEXTURE_WRAP_T, wrapParam); m_glFunc.glTexParameteri(target, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE); m_glFunc.glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_NONE); m_glFunc.glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minMagFilter); m_glFunc.glTexParameteri(target, GL_TEXTURE_MAG_FILTER, minMagFilter); m_glFunc.glTexImage2D (target, 0, internalFormat, m_width, m_height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, 0); m_glFunc.glBindTexture (target, 0); m_glFunc.glPopAttrib(); if (attachDepth(texID, true, target)) { return true; } else { m_glFunc.glDeleteTextures(1, &texID); return false; } }
void GLtarget::attachDepth(Target* depth) { AX_ASSERT(depth->isTexture()); AX_ASSERT(depth->isDepthFormat()); GLtarget* gldepth = dynamic_cast<GLtarget*>(depth); attachDepth(gldepth); }