[TIPS] How To Get the List of the OpenGL Extensions With a Core Profile

OpenGL



In this news we learnt that GLEW fails to initialize when an OpenGL 3 or 4 core profile is used because GLEW uses the deprecated glGetString(GL_EXTENSIONS) to read the available extensions.

With OpenGL 3 and 4, there is a new way to fetch the supported extensions First you have to get the number of extensions with:

GLint n=0; 
glGetIntegerv(GL_NUM_EXTENSIONS, &n); 



Now you can list all supported extensions with:


#include <GL/GL.h>
#include <GL/glext.h>

PFNGLGETSTRINGIPROC glGetStringi = 0;
glGetStringi = (PFNGLGETSTRINGIPROC)wglGetProcAddress("glGetStringi");

for (GLint i=0; i<n; i++) 
{ 
  const char* extension = 
    (const char*)glGetStringi(GL_EXTENSIONS, i);
  printf("Ext %d: %s\n", i, extension); 
} 



And here is a piece of code that can be used to patch GLEW:

bool IsExtensionSupported(const char *name)
{
  GLint n=0; 
  glGetIntegerv(GL_NUM_EXTENSIONS, &n); 
  for (GLint i=0; i<n; i++) 
  { 
    const char* extension = 
     (const char*)glGetStringi(GL_EXTENSIONS, i);
    if (!strcmp(name, extension)) 
    {
      return true;
    }
  }
  return false;
}



Actually this method works also with an OpenGL 2 context as long as glGetStringi is exposed…

On my GTX 480 + R258.96, this method returns 214 extensions:

  • GL extension 0: GL_ARB_blend_func_extended
  • GL extension 1: GL_ARB_color_buffer_float
  • GL extension 2: GL_ARB_compatibility
  • GL extension 3: GL_ARB_copy_buffer
  • GL extension 4: GL_ARB_depth_buffer_float
  • GL extension 5: GL_ARB_depth_clamp
  • GL extension 6: GL_ARB_depth_texture
  • GL extension 7: GL_ARB_draw_buffers
  • GL extension 8: GL_ARB_draw_buffers_blend
  • GL extension 9: GL_ARB_draw_indirect
  • GL extension 10: GL_ARB_draw_elements_base_vertex
  • GL extension 11: GL_ARB_draw_instanced
  • GL extension 12: GL_ARB_explicit_attrib_location
  • GL extension 13: GL_ARB_fragment_coord_conventions
  • GL extension 14: GL_ARB_fragment_program
  • GL extension 15: GL_ARB_fragment_program_shadow
  • GL extension 16: GL_ARB_fragment_shader
  • GL extension 17: GL_ARB_framebuffer_object
  • GL extension 18: GL_ARB_framebuffer_sRGB
  • GL extension 19: GL_ARB_geometry_shader4
  • GL extension 20: GL_ARB_gpu_shader5
  • GL extension 21: GL_ARB_gpu_shader_fp64
  • GL extension 22: GL_ARB_half_float_pixel
  • GL extension 23: GL_ARB_half_float_vertex
  • GL extension 24: GL_ARB_imaging
  • GL extension 25: GL_ARB_instanced_arrays
  • GL extension 26: GL_ARB_map_buffer_range
  • GL extension 27: GL_ARB_multisample
  • GL extension 28: GL_ARB_multitexture
  • GL extension 29: GL_ARB_occlusion_query
  • GL extension 30: GL_ARB_occlusion_query2
  • GL extension 31: GL_ARB_pixel_buffer_object
  • GL extension 32: GL_ARB_point_parameters
  • GL extension 33: GL_ARB_point_sprite
  • GL extension 34: GL_ARB_provoking_vertex
  • GL extension 35: GL_ARB_sample_shading
  • GL extension 36: GL_ARB_sampler_objects
  • GL extension 37: GL_ARB_seamless_cube_map
  • GL extension 38: GL_ARB_shader_bit_encoding
  • GL extension 39: GL_ARB_shader_objects
  • GL extension 40: GL_ARB_shader_subroutine
  • GL extension 41: GL_ARB_shading_language_100
  • GL extension 42: GL_ARB_shadow
  • GL extension 43: GL_ARB_sync
  • GL extension 44: GL_ARB_tessellation_shader
  • GL extension 45: GL_ARB_texture_border_clamp
  • GL extension 46: GL_ARB_texture_buffer_object
  • GL extension 47: GL_ARB_texture_buffer_object_rgb32
  • GL extension 48: GL_ARB_texture_compression
  • GL extension 49: GL_ARB_texture_compression_bptc
  • GL extension 50: GL_ARB_texture_compression_rgtc
  • GL extension 51: GL_ARB_texture_cube_map
  • GL extension 52: GL_ARB_texture_cube_map_array
  • GL extension 53: GL_ARB_texture_env_add
  • GL extension 54: GL_ARB_texture_env_combine
  • GL extension 55: GL_ARB_texture_env_crossbar
  • GL extension 56: GL_ARB_texture_env_dot3
  • GL extension 57: GL_ARB_texture_float
  • GL extension 58: GL_ARB_texture_gather
  • GL extension 59: GL_ARB_texture_mirrored_repeat
  • GL extension 60: GL_ARB_texture_multisample
  • GL extension 61: GL_ARB_texture_non_power_of_two
  • GL extension 62: GL_ARB_texture_query_lod
  • GL extension 63: GL_ARB_texture_rectangle
  • GL extension 64: GL_ARB_texture_rg
  • GL extension 65: GL_ARB_texture_rgb10_a2ui
  • GL extension 66: GL_ARB_texture_swizzle
  • GL extension 67: GL_ARB_timer_query
  • GL extension 68: GL_ARB_transform_feedback2
  • GL extension 69: GL_ARB_transform_feedback3
  • GL extension 70: GL_ARB_transpose_matrix
  • GL extension 71: GL_ARB_uniform_buffer_object
  • GL extension 72: GL_ARB_vertex_array_bgra
  • GL extension 73: GL_ARB_vertex_array_object
  • GL extension 74: GL_ARB_vertex_buffer_object
  • GL extension 75: GL_ARB_vertex_program
  • GL extension 76: GL_ARB_vertex_shader
  • GL extension 77: GL_ARB_vertex_type_2_10_10_10_rev
  • GL extension 78: GL_ARB_window_pos
  • GL extension 79: GL_ATI_draw_buffers
  • GL extension 80: GL_ATI_texture_float
  • GL extension 81: GL_ATI_texture_mirror_once
  • GL extension 82: GL_S3_s3tc
  • GL extension 83: GL_EXT_texture_env_add
  • GL extension 84: GL_EXT_abgr
  • GL extension 85: GL_EXT_bgra
  • GL extension 86: GL_EXT_bindable_uniform
  • GL extension 87: GL_EXT_blend_color
  • GL extension 88: GL_EXT_blend_equation_separate
  • GL extension 89: GL_EXT_blend_func_separate
  • GL extension 90: GL_EXT_blend_minmax
  • GL extension 91: GL_EXT_blend_subtract
  • GL extension 92: GL_EXT_compiled_vertex_array
  • GL extension 93: GL_EXT_Cg_shader
  • GL extension 94: GL_EXT_depth_bounds_test
  • GL extension 95: GL_EXT_direct_state_access
  • GL extension 96: GL_EXT_draw_buffers2
  • GL extension 97: GL_EXT_draw_instanced
  • GL extension 98: GL_EXT_draw_range_elements
  • GL extension 99: GL_EXT_fog_coord
  • GL extension 100: GL_EXT_framebuffer_blit
  • GL extension 101: GL_EXT_framebuffer_multisample
  • GL extension 102: GL_EXTX_framebuffer_mixed_formats
  • GL extension 103: GL_EXT_framebuffer_object
  • GL extension 104: GL_EXT_framebuffer_sRGB
  • GL extension 105: GL_EXT_geometry_shader4
  • GL extension 106: GL_EXT_gpu_program_parameters
  • GL extension 107: GL_EXT_gpu_shader4
  • GL extension 108: GL_EXT_multi_draw_arrays
  • GL extension 109: GL_EXT_packed_depth_stencil
  • GL extension 110: GL_EXT_packed_float
  • GL extension 111: GL_EXT_packed_pixels
  • GL extension 112: GL_EXT_pixel_buffer_object
  • GL extension 113: GL_EXT_point_parameters
  • GL extension 114: GL_EXT_provoking_vertex
  • GL extension 115: GL_EXT_rescale_normal
  • GL extension 116: GL_EXT_secondary_color
  • GL extension 117: GL_EXT_separate_shader_objects
  • GL extension 118: GL_EXT_separate_specular_color
  • GL extension 119: GL_EXT_shader_image_load_store
  • GL extension 120: GL_EXT_shadow_funcs
  • GL extension 121: GL_EXT_stencil_two_side
  • GL extension 122: GL_EXT_stencil_wrap
  • GL extension 123: GL_EXT_texture3D
  • GL extension 124: GL_EXT_texture_array
  • GL extension 125: GL_EXT_texture_buffer_object
  • GL extension 126: GL_EXT_texture_compression_latc
  • GL extension 127: GL_EXT_texture_compression_rgtc
  • GL extension 128: GL_EXT_texture_compression_s3tc
  • GL extension 129: GL_EXT_texture_cube_map
  • GL extension 130: GL_EXT_texture_edge_clamp
  • GL extension 131: GL_EXT_texture_env_combine
  • GL extension 132: GL_EXT_texture_env_dot3
  • GL extension 133: GL_EXT_texture_filter_anisotropic
  • GL extension 134: GL_EXT_texture_integer
  • GL extension 135: GL_EXT_texture_lod
  • GL extension 136: GL_EXT_texture_lod_bias
  • GL extension 137: GL_EXT_texture_mirror_clamp
  • GL extension 138: GL_EXT_texture_object
  • GL extension 139: GL_EXT_texture_shared_exponent
  • GL extension 140: GL_EXT_texture_sRGB
  • GL extension 141: GL_EXT_texture_swizzle
  • GL extension 142: GL_EXT_timer_query
  • GL extension 143: GL_EXT_transform_feedback2
  • GL extension 144: GL_EXT_vertex_array
  • GL extension 145: GL_EXT_vertex_array_bgra
  • GL extension 146: GL_EXT_vertex_attrib_64bit
  • GL extension 147: GL_IBM_rasterpos_clip
  • GL extension 148: GL_IBM_texture_mirrored_repeat
  • GL extension 149: GL_KTX_buffer_region
  • GL extension 150: GL_NV_blend_square
  • GL extension 151: GL_NV_conditional_render
  • GL extension 152: GL_NV_copy_depth_to_color
  • GL extension 153: GL_NV_copy_image
  • GL extension 154: GL_NV_depth_buffer_float
  • GL extension 155: GL_NV_depth_clamp
  • GL extension 156: GL_NV_explicit_multisample
  • GL extension 157: GL_NV_fence
  • GL extension 158: GL_NV_float_buffer
  • GL extension 159: GL_NV_fog_distance
  • GL extension 160: GL_NV_fragment_program
  • GL extension 161: GL_NV_fragment_program_option
  • GL extension 162: GL_NV_fragment_program2
  • GL extension 163: GL_NV_framebuffer_multisample_coverage
  • GL extension 164: GL_NV_geometry_shader4
  • GL extension 165: GL_NV_gpu_program4
  • GL extension 166: GL_NV_gpu_program4_1
  • GL extension 167: GL_NV_gpu_program5
  • GL extension 168: GL_NV_gpu_program_fp64
  • GL extension 169: GL_NV_gpu_shader5
  • GL extension 170: GL_NV_half_float
  • GL extension 171: GL_NV_light_max_exponent
  • GL extension 172: GL_NV_multisample_coverage
  • GL extension 173: GL_NV_multisample_filter_hint
  • GL extension 174: GL_NV_occlusion_query
  • GL extension 175: GL_NV_packed_depth_stencil
  • GL extension 176: GL_NV_parameter_buffer_object
  • GL extension 177: GL_NV_parameter_buffer_object2
  • GL extension 178: GL_NV_pixel_data_range
  • GL extension 179: GL_NV_point_sprite
  • GL extension 180: GL_NV_primitive_restart
  • GL extension 181: GL_NV_register_combiners
  • GL extension 182: GL_NV_register_combiners2
  • GL extension 183: GL_NV_shader_buffer_load
  • GL extension 184: GL_NV_texgen_reflection
  • GL extension 185: GL_NV_texture_barrier
  • GL extension 186: GL_NV_texture_compression_vtc
  • GL extension 187: GL_NV_texture_env_combine4
  • GL extension 188: GL_NV_texture_expand_normal
  • GL extension 189: GL_NV_texture_multisample
  • GL extension 190: GL_NV_texture_rectangle
  • GL extension 191: GL_NV_texture_shader
  • GL extension 192: GL_NV_texture_shader2
  • GL extension 193: GL_NV_texture_shader3
  • GL extension 194: GL_NV_transform_feedback
  • GL extension 195: GL_NV_transform_feedback2
  • GL extension 196: GL_NV_vertex_array_range
  • GL extension 197: GL_NV_vertex_array_range2
  • GL extension 198: GL_NV_vertex_attrib_integer_64bit
  • GL extension 199: GL_NV_vertex_buffer_unified_memory
  • GL extension 200: GL_NV_vertex_program
  • GL extension 201: GL_NV_vertex_program1_1
  • GL extension 202: GL_NV_vertex_program2
  • GL extension 203: GL_NV_vertex_program2_option
  • GL extension 204: GL_NV_vertex_program3
  • GL extension 205: GL_NVX_conditional_render
  • GL extension 206: GL_NVX_gpu_memory_info
  • GL extension 207: GL_SGIS_generate_mipmap
  • GL extension 208: GL_SGIS_texture_lod
  • GL extension 209: GL_SGIX_depth_texture
  • GL extension 210: GL_SGIX_shadow
  • GL extension 211: GL_SUN_slice_accum
  • GL extension 212: GL_WIN_swap_hint
  • GL extension 213: WGL_EXT_swap_control

As you can see, one WGL function is included: WGL_EXT_swap_control




Geeks3D.com

↑ Grab this Headline Animator