gl/examples/cube*: choose opengl by default
authorMatthew Waters <matthew@centricular.com>
Wed, 9 Mar 2016 13:24:48 +0000 (00:24 +1100)
committerTim-Philipp Müller <tim@centricular.com>
Sat, 9 Dec 2017 19:32:17 +0000 (19:32 +0000)
The examples don't work with any other GL API.

Also fix the yuv example to not translate the cube out of the clipping area.

tests/examples/gl/generic/cube/main.cpp
tests/examples/gl/generic/cubeyuv/main.cpp

index 3a54fe6..da4aa17 100644 (file)
@@ -120,7 +120,8 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
 
-    glScalef(0.5f,0.5f,0.5f);
+    /* invert the y-axis to get the front face the correct way up */
+    glScalef (0.5f, -0.5f, 0.5f);
 
     glRotatef(xrot,1.0f,0.0f,0.0f);
     glRotatef(yrot,0.0f,1.0f,0.0f);
@@ -182,6 +183,9 @@ gint main (gint argc, gchar *argv[])
     GMainLoop *loop;
     GstBus *bus;
 
+    /* FIXME: remove once the example supports gl3 and/or gles2 */
+    g_setenv ("GST_GL_API", "opengl", FALSE);
+
     /* initialization */
     gst_init (&argc, &argv);
     loop = g_main_loop_new (NULL, FALSE);
index 9c4b2cc..cda990f 100644 (file)
@@ -143,12 +143,13 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa
     glMatrixMode(GL_MODELVIEW);
     glLoadIdentity();
 
-    glTranslatef(0.0f,0.0f,-5.0f);
-
     glRotatef(xrot,1.0f,0.0f,0.0f);
     glRotatef(yrot,0.0f,1.0f,0.0f);
     glRotatef(zrot,0.0f,0.0f,1.0f);
 
+    /* invert the y-axis to get the front face the correct way up */
+    glScalef (0.5f, -0.5f, 0.5f);
+
     glBegin(GL_QUADS);
              // Front Face
              glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);
@@ -182,6 +183,8 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa
              glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f,  1.0f, -1.0f);
     glEnd();
 
+    glDisable(GL_DEPTH_TEST);
+
     gst_video_frame_unmap (&v_frame);
 
        xrot+=0.03f;
@@ -227,6 +230,9 @@ gint main (gint argc, gchar *argv[])
         return -1;
     }
 
+    /* FIXME: remove once the example supports gl3 and/or gles2 */
+    g_setenv ("GST_GL_API", "opengl", FALSE);
+
     std::string video_location(argv[1]);
 
     /* initialization */
@@ -247,22 +253,15 @@ gint main (gint argc, gchar *argv[])
     GstElement* decodebin = gst_element_factory_make ("decodebin", "decodebin");
     GstElement* identity  = gst_element_factory_make ("identity", "identity0");
     GstElement* textoverlay = gst_element_factory_make ("textoverlay", "textoverlay0");
-    GstElement* glcolorscale = gst_element_factory_make ("glcolorscale", "glcolorscale0");
     GstElement* glimagesink  = gst_element_factory_make ("glimagesink", "glimagesink0");
 
 
-    if (!videosrc || !decodebin || !identity || !textoverlay ||
-        !glcolorscale || !glimagesink)
+    if (!videosrc || !decodebin || !identity || !textoverlay || !glimagesink)
     {
         g_print ("one element could not be found \n");
         return -1;
     }
 
-    GstCaps *outcaps = gst_caps_new_simple("video/x-raw",
-                                           "width", G_TYPE_INT, 640,
-                                           "height", G_TYPE_INT, 480,
-                                           NULL);
-
     /* configure elements */
     g_object_set(G_OBJECT(videosrc), "num-buffers", 800, NULL);
     g_object_set(G_OBJECT(videosrc), "location", video_location.c_str(), NULL);
@@ -273,7 +272,7 @@ gint main (gint argc, gchar *argv[])
 
     /* add elements */
     gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, identity,
-        textoverlay, glcolorscale, glimagesink, NULL);
+        textoverlay, glimagesink, NULL);
 
     /* link elements */
        gst_element_link_pads (videosrc, "src", decodebin, "sink");
@@ -286,10 +285,7 @@ gint main (gint argc, gchar *argv[])
         return -1;
     }
 
-       gst_element_link (textoverlay, glcolorscale);
-
-    gboolean link_ok = gst_element_link_filtered(glcolorscale, glimagesink, outcaps) ;
-    gst_caps_unref(outcaps) ;
+    gboolean link_ok = gst_element_link (textoverlay, glimagesink);
     if(!link_ok)
     {
         g_warning("Failed to link textoverlay to glimagesink!\n") ;