diff options
Diffstat (limited to 'video')
-rw-r--r-- | video/out/gl_common.c | 230 | ||||
-rw-r--r-- | video/out/gl_common.h | 44 | ||||
-rw-r--r-- | video/out/gl_header_fixes.h | 117 | ||||
-rw-r--r-- | video/out/gl_osd.c | 103 | ||||
-rw-r--r-- | video/out/gl_osd.h | 6 | ||||
-rw-r--r-- | video/out/gl_video.c | 4 | ||||
-rw-r--r-- | video/out/gl_w32.c | 3 | ||||
-rw-r--r-- | video/out/gl_x11.c | 9 | ||||
-rw-r--r-- | video/out/vo_opengl.c | 2 |
9 files changed, 73 insertions, 445 deletions
diff --git a/video/out/gl_common.c b/video/out/gl_common.c index 3eeef29ea5..9384bc9e18 100644 --- a/video/out/gl_common.c +++ b/video/out/gl_common.c @@ -83,22 +83,12 @@ static int get_alignment(int stride) return 1; } -// adjusts the GL_UNPACK_ALIGNMENT to fit the stride. -void glAdjustAlignment(GL *gl, int stride) -{ - GLint gl_alignment = get_alignment(stride); - gl->PixelStorei(GL_UNPACK_ALIGNMENT, gl_alignment); - gl->PixelStorei(GL_PACK_ALIGNMENT, gl_alignment); -} - struct feature { int id; const char *name; }; static const struct feature features[] = { - {MPGL_CAP_GL_LEGACY, "Legacy OpenGL"}, - {MPGL_CAP_GL21, "OpenGL 2.1+ (or subset)"}, {MPGL_CAP_FB, "Framebuffers"}, {MPGL_CAP_VAO, "VAOs"}, {MPGL_CAP_SRGB_TEX, "sRGB textures"}, @@ -146,91 +136,62 @@ struct gl_functions { int ver_removed; // removed as required function (no replacement) int ver_es_core; // introduced as required GL ES function int ver_es_removed; // removed as required function (no replacement) - bool partial_ok; // loading only some functions is ok const struct gl_function *functions; }; -#define MAX_FN_COUNT 50 // max functions per gl_functions section +#define MAX_FN_COUNT 100 // max functions per gl_functions section // Note: to keep the number of sections low, some functions are in multiple // sections (if there are tricky combinations of GL/ES versions) static const struct gl_functions gl_functions[] = { - // GL functions which are always available anywhere at least since 1.1/ES2.0 - { - .ver_core = 110, - .ver_es_core = 200, - .functions = (const struct gl_function[]) { - DEF_FN(BlendFunc), - DEF_FN(Clear), - DEF_FN(ClearColor), - DEF_FN(ColorMask), - DEF_FN(DeleteTextures), - DEF_FN(DepthMask), - DEF_FN(Disable), - DEF_FN(DrawArrays), - DEF_FN(Enable), - DEF_FN(Finish), - DEF_FN(Flush), - DEF_FN(GenTextures), - DEF_FN(GetBooleanv), - DEF_FN(GetError), - DEF_FN(GetIntegerv), - DEF_FN(GetString), - DEF_FN(PixelStorei), - DEF_FN(ReadPixels), - DEF_FN(TexImage2D), - DEF_FN(TexParameteri), - DEF_FN(TexParameterf), - DEF_FN(TexParameterfv), - DEF_FN(TexSubImage2D), - DEF_FN(Viewport), - {0} - }, - }, - // GL 1.1+ desktop only + // GL 2.1+ desktop and GLES 2.0+ (anything we support) + // Probably all of these are in GL 2.0 too, but we require GLSL 120. { - .ver_core = 110, - .provides = MPGL_CAP_ROW_LENGTH, - .functions = (const struct gl_function[]) { - DEF_FN(DrawBuffer), - DEF_FN(GetTexImage), - DEF_FN(GetTexLevelParameteriv), - DEF_FN(ReadBuffer), - DEF_FN(TexEnvi), - DEF_FN(TexImage1D), - {0} - }, - }, - // GL 2.1+ functions (also: GLSL 120 shaders) - // All of the listed functions are also in GL 2.0 and ES 2.0 - { - .ver_core = 210, // not 200, so that we're guaranteed GLSL 120 + .ver_core = 210, .ver_es_core = 200, - .provides = MPGL_CAP_GL21, .functions = (const struct gl_function[]) { DEF_FN(ActiveTexture), DEF_FN(AttachShader), DEF_FN(BindAttribLocation), DEF_FN(BindBuffer), DEF_FN(BindTexture), + DEF_FN(BlendFuncSeparate), DEF_FN(BufferData), + DEF_FN(Clear), + DEF_FN(ClearColor), DEF_FN(CompileShader), DEF_FN(CreateProgram), DEF_FN(CreateShader), DEF_FN(DeleteBuffers), DEF_FN(DeleteProgram), DEF_FN(DeleteShader), + DEF_FN(DeleteTextures), + DEF_FN(Disable), DEF_FN(DisableVertexAttribArray), + DEF_FN(DrawArrays), + DEF_FN(Enable), DEF_FN(EnableVertexAttribArray), - DEF_FN(GetAttribLocation), + DEF_FN(Finish), + DEF_FN(Flush), DEF_FN(GenBuffers), - DEF_FN(GetShaderInfoLog), - DEF_FN(GetShaderiv), + DEF_FN(GenTextures), + DEF_FN(GetBooleanv), + DEF_FN(GetAttribLocation), + DEF_FN(GetError), + DEF_FN(GetIntegerv), DEF_FN(GetProgramInfoLog), DEF_FN(GetProgramiv), + DEF_FN(GetShaderInfoLog), + DEF_FN(GetShaderiv), + DEF_FN(GetString), DEF_FN(GetUniformLocation), DEF_FN(LinkProgram), + DEF_FN(PixelStorei), + DEF_FN(ReadPixels), DEF_FN(ShaderSource), + DEF_FN(TexImage2D), + DEF_FN(TexParameteri), + DEF_FN(TexSubImage2D), DEF_FN(Uniform1f), DEF_FN(Uniform2f), DEF_FN(Uniform3f), @@ -239,23 +200,28 @@ static const struct gl_functions gl_functions[] = { DEF_FN(UniformMatrix3fv), DEF_FN(UseProgram), DEF_FN(VertexAttribPointer), - // Added in GL 1.4 and ES 2.0, but vo_opengl_old doesn't need it - DEF_FN(BlendFuncSeparate), - {0}, + DEF_FN(Viewport), + {0} }, }, - // GL 2.1+ desktop only, GLSL 120 + // GL 2.1+ desktop only (and GLSL 120 shaders) { .ver_core = 210, - .provides = MPGL_CAP_3D_TEX | MPGL_CAP_1ST_CLASS_ARRAYS, + .provides = MPGL_CAP_ROW_LENGTH | MPGL_CAP_3D_TEX | + MPGL_CAP_1ST_CLASS_ARRAYS, .functions = (const struct gl_function[]) { + DEF_FN(DrawBuffer), + DEF_FN(GetTexImage), + DEF_FN(GetTexLevelParameteriv), DEF_FN(MapBuffer), + DEF_FN(ReadBuffer), + DEF_FN(TexImage1D), DEF_FN(TexImage3D), DEF_FN(UnmapBuffer), {0} }, }, - // GL+ES 3.x core only functions. + // GL 3.0+ and ES 3.x core only functions. { .ver_core = 300, .ver_es_core = 300, @@ -364,77 +330,6 @@ static const struct gl_functions gl_functions[] = { {0}, }, }, - // GL legacy functions in GL 1.x - 2.x, removed from GL 3.x - { - .ver_core = 110, - .ver_removed = 300, - .provides = MPGL_CAP_GL_LEGACY, - .functions = (const struct gl_function[]) { - DEF_FN(Begin), - DEF_FN(End), - DEF_FN(MatrixMode), - DEF_FN(LoadIdentity), - DEF_FN(Translated), - DEF_FN(Scaled), - DEF_FN(Ortho), - DEF_FN(PushMatrix), - DEF_FN(PopMatrix), - DEF_FN(GenLists), - DEF_FN(DeleteLists), - DEF_FN(NewList), - DEF_FN(EndList), - DEF_FN(CallList), - DEF_FN(CallLists), - DEF_FN(Color4ub), - DEF_FN(Color4f), - DEF_FN(TexCoord2f), - DEF_FN(TexCoord2fv), - DEF_FN(Vertex2f), - DEF_FN(VertexPointer), - DEF_FN(ColorPointer), - DEF_FN(TexCoordPointer), - DEF_FN(EnableClientState), - DEF_FN(DisableClientState), - {0} - }, - }, - // Loading of old extensions, which are later added to GL 2.0. - // NOTE: actually we should be checking the extension strings: the OpenGL - // library could provide an entry point, but not implement it. - // But the previous code didn't do that, and nobody ever complained. - { - .ver_removed = 210, - .ver_es_removed = 100, - .partial_ok = true, - .functions = (const struct gl_function[]) { - DEF_FN_NAMES(GenBuffers, "glGenBuffers", "glGenBuffersARB"), - DEF_FN_NAMES(DeleteBuffers, "glDeleteBuffers", "glDeleteBuffersARB"), - DEF_FN_NAMES(BindBuffer, "glBindBuffer", "glBindBufferARB"), - DEF_FN_NAMES(MapBuffer, "glMapBuffer", "glMapBufferARB"), - DEF_FN_NAMES(UnmapBuffer, "glUnmapBuffer", "glUnmapBufferARB"), - DEF_FN_NAMES(BufferData, "glBufferData", "glBufferDataARB"), - DEF_FN_NAMES(ActiveTexture, "glActiveTexture", "glActiveTextureARB"), - DEF_FN_NAMES(BindTexture, "glBindTexture", "glBindTextureARB", "glBindTextureEXT"), - DEF_FN_NAMES(MultiTexCoord2f, "glMultiTexCoord2f", "glMultiTexCoord2fARB"), - DEF_FN_NAMES(TexImage3D, "glTexImage3D"), - {0} - }, - }, - // Ancient ARB shaders. - { - .extension = "_program", - .ver_removed = 300, - .ver_es_removed = 100, - .functions = (const struct gl_function[]) { - DEF_FN_NAMES(GenPrograms, "glGenProgramsARB"), - DEF_FN_NAMES(DeletePrograms, "glDeleteProgramsARB"), - DEF_FN_NAMES(BindProgram, "glBindProgramARB"), - DEF_FN_NAMES(ProgramString, "glProgramStringARB"), - DEF_FN_NAMES(GetProgramivARB, "glGetProgramivARB"), - DEF_FN_NAMES(ProgramEnvParameter4f, "glProgramEnvParameter4fARB"), - {0} - }, - }, // For gl_hwdec_vdpau.c // http://www.opengl.org/registry/specs/NV/vdpau_interop.txt { @@ -495,7 +390,7 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), gl->GetString = get_fn(fn_ctx, "glGetString"); if (!gl->GetString) { mp_err(log, "Can't load OpenGL functions.\n"); - return; + goto error; } int major = 0, minor = 0; @@ -514,7 +409,7 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), gl->version = 0; if (gl->es < 200) { mp_fatal(log, "At least GLESv2 required.\n"); - return; + goto error; } } @@ -536,7 +431,7 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), gl->GetIntegerv = get_fn(fn_ctx, "glGetIntegerv"); if (!(gl->GetStringi && gl->GetIntegerv)) - return; + goto error; GLint exts; gl->GetIntegerv(GL_NUM_EXTENSIONS, &exts); @@ -587,9 +482,6 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), if (section->extension && strstr(gl->extensions, section->extension)) exists = true; - if (section->partial_ok) - exists = true; // possibly - exists |= must_exist; if (!exists) continue; @@ -608,24 +500,22 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), } if (!ptr) { all_loaded = false; - if (!section->partial_ok) { - mp_warn(log, "Required function '%s' not " - "found for %s OpenGL %d.%d.\n", fn->funcnames[0], - section->extension ? section->extension : "builtin", - MPGL_VER_GET_MAJOR(ver_core), - MPGL_VER_GET_MINOR(ver_core)); - if (must_exist) { - gl->mpgl_caps = 0; - return; - } - break; + mp_warn(log, "Required function '%s' not " + "found for %s OpenGL %d.%d.\n", fn->funcnames[0], + section->extension ? section->extension : "builtin", + MPGL_VER_GET_MAJOR(ver_core), + MPGL_VER_GET_MINOR(ver_core)); + if (must_exist) { + gl->mpgl_caps = 0; + goto error; } + break; } assert(i < MAX_FN_COUNT); loaded[i] = ptr; } - if (all_loaded || section->partial_ok) { + if (all_loaded) { gl->mpgl_caps |= section->provides; for (int i = 0; fnlist && fnlist[i].funcnames[0]; i++) { const struct gl_function *fn = &fnlist[i]; @@ -669,6 +559,12 @@ void mpgl_load_functions2(GL *gl, void *(*get_fn)(void *ctx, const char *n), // Provided for simpler handling if no framebuffer support is available. if (!gl->BindFramebuffer) gl->BindFramebuffer = &dummy_glBindFramebuffer; + return; + +error: + gl->version = 0; + gl->es = 0; + gl->mpgl_caps = 0; } static void *get_procaddr_wrapper(void *ctx, const char *name) @@ -715,7 +611,6 @@ int glFmt2bpp(GLenum format, GLenum type) case GL_LUMINANCE: case GL_ALPHA: return component_size; - case GL_YCBCR_MESA: case GL_RGB_422_APPLE: return 2; case GL_RGB: @@ -945,26 +840,19 @@ static MPGLContext *mpgl_create(struct vo *vo, const char *backend_name) return ctx; } -MPGLContext *mpgl_init(struct vo *vo, const char *backend_name, - int gl_flavor, int vo_flags) +MPGLContext *mpgl_init(struct vo *vo, const char *backend_name, int vo_flags) { MPGLContext *ctx = mpgl_create(vo, backend_name); if (!ctx) goto cleanup; - // A bit strange; but <300 triggers legacy context creation in mpv code. - ctx->requested_gl_version = gl_flavor < 210 ? 210 : 300; + ctx->requested_gl_version = 300; if (!ctx->config_window(ctx, vo_flags | VOFLAG_HIDDEN)) goto cleanup; - if (gl_flavor >= 210 && !(ctx->gl->mpgl_caps & MPGL_CAP_GL21)) { - MP_WARN(ctx->vo, "At least OpenGL 2.1 required.\n"); - goto cleanup; - } else if (gl_flavor < 210 && !(ctx->gl->mpgl_caps & MPGL_CAP_GL_LEGACY)) { - MP_WARN(ctx->vo, "OpenGL context creation failed!\n"); + if (!ctx->gl->version && !ctx->gl->es) goto cleanup; - } if (ctx->gl->es && vo->probing) { MP_INFO(ctx->vo, "Skipping experimental GLES support (use --vo=opengl).\n"); diff --git a/video/out/gl_common.h b/video/out/gl_common.h index 92ba81a249..81437b0852 100644 --- a/video/out/gl_common.h +++ b/video/out/gl_common.h @@ -55,7 +55,6 @@ struct GL; typedef struct GL GL; -void glAdjustAlignment(GL *gl, int stride); int glFmt2bpp(GLenum format, GLenum type); void glUploadTex(GL *gl, GLenum target, GLenum format, GLenum type, const void *dataptr, int stride, @@ -68,8 +67,6 @@ void glCheckError(GL *gl, struct mp_log *log, const char *info); mp_image_t *glGetWindowScreenshot(GL *gl); enum { - MPGL_CAP_GL_LEGACY = (1 << 1), // GL 1.1 (excluding 3.x) - MPGL_CAP_GL21 = (1 << 3), // GL 2.1+ (excluding legacy) MPGL_CAP_ROW_LENGTH = (1 << 4), // GL_[UN]PACK_ROW_LENGTH MPGL_CAP_FB = (1 << 5), MPGL_CAP_VAO = (1 << 6), @@ -142,8 +139,7 @@ bool mpgl_is_thread_safe(MPGLContext *ctx); // gl_flavor: 110 for legacy GL, 210 for GL 2.1 or 3.x core // flags: passed to the backend's create window function // Returns success. -MPGLContext *mpgl_init(struct vo *vo, const char *backend_name, - int gl_flavor, int vo_flags); +MPGLContext *mpgl_init(struct vo *vo, const char *backend_name, int vo_flags); void mpgl_uninit(MPGLContext *ctx); // flags: passed to the backend function @@ -184,26 +180,10 @@ struct GL { int mpgl_caps; // Bitfield of MPGL_CAP_* constants bool debug_context; // use of e.g. GLX_CONTEXT_DEBUG_BIT_ARB - void (GLAPIENTRY *Begin)(GLenum); - void (GLAPIENTRY *End)(void); void (GLAPIENTRY *Viewport)(GLint, GLint, GLsizei, GLsizei); - void (GLAPIENTRY *MatrixMode)(GLenum); - void (GLAPIENTRY *LoadIdentity)(void); - void (GLAPIENTRY *Translated)(double, double, double); - void (GLAPIENTRY *Scaled)(double, double, double); - void (GLAPIENTRY *Ortho)(double, double, double, double, double,double); - void (GLAPIENTRY *PushMatrix)(void); - void (GLAPIENTRY *PopMatrix)(void); void (GLAPIENTRY *Clear)(GLbitfield); - GLuint (GLAPIENTRY *GenLists)(GLsizei); - void (GLAPIENTRY *DeleteLists)(GLuint, GLsizei); - void (GLAPIENTRY *NewList)(GLuint, GLenum); - void (GLAPIENTRY *EndList)(void); - void (GLAPIENTRY *CallList)(GLuint); - void (GLAPIENTRY *CallLists)(GLsizei, GLenum, const GLvoid *); void (GLAPIENTRY *GenTextures)(GLsizei, GLuint *); void (GLAPIENTRY *DeleteTextures)(GLsizei, const GLuint *); - void (GLAPIENTRY *TexEnvi)(GLenum, GLenum, GLint); void (GLAPIENTRY *Color4ub)(GLubyte, GLubyte, GLubyte, GLubyte); void (GLAPIENTRY *Color4f)(GLfloat, GLfloat, GLfloat, GLfloat); void (GLAPIENTRY *ClearColor)(GLclampf, GLclampf, GLclampf, GLclampf); @@ -211,8 +191,6 @@ struct GL { void (GLAPIENTRY *Disable)(GLenum); const GLubyte *(GLAPIENTRY * GetString)(GLenum); void (GLAPIENTRY *DrawBuffer)(GLenum); - void (GLAPIENTRY *DepthMask)(GLboolean); - void (GLAPIENTRY *BlendFunc)(GLenum, GLenum); void (GLAPIENTRY *BlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum); void (GLAPIENTRY *Flush)(void); void (GLAPIENTRY *Finish)(void); @@ -226,27 +204,15 @@ struct GL { const GLvoid *); void (GLAPIENTRY *GetTexImage)(GLenum, GLint, GLenum, GLenum, GLvoid *); void (GLAPIENTRY *TexParameteri)(GLenum, GLenum, GLint); - void (GLAPIENTRY *TexParameterf)(GLenum, GLenum, GLfloat); - void (GLAPIENTRY *TexParameterfv)(GLenum, GLenum, const GLfloat *); - void (GLAPIENTRY *TexCoord2f)(GLfloat, GLfloat); - void (GLAPIENTRY *TexCoord2fv)(const GLfloat *); - void (GLAPIENTRY *Vertex2f)(GLfloat, GLfloat); void (GLAPIENTRY *GetIntegerv)(GLenum, GLint *); void (GLAPIENTRY *GetBooleanv)(GLenum, GLboolean *); - void (GLAPIENTRY *ColorMask)(GLboolean, GLboolean, GLboolean, GLboolean); void (GLAPIENTRY *ReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *); void (GLAPIENTRY *ReadBuffer)(GLenum); - void (GLAPIENTRY *VertexPointer)(GLint, GLenum, GLsizei, const GLvoid *); - void (GLAPIENTRY *ColorPointer)(GLint, GLenum, GLsizei, const GLvoid *); - void (GLAPIENTRY *TexCoordPointer)(GLint, GLenum, GLsizei, const GLvoid *); void (GLAPIENTRY *DrawArrays)(GLenum, GLint, GLsizei); - void (GLAPIENTRY *EnableClientState)(GLenum); - void (GLAPIENTRY *DisableClientState)(GLenum); GLenum (GLAPIENTRY *GetError)(void); void (GLAPIENTRY *GetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint *); - void (GLAPIENTRY *GenBuffers)(GLsizei, GLuint *); void (GLAPIENTRY *DeleteBuffers)(GLsizei, const GLuint *); void (GLAPIENTRY *BindBuffer)(GLenum, GLuint); @@ -255,14 +221,6 @@ struct GL { void (GLAPIENTRY *BufferData)(GLenum, intptr_t, const GLvoid *, GLenum); void (GLAPIENTRY *ActiveTexture)(GLenum); void (GLAPIENTRY *BindTexture)(GLenum, GLuint); - void (GLAPIENTRY *MultiTexCoord2f)(GLenum, GLfloat, GLfloat); - void (GLAPIENTRY *GenPrograms)(GLsizei, GLuint *); - void (GLAPIENTRY *DeletePrograms)(GLsizei, const GLuint *); - void (GLAPIENTRY *BindProgram)(GLenum, GLuint); - void (GLAPIENTRY *ProgramString)(GLenum, GLenum, GLsizei, const GLvoid *); - void (GLAPIENTRY *GetProgramivARB)(GLenum, GLenum, GLint *); - void (GLAPIENTRY *ProgramEnvParameter4f)(GLenum, GLuint, GLfloat, GLfloat, - GLfloat, GLfloat); int (GLAPIENTRY *SwapInterval)(int); void (GLAPIENTRY *TexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, diff --git a/video/out/gl_header_fixes.h b/video/out/gl_header_fixes.h index 0a8cef9684..d7c48b3f0b 100644 --- a/video/out/gl_header_fixes.h +++ b/video/out/gl_header_fixes.h @@ -34,132 +34,15 @@ #endif #endif -#ifndef GL_TEXTURE_3D -#define GL_TEXTURE_3D 0x806F -#endif -#ifndef GL_TEXTURE_WRAP_R -#define GL_TEXTURE_WRAP_R 0x8072 -#endif -#ifndef GL_CLAMP_TO_EDGE -#define GL_CLAMP_TO_EDGE 0x812F -#endif -#ifndef GL_GENERATE_MIPMAP -#define GL_GENERATE_MIPMAP 0x8191 -#endif -#ifndef GL_MAX_TEXTURE_UNITS -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#endif -#ifndef GL_TEXTURE0 -#define GL_TEXTURE0 0x84C0 -#endif -#ifndef GL_TEXTURE1 -#define GL_TEXTURE1 0x84C1 -#endif -#ifndef GL_TEXTURE2 -#define GL_TEXTURE2 0x84C2 -#endif -#ifndef GL_TEXTURE3 -#define GL_TEXTURE3 0x84C3 -#endif #ifndef GL_TEXTURE_RECTANGLE #define GL_TEXTURE_RECTANGLE 0x84F5 #endif -#ifndef GL_PIXEL_UNPACK_BUFFER -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#endif -#ifndef GL_STREAM_DRAW -#define GL_STREAM_DRAW 0x88E0 -#endif -#ifndef GL_DYNAMIC_DRAW -#define GL_DYNAMIC_DRAW 0x88E8 -#endif -#ifndef GL_WRITE_ONLY -#define GL_WRITE_ONLY 0x88B9 -#endif -#ifndef GL_BGR -#define GL_BGR 0x80E0 -#endif -#ifndef GL_BGRA -#define GL_BGRA 0x80E1 -#endif -#ifndef GL_UNSIGNED_BYTE_3_3_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#endif -#ifndef GL_UNSIGNED_BYTE_2_3_3_REV -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#endif -#ifndef GL_UNSIGNED_SHORT_4_4_4_4 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#endif -#ifndef GL_UNSIGNED_SHORT_4_4_4_4_REV -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#endif -#ifndef GL_UNSIGNED_SHORT_5_6_5 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#endif -#ifndef GL_UNSIGNED_INT_8_8_8_8 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#endif -#ifndef GL_UNSIGNED_INT_8_8_8_8_REV -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#endif -#ifndef GL_UNSIGNED_SHORT_5_6_5_REV -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#endif -#ifndef GL_UNSIGNED_INT_10_10_10_2 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#endif -#ifndef GL_UNSIGNED_INT_2_10_10_10_REV -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#endif -#ifndef GL_UNSIGNED_SHORT_5_5_5_1 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#endif -#ifndef GL_UNSIGNED_SHORT_1_5_5_5_REV -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#endif #ifndef GL_UNSIGNED_SHORT_8_8 #define GL_UNSIGNED_SHORT_8_8 0x85BA #endif #ifndef GL_UNSIGNED_SHORT_8_8_REV #define GL_UNSIGNED_SHORT_8_8_REV 0x85BB #endif -#ifndef GL_YCBCR_MESA -#define GL_YCBCR_MESA 0x8757 -#endif -#ifndef GL_RGB32F -#define GL_RGB32F 0x8815 -#endif -#ifndef GL_FLOAT_RGB32_NV -#define GL_FLOAT_RGB32_NV 0x8889 -#endif -#ifndef GL_LUMINANCE16 -#define GL_LUMINANCE16 0x8042 -#endif -#ifndef GL_R16 -#define GL_R16 0x822A -#endif -#ifndef GL_UNPACK_CLIENT_STORAGE_APPLE -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif -#ifndef GL_FRAGMENT_PROGRAM -#define GL_FRAGMENT_PROGRAM 0x8804 -#endif -#ifndef GL_PROGRAM_FORMAT_ASCII -#define GL_PROGRAM_FORMAT_ASCII 0x8875 -#endif -#ifndef GL_PROGRAM_ERROR_POSITION -#define GL_PROGRAM_ERROR_POSITION 0x864B -#endif -#ifndef GL_MAX_TEXTURE_IMAGE_UNITS -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#endif -#ifndef GL_PROGRAM_ERROR_STRING -#define GL_PROGRAM_ERROR_STRING 0x8874 -#endif -#ifndef GL_RGBA32F -#define GL_RGBA32F 0x8814 -#endif #if HAVE_GL_WIN32 && !defined(WGL_CONTEXT_MAJOR_VERSION_ARB) /* these are supposed to be defined in wingdi.h but mingw's is too old */ diff --git a/video/out/gl_osd.c b/video/out/gl_osd.c index 5477b24197..8a92d3ee8c 100644 --- a/video/out/gl_osd.c +++ b/video/out/gl_osd.c @@ -52,13 +52,7 @@ static const struct osd_fmt_entry osd_to_gl2_formats[SUBBITMAP_COUNT] = { [SUBBITMAP_RGBA] = {GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE}, }; -static const struct osd_fmt_entry osd_to_gl_legacy_formats[SUBBITMAP_COUNT] = { - [SUBBITMAP_LIBASS] = {GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE}, - [SUBBITMAP_RGBA] = {GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE}, -}; - -struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd, - bool legacy) +struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd) { GLint max_texture_size; gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); @@ -72,9 +66,7 @@ struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd .scratch = talloc_zero_size(ctx, 1), }; - if (legacy) { - ctx->fmt_table = osd_to_gl_legacy_formats; - } else if (gl->es >= 300) { + if (gl->es >= 300) { ctx->fmt_table = osd_to_gles3_formats; } else if (!(gl->mpgl_caps & MPGL_CAP_TEX_RG)) { ctx->fmt_table = osd_to_gl2_formats; @@ -257,11 +249,7 @@ void mpgl_osd_set_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p) gl->Enable(GL_BLEND); const int *factors = &blend_factors[p->format][0]; - if (gl->BlendFuncSeparate) { - gl->BlendFuncSeparate(factors[0], factors[1], factors[2], factors[3]); - } else { - gl->BlendFunc(factors[0], factors[1]); - } + gl->BlendFuncSeparate(factors[0], factors[1], factors[2], factors[3]); } void mpgl_osd_unset_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p) @@ -271,88 +259,3 @@ void mpgl_osd_unset_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p) gl->Disable(GL_BLEND); gl->BindTexture(GL_TEXTURE_2D, 0); } - -struct vertex { - float position[2]; - uint8_t color[4]; - float texcoord[2]; -}; - -static void draw_legacy_cb(void *pctx, struct sub_bitmaps *imgs) -{ - struct mpgl_osd *ctx = pctx; - struct mpgl_osd_part *osd = mpgl_osd_generate(ctx, imgs); - if (!osd) - return; - - if (!osd->num_vertices) { - // 2 triangles primitives per quad = 6 vertices per quad - // not using GL_QUADS, as it is deprecated in OpenGL 3.x and later - osd->vertices = talloc_realloc(osd, osd->vertices, struct vertex, - osd->packer->count * 6); - - struct vertex *va = osd->vertices; - float tex_w = osd->w; - float tex_h = osd->h; - - for (int n = 0; n < osd->packer->count; n++) { - struct sub_bitmap *b = &imgs->parts[n]; - struct pos p = osd->packer->result[n]; - - uint32_t c = imgs->format == SUBBITMAP_LIBASS - ? b->libass.color : 0xFFFFFF00; - uint8_t color[4] = { c >> 24, (c >> 16) & 0xff, - (c >> 8) & 0xff, 255 - (c & 0xff) }; - - float x0 = b->x; - float y0 = b->y; - float x1 = b->x + b->dw; - float y1 = b->y + b->dh; - float tx0 = p.x / tex_w; - float ty0 = p.y / tex_h; - float tx1 = (p.x + b->w) / tex_w; - float ty1 = (p.y + b->h) / tex_h; - -#define COLOR_INIT {color[0], color[1], color[2], color[3]} - struct vertex *v = &va[osd->num_vertices]; - v[0] = (struct vertex) { {x0, y0}, COLOR_INIT, {tx0, ty0} }; - v[1] = (struct vertex) { {x0, y1}, COLOR_INIT, {tx0, ty1} }; - v[2] = (struct vertex) { {x1, y0}, COLOR_INIT, {tx1, ty0} }; - v[3] = (struct vertex) { {x1, y1}, COLOR_INIT, {tx1, ty1} }; - v[4] = v[2]; - v[5] = v[1]; -#undef COLOR_INIT - osd->num_vertices += 6; - } - } - - GL *gl = ctx->gl; - - struct vertex *va = osd->vertices; - size_t stride = sizeof(va[0]); - - gl->VertexPointer(2, GL_FLOAT, stride, &va[0].position[0]); - gl->ColorPointer(4, GL_UNSIGNED_BYTE, stride, &va[0].color[0]); - gl->TexCoordPointer(2, GL_FLOAT, stride, &va[0].texcoord[0]); - - gl->EnableClientState(GL_VERTEX_ARRAY); - gl->EnableClientState(GL_TEXTURE_COORD_ARRAY); - gl->EnableClientState(GL_COLOR_ARRAY); - - mpgl_osd_set_gl_state(ctx, osd); - gl->DrawArrays(GL_TRIANGLES, 0, osd->num_vertices); - mpgl_osd_unset_gl_state(ctx, osd); - - gl->DisableClientState(GL_VERTEX_ARRAY); - gl->DisableClientState(GL_TEXTURE_COORD_ARRAY); - gl->DisableClientState(GL_COLOR_ARRAY); -} - -void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, double pts, - struct mp_osd_res res) -{ - ctx->fmt_table = osd_to_gl_legacy_formats; - for (int n = 0; n < SUBBITMAP_COUNT; n++) - ctx->formats[n] = ctx->fmt_table[n].type != 0; - osd_draw(ctx->osd, res, pts, 0, ctx->formats, draw_legacy_cb, ctx); -} diff --git a/video/out/gl_osd.h b/video/out/gl_osd.h index f05385b547..fce87bafe4 100644 --- a/video/out/gl_osd.h +++ b/video/out/gl_osd.h @@ -30,8 +30,7 @@ struct mpgl_osd { void *scratch; }; -struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd, - bool legacy); +struct mpgl_osd *mpgl_osd_init(GL *gl, struct mp_log *log, struct osd_state *osd); void mpgl_osd_destroy(struct mpgl_osd *ctx); struct mpgl_osd_part *mpgl_osd_generate(struct mpgl_osd *ctx, @@ -40,7 +39,4 @@ struct mpgl_osd_part *mpgl_osd_generate(struct mpgl_osd *ctx, void mpgl_osd_set_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p); void mpgl_osd_unset_gl_state(struct mpgl_osd *ctx, struct mpgl_osd_part *p); -void mpgl_osd_draw_legacy(struct mpgl_osd *ctx, double pts, - struct mp_osd_res res); - #endif diff --git a/video/out/gl_video.c b/video/out/gl_video.c index 50be85d3fe..9aacf57ae9 100644 --- a/video/out/gl_video.c +++ b/video/out/gl_video.c @@ -1417,7 +1417,7 @@ static void recreate_osd(struct gl_video *p) { if (p->osd) mpgl_osd_destroy(p->osd); - p->osd = mpgl_osd_init(p->gl, p->log, p->osd_state, false); + p->osd = mpgl_osd_init(p->gl, p->log, p->osd_state); p->osd->use_pbo = p->opts.pbo; } @@ -2551,7 +2551,7 @@ void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b) struct gl_video *gl_video_init(GL *gl, struct mp_log *log, struct osd_state *osd) { - if (!(gl->mpgl_caps & MPGL_CAP_GL21)) { + if (gl->version < 210 && gl->es < 200) { mp_err(log, "At least OpenGL 2.1 or OpenGL ES 2.0 required.\n"); return NULL; } diff --git a/video/out/gl_w32.c b/video/out/gl_w32.c index abdea60775..3af58cf21d 100644 --- a/video/out/gl_w32.c +++ b/video/out/gl_w32.c @@ -202,8 +202,7 @@ static void create_ctx(void *ptr) if (!create_dc(ctx, w32_ctx->flags)) return; - if (ctx->requested_gl_version >= MPGL_VER(3, 0)) - create_context_w32_gl3(ctx); + create_context_w32_gl3(ctx); if (!w32_ctx->context) create_context_w32_old(ctx); wglMakeCurrent(w32_ctx->hdc, NULL); diff --git a/video/out/gl_x11.c b/video/out/gl_x11.c index b99f5ccc0a..fa1ab62a28 100644 --- a/video/out/gl_x11.c +++ b/video/out/gl_x11.c @@ -261,11 +261,12 @@ static bool config_window_x11(struct MPGLContext *ctx, int flags) int gl_version = ctx->requested_gl_version; bool success = false; - if (gl_version >= 300 && !glx_ctx->force_es) + if (!glx_ctx->force_es) { success = create_context_x11_gl3(ctx, flags, gl_version, false); - if (!success && !glx_ctx->force_es) - success = create_context_x11_old(ctx); - if (!success && gl_version >= 300) // 3.00 = vo_opengl; accepts GLES 2 or 3 + if (!success) + success = create_context_x11_old(ctx); + } + if (!success) // try ES success = create_context_x11_gl3(ctx, flags, 200, true); if (success && !glXIsDirect(vo->x11->display, glx_ctx->context)) ctx->gl->mpgl_caps |= MPGL_CAP_SW; diff --git a/video/out/vo_opengl.c b/video/out/vo_opengl.c index 1d908148e3..54da31f2e3 100644 --- a/video/out/vo_opengl.c +++ b/video/out/vo_opengl.c @@ -412,7 +412,7 @@ static int preinit(struct vo *vo) if (p->allow_sw) vo->probing = false; - p->glctx = mpgl_init(vo, p->backend, 210, vo_flags); + p->glctx = mpgl_init(vo, p->backend, vo_flags); if (!p->glctx) goto err_out; p->gl = p->glctx->gl; |