diff --git a/src/backend/gl/gl_common.c b/src/backend/gl/gl_common.c index badbd9bb6c..287ae6597b 100644 --- a/src/backend/gl/gl_common.c +++ b/src/backend/gl/gl_common.c @@ -22,6 +22,8 @@ #include "backend/backend_common.h" #include "backend/gl/gl_common.h" +static PFNGLGETQUERYOBJECTUI64VPROC ptrglGetQueryObjectui64v = NULL; + void gl_prepare(backend_t *base, const region_t *reg attr_unused) { auto gd = (struct gl_data *)base; glBeginQuery(GL_TIME_ELAPSED, gd->frame_timing[gd->current_frame_timing]); @@ -1213,13 +1215,29 @@ bool gl_last_render_time(backend_t *base, struct timespec *ts) { return false; } - GLuint64 time; - glGetQueryObjectui64v(gd->frame_timing[gd->current_frame_timing ^ 1], - GL_QUERY_RESULT, &time); - ts->tv_sec = (long)(time / 1000000000); - ts->tv_nsec = (long)(time % 1000000000); - gl_check_err(); - return true; + // We need obtain proc pointer for glGetQueryObjectui64v function. + // In OpenBSD this function no appear publicly, glXGetProcAddress resolve the issue. + if(ptrglGetQueryObjectui64v == NULL) { + ptrglGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC) + glXGetProcAddress("glGetQueryObjectui64v"); + + GLuint64 time; + ptrglGetQueryObjectui64v(gd->frame_timing[gd->current_frame_timing ^ 1], + GL_QUERY_RESULT, &time); + ts->tv_sec = (long)(time / 1000000000); + ts->tv_nsec = (long)(time % 1000000000); + gl_check_err(); + } + else { + GLuint64 time; + ptrglGetQueryObjectui64v(gd->frame_timing[gd->current_frame_timing ^ 1], + GL_QUERY_RESULT, &time); + ts->tv_sec = (long)(time / 1000000000); + ts->tv_nsec = (long)(time % 1000000000); + gl_check_err(); + } + + return true; } bool gl_image_op(backend_t *base, enum image_operations op, void *image_data,