Thanks for the reply guys.
This is how I create my selection buffer. How would I change that to create the buffer bound to the default depth buffer? If I don’t want the existing depth information I can clear it just as easily, as making a call to have it preserved. Using the existing depth buffer would be more memory efficient, and I don’t know, but it seems that clearing it would be at least as fast as blitting.
void wxBFXCanvas::setSelectionBuffer()
{
if(m_SBO != 0) // delete current selection buffer if it exists
{
glDeleteFramebuffers(1, &m_SBO);
glDeleteRenderbuffers(1, &m_SBODepth);
glDeleteRenderbuffers(1, &m_SBOPixels);
m_SBO = 0;
}
// create depth renderbuffer
glGenRenderbuffers(1, &m_SBODepth);
glBindRenderbuffer(GL_RENDERBUFFER, m_SBODepth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_CanvasWidth, m_CanvasHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_SBODepth);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
// create pixel renderbuffer
glGenRenderbuffers(1, &m_SBOPixels);
glBindRenderbuffer(GL_RENDERBUFFER, m_SBOPixels);
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB, m_CanvasWidth, m_CanvasHeight);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_SBOPixels);
glBindRenderbuffer(GL_RENDERBUFFER, 0);
// create framebuffer object
glGenFramebuffers(1, &m_SBO);
glBindFramebuffer(GL_FRAMEBUFFER, m_SBO);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, m_SBOPixels);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_SBODepth);
// Check that things seem to have worked so far
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if (status != GL_FRAMEBUFFER_COMPLETE)
{
wxMessageBox(_T("Selection buffer creation failed"),_T("Oops, Bad Cr*p...."));
glBindFramebuffer(GL_FRAMEBUFFER, 0);
m_SBODirty = false;
m_SBO = 0;
return;
}
glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
m_SBODirty = false;
Refresh(false); // force a screen refresh
}
Notice the title of the error message box. I think that’s the bit that was causing the forum code to choke. My Bad!