GLAD Extensions

Fix missing extensions in OpenGLES

GLAD is a runtime loader-generator for Vulkan/GL/GLES/EGL/GLX/WGL. There is a great web tool to generate glad.h and glad.cpp files we need (https://glad.dav1d.de/).

Recently, i was using GL_TIME_ELAPSED_EXT in my code to do the time query of my opengl rendering task, but found that GL_TIME_ELAPSED_EXT is not defined. The main reason is that in OpenGLES, timer queries are not core, even in ES 3.2. They are extension-only. So if GLAD wasn’t generated with that extension enabled, the macro will simply not exist.

To fix this, we have to manually include the extension GL_EXT_disjoint_timer_query, which GL_TIME_ELAPSED_EXT comes from, when generating the GLAD files.

Then, the generated glad.h file will contain the definition of GL_TIME_ELAPSED_EXT.

1
2
3
4
5
6
7
8
9
#define GL_QUERY_COUNTER_BITS_EXT 0x8864
#define GL_CURRENT_QUERY_EXT 0x8865
#define GL_QUERY_RESULT_EXT 0x8866
#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867
#define GL_TIME_ELAPSED_EXT 0x88BF
#define GL_TIMESTAMP_EXT 0x8E28
#define GL_GPU_DISJOINT_EXT 0x8FBB
#ifndef GL_EXT_disjoint_timer_query
#define GL_EXT_disjoint_timer_query 1
Author

Joe Chu

Posted on

2026-01-24

Updated on

2026-01-24

Licensed under

Comments