Permalink
Browse files

Move more feature tests to GLimp_InitExtensions

Support BC4 and BC5 compressed textures natively on Mac OSX core profile
  • Loading branch information...
1 parent cb062d0 commit 4e3efb64b3884936a12b4366b4e1108eadad1c6e @cmf028 cmf028 committed Mar 9, 2016
@@ -261,7 +261,7 @@ void GLShaderManager::UpdateShaderProgramUniformLocations( GLShader *shader, sha
uniform->UpdateShaderProgramUniformLocation( shaderProgram );
}
- if( GLEW_ARB_uniform_buffer_object || glConfig2.glCoreProfile ) {
+ if( glConfig2.uniformBufferObjectAvailable ) {
// create buffer for storing uniform block indexes
shaderProgram->uniformBlockIndexes = ( GLuint * ) ri.Z_Malloc( sizeof( GLuint ) * numUniformBlocks );
@@ -5417,7 +5417,7 @@ static const void *RB_SetupLights( const void *data )
cmd = ( const setupLightsCommand_t * ) data;
- if( ( GLEW_ARB_uniform_buffer_object || glConfig2.glCoreProfile ) &&
+ if( ( glConfig2.uniformBufferObjectAvailable ) &&
(numLights = cmd->refdef.numLights) > 0 ) {
shaderLight_t *buffer;
@@ -1222,7 +1222,7 @@ void R_UploadImage( const byte **dataArray, int numLayers, int numMips,
blockSize = 16;
}
else if ( image->bits & IF_BC4 ) {
- if( !GLEW_ARB_texture_compression_rgtc ) {
+ if( !glConfig2.textureCompressionRGTCAvailable ) {
format = GL_NONE;
internalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
blockSize = 8;
@@ -1238,7 +1238,7 @@ void R_UploadImage( const byte **dataArray, int numLayers, int numMips,
}
}
else if ( image->bits & IF_BC5 ) {
- if( !GLEW_ARB_texture_compression_rgtc ) {
+ if( !glConfig2.textureCompressionRGTCAvailable ) {
format = GL_NONE;
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
blockSize = 16;
@@ -373,6 +373,8 @@ struct glconfig_t
struct glconfig2_t
{
bool ARBTextureCompressionAvailable;
+ bool textureCompressionRGTCAvailable;
+
bool glCoreProfile;
int maxCubeMapTextureSize;
@@ -408,6 +410,7 @@ struct glconfig2_t
bool generateMipmapAvailable;
bool getProgramBinaryAvailable;
bool bufferStorageAvailable;
+ bool uniformBufferObjectAvailable;
bool mapBufferRangeAvailable;
bool syncAvailable;
};
@@ -1023,7 +1023,7 @@ void R_InitVBOs()
nullptr, GL_STREAM_COPY );
glBindBuffer( GL_PIXEL_PACK_BUFFER, 0 );
- if( GLEW_ARB_uniform_buffer_object || glConfig2.glCoreProfile ) {
+ if( glConfig2.uniformBufferObjectAvailable ) {
glGenBuffers( 1, &tr.dlightUBO );
glBindBuffer( GL_UNIFORM_BUFFER, tr.dlightUBO );
glBufferData( GL_UNIFORM_BUFFER, MAX_REF_LIGHTS * sizeof( shaderLight_t ), nullptr, GL_DYNAMIC_DRAW );
@@ -1101,7 +1101,7 @@ void R_ShutdownVBOs()
Com_Free_Aligned( tess.vertsBuffer );
Com_Free_Aligned( tess.indexesBuffer );
- if( GLEW_ARB_uniform_buffer_object || glConfig2.glCoreProfile ) {
+ if( glConfig2.uniformBufferObjectAvailable ) {
glDeleteBuffers( 1, &tr.dlightUBO );
tr.dlightUBO = 0;
}
@@ -1077,6 +1077,10 @@ static void GLimp_InitExtensions()
{
glConfig.textureCompression = textureCompression_t::TC_S3TC;
}
+
+ // made required in OpenGL 3.0
+ glConfig2.textureCompressionRGTCAvailable = LOAD_CORE_EXTENSION_WITH_CVAR(ARB_texture_compression_rgtc, r_ext_compressed_textures);
+
//REQUIRE_EXTENSION(EXT_texture3D);
// Texture - others
@@ -1186,6 +1190,9 @@ static void GLimp_InitExtensions()
glConfig2.bufferStorageAvailable = false;
}
+ // made required since OpenGL 3.1
+ glConfig2.uniformBufferObjectAvailable = GLEW_ARB_uniform_buffer_object || glConfig2.glCoreProfile;
+
// made required in OpenGL 3.0
glConfig2.mapBufferRangeAvailable = LOAD_CORE_EXTENSION_WITH_CVAR( ARB_map_buffer_range, r_arb_map_buffer_range );

0 comments on commit 4e3efb6

Please sign in to comment.