Use core GL function names instead of EXT/ARB.

GLAD aliases most EXT/ARB function names.
This commit is contained in:
Alex Shvartzkop
2026-02-22 14:56:40 +03:00
committed by dsa-t
parent 3fa40e05dc
commit f8cb730edf
6 changed files with 57 additions and 60 deletions
@@ -59,7 +59,7 @@ void RENDER_3D_RAYTRACE_GL::deletePbo()
// Delete PBO if it was created
if( m_openglSupportsVertexBufferObjects )
{
if( glIsBufferARB( m_pboId ) )
if( glIsBuffer( m_pboId ) )
glDeleteBuffers( 1, &m_pboId );
m_pboId = GL_NONE;
@@ -156,18 +156,17 @@ bool RENDER_3D_RAYTRACE_GL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
premultiplyAlpha( m_boardAdapter.m_BgColorBot ) );
// Bind PBO
glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_pboId );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, m_pboId );
// Get the PBO pixel pointer to write the data
uint8_t* ptrPBO = (uint8_t *)glMapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB,
GL_WRITE_ONLY_ARB );
uint8_t* ptrPBO = (uint8_t *)glMapBuffer( GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY );
if( ptrPBO )
{
renderPreview( ptrPBO );
// release pointer to mapping buffer, this initialize the coping to PBO
glUnmapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB );
glUnmapBuffer( GL_PIXEL_UNPACK_BUFFER );
}
glWindowPos2i( m_xoffset, m_yoffset );
@@ -175,13 +174,12 @@ bool RENDER_3D_RAYTRACE_GL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
else
{
// Bind PBO
glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_pboId );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, m_pboId );
if( m_renderState != RT_RENDER_STATE_FINISH )
{
// Get the PBO pixel pointer to write the data
uint8_t* ptrPBO = (uint8_t *)glMapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB,
GL_WRITE_ONLY_ARB );
uint8_t* ptrPBO = (uint8_t *)glMapBuffer( GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY );
if( ptrPBO )
{
@@ -191,7 +189,7 @@ bool RENDER_3D_RAYTRACE_GL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
requestRedraw = true;
// release pointer to mapping buffer, this initialize the coping to PBO
glUnmapBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB );
glUnmapBuffer( GL_PIXEL_UNPACK_BUFFER );
}
}
@@ -209,7 +207,7 @@ bool RENDER_3D_RAYTRACE_GL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glEnable( GL_ALPHA_TEST );
glDrawPixels( m_realBufferSize.x, m_realBufferSize.y, GL_RGBA, GL_UNSIGNED_BYTE, 0 );
glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, 0 );
return requestRedraw;
}
@@ -217,7 +215,7 @@ bool RENDER_3D_RAYTRACE_GL::Redraw( bool aIsMoving, REPORTER* aStatusReporter,
void RENDER_3D_RAYTRACE_GL::initPbo()
{
if( GLEW_ARB_pixel_buffer_object )
if( GLAD_GL_VERSION_1_5 )
{
m_openglSupportsVertexBufferObjects = true;
@@ -228,17 +226,17 @@ void RENDER_3D_RAYTRACE_GL::initPbo()
// http://www.songho.ca/opengl/gl_pbo.html
// http://web.eecs.umich.edu/~sugih/courses/eecs487/lectures/25-PBO+Mipmapping.pdf
// "create 2 pixel buffer objects, you need to delete them when program exits.
// glBufferDataARB with NULL pointer reserves only memory space."
// glBufferData with NULL pointer reserves only memory space."
// This sets the number of RGBA pixels
m_pboDataSize = m_realBufferSize.x * m_realBufferSize.y * 4;
glGenBuffersARB( 1, &m_pboId );
glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_pboId );
glBufferDataARB( GL_PIXEL_UNPACK_BUFFER_ARB, m_pboDataSize, 0, GL_STREAM_DRAW_ARB );
glBindBufferARB( GL_PIXEL_UNPACK_BUFFER_ARB, 0 );
glGenBuffers( 1, &m_pboId );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, m_pboId );
glBufferData( GL_PIXEL_UNPACK_BUFFER, m_pboDataSize, 0, GL_STREAM_DRAW );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, 0 );
wxLogTrace( m_logTrace,
wxT( "RENDER_3D_RAYTRACE_GL:: GLEW_ARB_pixel_buffer_object is supported" ) );
wxT( "RENDER_3D_RAYTRACE_GL:: GL Version 1.5+ is supported" ) );
}
}
+1 -1
View File
@@ -54,7 +54,7 @@ CACHED_CONTAINER_GPU::CACHED_CONTAINER_GPU( unsigned int aSize ) :
m_isMapped( false ),
m_glBufferHandle( -1 )
{
m_useCopyBuffer = ( GLAD_GL_ARB_copy_buffer != 0 ) || ( GLAD_GL_VERSION_3_1 != 0 );
m_useCopyBuffer = !!GLAD_GL_ARB_copy_buffer;
wxString vendor( glGetString( GL_VENDOR ) );
+22 -22
View File
@@ -119,28 +119,28 @@ void OPENGL_COMPOSITOR::Initialize()
assert( dims.x != 0 && dims.y != 0 );
GLint maxBufSize;
glGetIntegerv( GL_MAX_RENDERBUFFER_SIZE_EXT, &maxBufSize );
glGetIntegerv( GL_MAX_RENDERBUFFER_SIZE, &maxBufSize );
if( dims.x < 0 || dims.y < 0 || dims.x > maxBufSize || dims.y >= maxBufSize )
throw std::runtime_error( "Requested render buffer size is not supported" );
// We need framebuffer objects for drawing the screen contents
// Generate framebuffer and a depth buffer
glGenFramebuffersEXT( 1, &m_mainFbo );
glGenFramebuffers( 1, &m_mainFbo );
checkGlError( "generating framebuffer", __FILE__, __LINE__ );
bindFb( m_mainFbo );
// Allocate memory for the depth buffer
// Attach the depth buffer to the framebuffer
glGenRenderbuffersEXT( 1, &m_depthBuffer );
glGenRenderbuffers( 1, &m_depthBuffer );
checkGlError( "generating renderbuffer", __FILE__, __LINE__ );
glBindRenderbufferEXT( GL_RENDERBUFFER_EXT, m_depthBuffer );
glBindRenderbuffer( GL_RENDERBUFFER, m_depthBuffer );
checkGlError( "binding renderbuffer", __FILE__, __LINE__ );
glRenderbufferStorageEXT( GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8, dims.x, dims.y );
glRenderbufferStorage( GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, dims.x, dims.y );
checkGlError( "creating renderbuffer storage", __FILE__, __LINE__ );
glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
GL_RENDERBUFFER_EXT, m_depthBuffer );
glFramebufferRenderbuffer( GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
GL_RENDERBUFFER, m_depthBuffer );
checkGlError( "attaching renderbuffer", __FILE__, __LINE__ );
// Unbind the framebuffer, so by default all the rendering goes directly to the display
@@ -212,35 +212,35 @@ unsigned int OPENGL_COMPOSITOR::CreateBuffer( VECTOR2I aDimensions )
// Bind the texture to the specific attachment point, clear and rebind the screen
bindFb( m_mainFbo );
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachmentPoint, GL_TEXTURE_2D, textureTarget, 0 );
glFramebufferTexture2D( GL_FRAMEBUFFER, attachmentPoint, GL_TEXTURE_2D, textureTarget, 0 );
// Check the status, exit if the framebuffer can't be created
GLenum status = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER );
if( status != GL_FRAMEBUFFER_COMPLETE_EXT )
if( status != GL_FRAMEBUFFER_COMPLETE )
{
switch( status )
{
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
throw std::runtime_error( "The framebuffer attachment points are incomplete." );
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
throw std::runtime_error( "No images attached to the framebuffer." );
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
throw std::runtime_error( "The framebuffer does not have at least one image attached to it." );
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
throw std::runtime_error( "The framebuffer read buffer is incomplete." );
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
case GL_FRAMEBUFFER_UNSUPPORTED:
throw std::runtime_error( "The combination of internal formats of the attached images violates "
"an implementation-dependent set of restrictions." );
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
throw std::runtime_error( "GL_RENDERBUFFER_SAMPLES is not the same for all attached renderbuffers" );
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
throw std::runtime_error( "Framebuffer incomplete layer targets errors." );
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
@@ -384,7 +384,7 @@ void OPENGL_COMPOSITOR::bindFb( unsigned int aFb )
if( m_curFbo != aFb )
{
glBindFramebufferEXT( GL_FRAMEBUFFER, aFb );
glBindFramebuffer( GL_FRAMEBUFFER, aFb );
checkGlError( "switching framebuffer", __FILE__, __LINE__ );
m_curFbo = aFb;
}
@@ -402,11 +402,11 @@ void OPENGL_COMPOSITOR::clean()
m_buffers.clear();
if( glDeleteFramebuffersEXT )
glDeleteFramebuffersEXT( 1, &m_mainFbo );
if( glDeleteFramebuffers )
glDeleteFramebuffers( 1, &m_mainFbo );
if( glDeleteRenderbuffersEXT )
glDeleteRenderbuffersEXT( 1, &m_depthBuffer );
if( glDeleteRenderbuffers )
glDeleteRenderbuffers( 1, &m_depthBuffer );
// Clean up difference shader
if( m_differenceShaderInitialized && m_differenceShader != 0 )
+3 -3
View File
@@ -2838,17 +2838,17 @@ void OPENGL_GAL::init()
#if defined( __LINUX__ ) // calling enableGlDebug crashes opengl on some OS (OSX and some Windows)
#ifdef DEBUG
if( glDebugMessageCallback || glDebugMessageCallbackARB )
if( glDebugMessageCallback )
enableGlDebug( true );
#endif
#endif
// Framebuffers have to be supported
if( !GLAD_GL_EXT_framebuffer_object && !GLAD_GL_VERSION_3_0 )
if( !GLAD_GL_ARB_framebuffer_object )
throw std::runtime_error( "Framebuffer objects are not supported!" );
// Vertex buffer has to be supported
if( !GLAD_GL_ARB_vertex_buffer_object && !GLAD_GL_VERSION_1_5 )
if( !GLAD_GL_ARB_vertex_buffer_object )
throw std::runtime_error( "Vertex buffer objects are not supported!" );
// Prepare shaders
+6 -4
View File
@@ -289,10 +289,12 @@ bool SHADER::loadShaderFromStringArray( SHADER_TYPE aShaderType, const char** aA
// Special handling for the geometry shader
if( aShaderType == SHADER_TYPE_GEOMETRY )
{
glProgramParameteriEXT( programNumber, GL_GEOMETRY_VERTICES_OUT_EXT, maximumVertices );
glProgramParameteriEXT( programNumber, GL_GEOMETRY_INPUT_TYPE_EXT, geomInputType );
glProgramParameteriEXT( programNumber, GL_GEOMETRY_OUTPUT_TYPE_EXT, geomOutputType );
if( GLAD_GL_ARB_geometry_shader4 || GLAD_GL_EXT_geometry_shader4 )
{
glProgramParameteri( programNumber, GL_GEOMETRY_VERTICES_OUT_EXT, maximumVertices );
glProgramParameteri( programNumber, GL_GEOMETRY_INPUT_TYPE_EXT, geomInputType );
glProgramParameteri( programNumber, GL_GEOMETRY_OUTPUT_TYPE_EXT, geomOutputType );
}
}
return true;
}
+10 -13
View File
@@ -67,39 +67,39 @@ int checkGlError( const std::string& aInfo, const char* aFile, int aLine, bool a
case GL_INVALID_FRAMEBUFFER_OPERATION:
{
GLenum status = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );
GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER );
if( status != GL_FRAMEBUFFER_COMPLETE_EXT )
if( status != GL_FRAMEBUFFER_COMPLETE )
{
switch( status )
{
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
errorMsg = "The framebuffer attachment points are incomplete.";
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
errorMsg = "No images attached to the framebuffer.";
break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
errorMsg = "The framebuffer does not have at least one image attached to it.";
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
errorMsg = "The framebuffer read buffer is incomplete.";
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
case GL_FRAMEBUFFER_UNSUPPORTED:
errorMsg = "The combination of internal formats of the attached images violates "
"an implementation dependent set of restrictions.";
break;
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
errorMsg = "GL_RENDERBUFFER_SAMPLES is not the same for all attached render "
"buffers.";
break;
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT:
case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS:
errorMsg = "Framebuffer incomplete layer targets errors.";
break;
@@ -190,10 +190,7 @@ void enableGlDebug( bool aEnable )
if( aEnable )
{
glEnable( GL_DEBUG_OUTPUT );
if( glDebugMessageCallback )
glDebugMessageCallback( (GLDEBUGPROC) debugMsgCallback, nullptr );
else if( glDebugMessageCallbackARB )
glDebugMessageCallbackARB( (GLDEBUGPROCARB) debugMsgCallback, nullptr );
glDebugMessageCallback( (GLDEBUGPROC) debugMsgCallback, nullptr );
}
else
{