aboutsummaryrefslogtreecommitdiffhomepage
path: root/video
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2014-12-18 21:06:17 +0100
committerGravatar wm4 <wm4@nowhere>2014-12-18 21:06:17 +0100
commit32fb3dae8783800e01e94b561baca306389d64a8 (patch)
tree3dd44aef9858dd5a1a6b5adc5eb7bf7caeb64aba /video
parentda997db09504767de63d434f0a6a6773827e670b (diff)
vo_opengl: simplify some aspects of the GL function loader
Diffstat (limited to 'video')
-rw-r--r--video/out/gl_common.c30
-rw-r--r--video/out/gl_common.h19
2 files changed, 23 insertions, 26 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c
index 892f7cee8d..50864afaf7 100644
--- a/video/out/gl_common.c
+++ b/video/out/gl_common.c
@@ -104,11 +104,8 @@ struct feature {
};
static const struct feature features[] = {
- {MPGL_CAP_GL, "Basic OpenGL"},
{MPGL_CAP_GL_LEGACY, "Legacy OpenGL"},
- {MPGL_CAP_GL2, "OpenGL 2.0"},
- {MPGL_CAP_GL21, "OpenGL 2.1"},
- {MPGL_CAP_GL3, "OpenGL 3.0"},
+ {MPGL_CAP_GL21, "OpenGL 2.1+"},
{MPGL_CAP_FB, "Framebuffers"},
{MPGL_CAP_VAO, "VAOs"},
{MPGL_CAP_SRGB_TEX, "sRGB textures"},
@@ -171,7 +168,6 @@ static const struct gl_functions gl_functions[] = {
// GL functions which are always available anywhere at least since 1.1
{
.ver_core = MPGL_VER(1, 1),
- .provides = MPGL_CAP_GL,
.functions = (const struct gl_function[]) {
DEF_FN(Viewport),
DEF_FN(Clear),
@@ -209,7 +205,6 @@ static const struct gl_functions gl_functions[] = {
// GL 2.0-3.x functions
{
.ver_core = MPGL_VER(2, 0),
- .provides = MPGL_CAP_GL2,
.functions = (const struct gl_function[]) {
DEF_FN(GenBuffers),
DEF_FN(DeleteBuffers),
@@ -262,7 +257,7 @@ static const struct gl_functions gl_functions[] = {
// GL 3.x core only functions.
{
.ver_core = MPGL_VER(3, 0),
- .provides = MPGL_CAP_GL3 | MPGL_CAP_SRGB_TEX | MPGL_CAP_SRGB_FB,
+ .provides = MPGL_CAP_SRGB_TEX | MPGL_CAP_SRGB_FB,
.functions = (const struct gl_function[]) {
DEF_FN(GetStringi),
{0}
@@ -490,17 +485,22 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n),
const char *version = gl->GetString(GL_VERSION);
if (strncmp(version, "OpenGL ES ", 10) == 0) {
version += 10;
- gl->es = true;
+ gl->es = 100;
}
sscanf(version, "%d.%d", &major, &minor);
gl->version = MPGL_VER(major, minor);
- mp_verbose(log, "Detected OpenGL %d.%d (%s).\n", major, minor,
- gl->es ? "GLES" : "desktop");
+ mp_verbose(log, "Detected %s %d.%d.\n", gl->es ? "GLES" : "desktop OpenGL",
+ major, minor);
- if (gl->es && gl->version < MPGL_VER(3, 0)) {
- mp_warn(log, "At least GLESv3 required.\n");
- gl->version = 0;
- return;
+ if (gl->es) {
+ gl->es = gl->version;
+ if (gl->version >= 300) {
+ gl->version = 300; // pretend it's desktop OpenGL 3.0
+ } else {
+ mp_warn(log, "At least GLESv3 required.\n");
+ gl->version = 0;
+ return;
+ }
}
mp_verbose(log, "GL_VENDOR='%s'\n", gl->GetString(GL_VENDOR));
@@ -903,8 +903,6 @@ MPGLContext *mpgl_init(struct vo *vo, const char *backend_name,
if (!ctx)
return NULL;
- gl_caps |= MPGL_CAP_GL;
-
ctx->requested_gl_version = (gl_caps & MPGL_CAP_GL_LEGACY)
? MPGL_VER(2, 1) : MPGL_VER(3, 0);
diff --git a/video/out/gl_common.h b/video/out/gl_common.h
index 7ec06fc248..999dc5d606 100644
--- a/video/out/gl_common.h
+++ b/video/out/gl_common.h
@@ -68,11 +68,8 @@ void glCheckError(GL *gl, struct mp_log *log, const char *info);
mp_image_t *glGetWindowScreenshot(GL *gl);
enum {
- MPGL_CAP_GL = (1 << 0), // GL was successfully loaded
- MPGL_CAP_GL_LEGACY = (1 << 1), // GL 1.1 (but not 3.x)
- MPGL_CAP_GL2 = (1 << 2), // GL 2.0 (3.x core subset)
- MPGL_CAP_GL21 = (1 << 3), // GL 2.1 (3.x core subset)
- MPGL_CAP_GL3 = (1 << 4), // GL 3.x core
+ MPGL_CAP_GL_LEGACY = (1 << 1), // GL 1.1 (excluding 3.x)
+ MPGL_CAP_GL21 = (1 << 3), // GL 2.1+ (excluding legacy)
MPGL_CAP_FB = (1 << 5),
MPGL_CAP_VAO = (1 << 6),
MPGL_CAP_SRGB_TEX = (1 << 7),
@@ -84,9 +81,11 @@ enum {
MPGL_CAP_NO_SW = (1 << 30), // used to block sw. renderers
};
-#define MPGL_VER(major, minor) (((major) << 16) | (minor))
-#define MPGL_VER_GET_MAJOR(ver) ((ver) >> 16)
-#define MPGL_VER_GET_MINOR(ver) ((ver) & ((1 << 16) - 1))
+// E.g. 310 means 3.1
+// Code doesn't have to use the macros; they are for convenience only.
+#define MPGL_VER(major, minor) (((major) * 100) + (minor))
+#define MPGL_VER_GET_MAJOR(ver) ((unsigned)(ver) / 100)
+#define MPGL_VER_GET_MINOR(ver) ((unsigned)(ver) % 100)
#define MPGL_VER_P(ver) MPGL_VER_GET_MAJOR(ver), MPGL_VER_GET_MINOR(ver)
@@ -170,8 +169,8 @@ void mp_log_source(struct mp_log *log, int lev, const char *src);
//function pointers loaded from the OpenGL library
struct GL {
- bool es; // false: desktop GL, true: GLES
- int version; // MPGL_VER() mangled
+ int version; // MPGL_VER() mangled (e.g. 210 for 2.1)
+ int es; // es version (e.g. 300), 0 for desktop GL
int glsl_version; // e.g. 130 for GLSL 1.30
char *extensions; // Equivalent to GL_EXTENSIONS
int mpgl_caps; // Bitfield of MPGL_CAP_* constants