Changed the used framebuffer object extension from ARB_framebuffer_object to EXT_framebuffer_object (compatibility reasons).
This commit is contained in:
parent
e13f862145
commit
f615c462a2
|
@ -56,25 +56,25 @@ void OPENGL_COMPOSITOR::Initialize()
|
||||||
|
|
||||||
// We need framebuffer objects for drawing the screen contents
|
// We need framebuffer objects for drawing the screen contents
|
||||||
// Generate framebuffer and a depth buffer
|
// Generate framebuffer and a depth buffer
|
||||||
glGenFramebuffers( 1, &m_framebuffer );
|
glGenFramebuffersEXT( 1, &m_framebuffer );
|
||||||
glBindFramebuffer( GL_FRAMEBUFFER, m_framebuffer );
|
glBindFramebufferEXT( GL_FRAMEBUFFER, m_framebuffer );
|
||||||
m_currentFbo = m_framebuffer;
|
m_currentFbo = m_framebuffer;
|
||||||
|
|
||||||
// Allocate memory for the depth buffer
|
// Allocate memory for the depth buffer
|
||||||
// Attach the depth buffer to the framebuffer
|
// Attach the depth buffer to the framebuffer
|
||||||
glGenRenderbuffers( 1, &m_depthBuffer );
|
glGenRenderbuffersEXT( 1, &m_depthBuffer );
|
||||||
glBindRenderbuffer( GL_RENDERBUFFER, m_depthBuffer );
|
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_depthBuffer );
|
||||||
|
|
||||||
// Use here a size of 24 bits for the depth buffer, 8 bits for the stencil buffer
|
// Use here a size of 24 bits for the depth buffer, 8 bits for the stencil buffer
|
||||||
// this is required later for anti-aliasing
|
// this is required later for anti-aliasing
|
||||||
glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH_STENCIL, m_width, m_height );
|
glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL, m_width, m_height );
|
||||||
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT,
|
||||||
GL_RENDERBUFFER, m_depthBuffer );
|
GL_RENDERBUFFER_EXT, m_depthBuffer );
|
||||||
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
|
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT,
|
||||||
GL_RENDERBUFFER, m_depthBuffer );
|
GL_RENDERBUFFER_EXT, m_depthBuffer );
|
||||||
|
|
||||||
// Unbind the framebuffer, so by default all the rendering goes directly to the display
|
// Unbind the framebuffer, so by default all the rendering goes directly to the display
|
||||||
glBindFramebuffer( GL_FRAMEBUFFER, DIRECT_RENDERING );
|
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, DIRECT_RENDERING );
|
||||||
m_currentFbo = 0;
|
m_currentFbo = 0;
|
||||||
|
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
|
@ -119,50 +119,45 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
|
||||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||||
|
|
||||||
// Bind the texture to the specific attachment point, clear and rebind the screen
|
// Bind the texture to the specific attachment point, clear and rebind the screen
|
||||||
glBindFramebuffer( GL_FRAMEBUFFER, m_framebuffer );
|
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_framebuffer );
|
||||||
m_currentFbo = m_framebuffer;
|
m_currentFbo = m_framebuffer;
|
||||||
glFramebufferTexture2D( GL_FRAMEBUFFER, attachmentPoint, GL_TEXTURE_2D, textureTarget, 0 );
|
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachmentPoint, GL_TEXTURE_2D, textureTarget, 0 );
|
||||||
|
|
||||||
// Check the status, exit if the framebuffer can't be created
|
// Check the status, exit if the framebuffer can't be created
|
||||||
GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER );
|
GLenum status = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
|
||||||
|
|
||||||
if( status != GL_FRAMEBUFFER_COMPLETE )
|
if( status != GL_FRAMEBUFFER_COMPLETE_EXT )
|
||||||
{
|
{
|
||||||
switch( status )
|
switch( status )
|
||||||
{
|
{
|
||||||
case GL_FRAMEBUFFER_UNDEFINED:
|
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
|
||||||
wxLogFatalError( wxT( "Target is the default framebuffer, "
|
|
||||||
"but the default framebuffer does not exist." ) );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
|
||||||
wxLogFatalError( wxT( "Cannot create the framebuffer." ) );
|
wxLogFatalError( wxT( "Cannot create the framebuffer." ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
|
||||||
wxLogFatalError( wxT( "The framebuffer attachment points are incomplete." ) );
|
wxLogFatalError( wxT( "The framebuffer attachment points are incomplete." ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
|
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
|
||||||
wxLogFatalError( wxT( "The framebuffer does not have at least "
|
wxLogFatalError( wxT( "The framebuffer does not have at least "
|
||||||
"one image attached to it." ) );
|
"one image attached to it." ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
|
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
|
||||||
wxLogFatalError( wxT( "The framebuffer read buffer is incomplete." ) );
|
wxLogFatalError( wxT( "The framebuffer read buffer is incomplete." ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_UNSUPPORTED:
|
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
|
||||||
wxLogFatalError( wxT( "The combination of internal formats of the attached images "
|
wxLogFatalError( wxT( "The combination of internal formats of the attached images "
|
||||||
"violates an implementation-dependent set of restrictions." ) );
|
"violates an implementation-dependent set of restrictions." ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
|
||||||
wxLogFatalError( wxT( "GL_RENDERBUFFER_SAMPLES is not the same "
|
wxLogFatalError( wxT( "GL_RENDERBUFFER_SAMPLES is not the same "
|
||||||
"for all attached renderbuffers" ) );
|
"for all attached renderbuffers" ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
|
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
|
||||||
wxLogFatalError( wxT( "Framebuffer incomplete layer targets errors." ) );
|
wxLogFatalError( wxT( "Framebuffer incomplete layer targets errors." ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -177,7 +172,7 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer()
|
||||||
ClearBuffer();
|
ClearBuffer();
|
||||||
|
|
||||||
// Return to direct rendering (we were asked only to create a buffer, not switch to one)
|
// Return to direct rendering (we were asked only to create a buffer, not switch to one)
|
||||||
glBindFramebuffer( GL_FRAMEBUFFER, DIRECT_RENDERING );
|
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, DIRECT_RENDERING );
|
||||||
m_currentFbo = DIRECT_RENDERING;
|
m_currentFbo = DIRECT_RENDERING;
|
||||||
|
|
||||||
// Store the new buffer
|
// Store the new buffer
|
||||||
|
@ -196,12 +191,12 @@ void OPENGL_COMPOSITOR::SetBuffer( unsigned int aBufferHandle )
|
||||||
// Change the rendering destination to the selected attachment point
|
// Change the rendering destination to the selected attachment point
|
||||||
if( aBufferHandle == DIRECT_RENDERING )
|
if( aBufferHandle == DIRECT_RENDERING )
|
||||||
{
|
{
|
||||||
glBindFramebuffer( GL_FRAMEBUFFER, DIRECT_RENDERING );
|
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, DIRECT_RENDERING );
|
||||||
m_currentFbo = DIRECT_RENDERING;
|
m_currentFbo = DIRECT_RENDERING;
|
||||||
}
|
}
|
||||||
else if( m_currentFbo != m_framebuffer )
|
else if( m_currentFbo != m_framebuffer )
|
||||||
{
|
{
|
||||||
glBindFramebuffer( GL_FRAMEBUFFER, m_framebuffer );
|
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_framebuffer );
|
||||||
m_currentFbo = m_framebuffer;
|
m_currentFbo = m_framebuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +228,7 @@ void OPENGL_COMPOSITOR::DrawBuffer( unsigned int aBufferHandle )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch to the main framebuffer and blit the scene
|
// Switch to the main framebuffer and blit the scene
|
||||||
glBindFramebuffer( GL_FRAMEBUFFER, DIRECT_RENDERING );
|
glBindFramebufferEXT( GL_FRAMEBUFFER, DIRECT_RENDERING );
|
||||||
m_currentFbo = DIRECT_RENDERING;
|
m_currentFbo = DIRECT_RENDERING;
|
||||||
|
|
||||||
// Depth test has to be disabled to make transparency working
|
// Depth test has to be disabled to make transparency working
|
||||||
|
@ -278,8 +273,8 @@ void OPENGL_COMPOSITOR::clean()
|
||||||
{
|
{
|
||||||
wxASSERT( m_initialized );
|
wxASSERT( m_initialized );
|
||||||
|
|
||||||
glDeleteFramebuffers( 1, &m_framebuffer );
|
glDeleteFramebuffersEXT( 1, &m_framebuffer );
|
||||||
glDeleteRenderbuffers( 1, &m_depthBuffer );
|
glDeleteRenderbuffersEXT( 1, &m_depthBuffer );
|
||||||
|
|
||||||
OPENGL_BUFFERS::const_iterator it;
|
OPENGL_BUFFERS::const_iterator it;
|
||||||
|
|
||||||
|
|
|
@ -52,10 +52,11 @@ OPENGL_GAL::OPENGL_GAL( wxWindow* aParent, wxEvtHandler* aMouseListener,
|
||||||
nonCachedManager( false ),
|
nonCachedManager( false ),
|
||||||
overlayManager( false )
|
overlayManager( false )
|
||||||
{
|
{
|
||||||
|
// Create the OpenGL-Context
|
||||||
|
glContext = new wxGLContext( this );
|
||||||
parentWindow = aParent;
|
parentWindow = aParent;
|
||||||
mouseListener = aMouseListener;
|
mouseListener = aMouseListener;
|
||||||
paintListener = aPaintListener;
|
paintListener = aPaintListener;
|
||||||
glContext = NULL;
|
|
||||||
|
|
||||||
// Initialize the flags
|
// Initialize the flags
|
||||||
isGlewInitialized = false;
|
isGlewInitialized = false;
|
||||||
|
@ -112,9 +113,6 @@ OPENGL_GAL::~OPENGL_GAL()
|
||||||
|
|
||||||
void OPENGL_GAL::BeginDrawing()
|
void OPENGL_GAL::BeginDrawing()
|
||||||
{
|
{
|
||||||
if( !glContext )
|
|
||||||
glContext = new wxGLContext( this );
|
|
||||||
|
|
||||||
SetCurrent( *glContext );
|
SetCurrent( *glContext );
|
||||||
|
|
||||||
clientDC = new wxClientDC( this );
|
clientDC = new wxClientDC( this );
|
||||||
|
@ -935,7 +933,7 @@ void OPENGL_GAL::initGlew()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Framebuffers have to be supported
|
// Framebuffers have to be supported
|
||||||
if( !GLEW_ARB_framebuffer_object )
|
if( !GLEW_EXT_framebuffer_object )
|
||||||
{
|
{
|
||||||
wxLogError( wxT( "Framebuffer objects are not supported!" ) );
|
wxLogError( wxT( "Framebuffer objects are not supported!" ) );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
|
|
Loading…
Reference in New Issue