mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-01 06:01:04 +00:00
glcontext: check for GLES versions
This commit is contained in:
parent
babef3069b
commit
bfd8550bff
1 changed files with 15 additions and 55 deletions
|
@ -598,50 +598,13 @@ gst_gl_context_create (GstGLContext * context,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_create_context_gles2 (GstGLContext * context, gint * gl_major, gint * gl_minor,
|
_create_context_info (GstGLContext * context, GstGLAPI gl_api, gint * gl_major,
|
||||||
GError ** error)
|
|
||||||
{
|
|
||||||
const GstGLFuncs *gl;
|
|
||||||
GLenum gl_err = GL_NO_ERROR;
|
|
||||||
|
|
||||||
gl = context->gl_vtable;
|
|
||||||
|
|
||||||
GST_INFO ("GL_VERSION: %s", gl->GetString (GL_VERSION));
|
|
||||||
GST_INFO ("GL_SHADING_LANGUAGE_VERSION: %s",
|
|
||||||
gl->GetString (GL_SHADING_LANGUAGE_VERSION));
|
|
||||||
GST_INFO ("GL_VENDOR: %s", gl->GetString (GL_VENDOR));
|
|
||||||
GST_INFO ("GL_RENDERER: %s", gl->GetString (GL_RENDERER));
|
|
||||||
|
|
||||||
gl_err = gl->GetError ();
|
|
||||||
if (gl_err != GL_NO_ERROR) {
|
|
||||||
g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_FAILED,
|
|
||||||
"glGetString error: 0x%x", gl_err);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#if GST_GL_HAVE_GLES2
|
|
||||||
if (!GL_ES_VERSION_2_0) {
|
|
||||||
g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_OLD_LIBS,
|
|
||||||
"OpenGL|ES >= 2.0 is required");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gl_major)
|
|
||||||
*gl_major = 2;
|
|
||||||
if (gl_minor)
|
|
||||||
*gl_minor = 0;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_create_context_opengl (GstGLContext * context, gint * gl_major,
|
|
||||||
gint * gl_minor, GError ** error)
|
gint * gl_minor, GError ** error)
|
||||||
{
|
{
|
||||||
const GstGLFuncs *gl;
|
const GstGLFuncs *gl;
|
||||||
guint maj, min;
|
guint maj, min;
|
||||||
GLenum gl_err = GL_NO_ERROR;
|
GLenum gl_err = GL_NO_ERROR;
|
||||||
GString *opengl_version = NULL;
|
gchar *opengl_version = NULL;
|
||||||
|
|
||||||
gl = context->gl_vtable;
|
gl = context->gl_vtable;
|
||||||
|
|
||||||
|
@ -657,19 +620,21 @@ _create_context_opengl (GstGLContext * context, gint * gl_major,
|
||||||
"glGetString error: 0x%x", gl_err);
|
"glGetString error: 0x%x", gl_err);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
opengl_version =
|
|
||||||
g_string_truncate (g_string_new ((gchar *) gl->GetString (GL_VERSION)),
|
|
||||||
3);
|
|
||||||
|
|
||||||
sscanf (opengl_version->str, "%d.%d", &maj, &min);
|
opengl_version = (gchar *) gl->GetString (GL_VERSION);
|
||||||
|
if (opengl_version && gl_api & GST_GL_API_GLES2)
|
||||||
|
/* gles starts with "OpenGL ES " */
|
||||||
|
opengl_version = &opengl_version[10];
|
||||||
|
|
||||||
g_string_free (opengl_version, TRUE);
|
sscanf (opengl_version, "%d.%d", &maj, &min);
|
||||||
|
|
||||||
/* OpenGL > 1.2.0 */
|
/* OpenGL > 1.2.0 */
|
||||||
if ((maj < 1) || (maj < 2 && maj >= 1 && min < 2)) {
|
if (gl_api & GST_GL_API_OPENGL || gl_api & GST_GL_API_OPENGL3) {
|
||||||
g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_OLD_LIBS,
|
if ((maj < 1) || (maj < 2 && maj >= 1 && min < 2)) {
|
||||||
"OpenGL >= 1.2.0 required, found %u.%u", maj, min);
|
g_set_error (error, GST_GL_CONTEXT_ERROR, GST_GL_CONTEXT_ERROR_OLD_LIBS,
|
||||||
return FALSE;
|
"OpenGL >= 1.2.0 required, found %u.%u", maj, min);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gl_major)
|
if (gl_major)
|
||||||
|
@ -835,13 +800,8 @@ gst_gl_context_create_thread (GstGLContext * context)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* gl api specific code */
|
/* gl api specific code */
|
||||||
if (!ret && gl_api & GST_GL_API_OPENGL)
|
ret = _create_context_info (context, gl_api, &context->priv->gl_major,
|
||||||
ret = _create_context_opengl (context, &context->priv->gl_major,
|
&context->priv->gl_minor, error);
|
||||||
&context->priv->gl_minor, error);
|
|
||||||
if (!ret && gl_api & GST_GL_API_GLES2)
|
|
||||||
ret =
|
|
||||||
_create_context_gles2 (context, &context->priv->gl_major,
|
|
||||||
&context->priv->gl_minor, error);
|
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
g_assert (error == NULL || *error != NULL);
|
g_assert (error == NULL || *error != NULL);
|
||||||
|
|
Loading…
Reference in a new issue