gl/examples/cube*: choose opengl by default

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.
This commit is contained in:
Matthew Waters 2016-03-10 00:24:48 +11:00
parent bf6838d913
commit 59da66f969
2 changed files with 16 additions and 16 deletions

View file

@ -120,7 +120,8 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); 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(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f); glRotatef(yrot,0.0f,1.0f,0.0f);
@ -182,6 +183,9 @@ gint main (gint argc, gchar *argv[])
GMainLoop *loop; GMainLoop *loop;
GstBus *bus; GstBus *bus;
/* FIXME: remove once the example supports gl3 and/or gles2 */
g_setenv ("GST_GL_API", "opengl", FALSE);
/* initialization */ /* initialization */
gst_init (&argc, &argv); gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE); loop = g_main_loop_new (NULL, FALSE);

View file

@ -143,12 +143,13 @@ static gboolean drawCallback (GstElement * gl_sink, GstGLContext *context, GstSa
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glTranslatef(0.0f,0.0f,-5.0f);
glRotatef(xrot,1.0f,0.0f,0.0f); glRotatef(xrot,1.0f,0.0f,0.0f);
glRotatef(yrot,0.0f,1.0f,0.0f); glRotatef(yrot,0.0f,1.0f,0.0f);
glRotatef(zrot,0.0f,0.0f,1.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); glBegin(GL_QUADS);
// Front Face // Front Face
glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); 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); glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, 1.0f, -1.0f);
glEnd(); glEnd();
glDisable(GL_DEPTH_TEST);
gst_video_frame_unmap (&v_frame); gst_video_frame_unmap (&v_frame);
xrot+=0.03f; xrot+=0.03f;
@ -227,6 +230,9 @@ gint main (gint argc, gchar *argv[])
return -1; 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]); std::string video_location(argv[1]);
/* initialization */ /* initialization */
@ -247,22 +253,15 @@ gint main (gint argc, gchar *argv[])
GstElement* decodebin = gst_element_factory_make ("decodebin", "decodebin"); GstElement* decodebin = gst_element_factory_make ("decodebin", "decodebin");
GstElement* identity = gst_element_factory_make ("identity", "identity0"); GstElement* identity = gst_element_factory_make ("identity", "identity0");
GstElement* textoverlay = gst_element_factory_make ("textoverlay", "textoverlay0"); GstElement* textoverlay = gst_element_factory_make ("textoverlay", "textoverlay0");
GstElement* glcolorscale = gst_element_factory_make ("glcolorscale", "glcolorscale0");
GstElement* glimagesink = gst_element_factory_make ("glimagesink", "glimagesink0"); GstElement* glimagesink = gst_element_factory_make ("glimagesink", "glimagesink0");
if (!videosrc || !decodebin || !identity || !textoverlay || if (!videosrc || !decodebin || !identity || !textoverlay || !glimagesink)
!glcolorscale || !glimagesink)
{ {
g_print ("one element could not be found \n"); g_print ("one element could not be found \n");
return -1; return -1;
} }
GstCaps *outcaps = gst_caps_new_simple("video/x-raw",
"width", G_TYPE_INT, 640,
"height", G_TYPE_INT, 480,
NULL);
/* configure elements */ /* configure elements */
g_object_set(G_OBJECT(videosrc), "num-buffers", 800, NULL); g_object_set(G_OBJECT(videosrc), "num-buffers", 800, NULL);
g_object_set(G_OBJECT(videosrc), "location", video_location.c_str(), 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 */ /* add elements */
gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, identity, gst_bin_add_many (GST_BIN (pipeline), videosrc, decodebin, identity,
textoverlay, glcolorscale, glimagesink, NULL); textoverlay, glimagesink, NULL);
/* link elements */ /* link elements */
gst_element_link_pads (videosrc, "src", decodebin, "sink"); gst_element_link_pads (videosrc, "src", decodebin, "sink");
@ -286,10 +285,7 @@ gint main (gint argc, gchar *argv[])
return -1; return -1;
} }
gst_element_link (textoverlay, glcolorscale); gboolean link_ok = gst_element_link (textoverlay, glimagesink);
gboolean link_ok = gst_element_link_filtered(glcolorscale, glimagesink, outcaps) ;
gst_caps_unref(outcaps) ;
if(!link_ok) if(!link_ok)
{ {
g_warning("Failed to link textoverlay to glimagesink!\n") ; g_warning("Failed to link textoverlay to glimagesink!\n") ;