• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifdef HAVE_CONFIG_H
21 #  include "config.h"
22 #endif
23 
24 #include <gst/check/gstcheck.h>
25 
26 #include <gst/gl/gl.h>
27 #include <gst/gl/gstglfuncs.h>
28 
29 #include <stdio.h>
30 
31 static GstGLDisplay *display;
32 static GstGLContext *context;
33 
34 static void
setup(void)35 setup (void)
36 {
37   GError *error = NULL;
38 
39   display = gst_gl_display_new ();
40   context = gst_gl_context_new (display);
41 
42   gst_gl_context_create (context, NULL, &error);
43 
44   fail_if (error != NULL, "Error creating context: %s\n",
45       error ? error->message : "Unknown Error");
46 }
47 
48 static void
teardown(void)49 teardown (void)
50 {
51   gst_object_unref (display);
52   gst_object_unref (context);
53 }
54 
GST_START_TEST(test_default_vertex)55 GST_START_TEST (test_default_vertex)
56 {
57   GstGLSLStage *stage;
58   GError *error = NULL;
59 
60   stage = gst_glsl_stage_new_default_vertex (context);
61   fail_unless (stage != NULL);
62   fail_unless (GL_VERTEX_SHADER == gst_glsl_stage_get_shader_type (stage));
63 
64   fail_unless (gst_glsl_stage_compile (stage, &error));
65 
66   gst_object_unref (stage);
67 }
68 
69 GST_END_TEST;
70 
71 static void
create_frag_shader(GstGLContext * context,GstGLSLStage ** stage)72 create_frag_shader (GstGLContext * context, GstGLSLStage ** stage)
73 {
74   *stage = gst_glsl_stage_new_default_fragment (context);
75 }
76 
GST_START_TEST(test_default_fragment)77 GST_START_TEST (test_default_fragment)
78 {
79   GstGLSLStage *stage;
80   GError *error = NULL;
81 
82   gst_gl_context_thread_add (context,
83       (GstGLContextThreadFunc) create_frag_shader, &stage);
84 
85   fail_unless (stage != NULL);
86   fail_unless (GL_FRAGMENT_SHADER == gst_glsl_stage_get_shader_type (stage));
87 
88   fail_unless (gst_glsl_stage_compile (stage, &error));
89 
90   gst_object_unref (stage);
91 }
92 
93 GST_END_TEST;
94 
95 static Suite *
gst_gl_upload_suite(void)96 gst_gl_upload_suite (void)
97 {
98   Suite *s = suite_create ("GstGLSL");
99   TCase *tc_chain = tcase_create ("glsl");
100 
101   suite_add_tcase (s, tc_chain);
102   tcase_add_checked_fixture (tc_chain, setup, teardown);
103   tcase_add_test (tc_chain, test_default_vertex);
104   tcase_add_test (tc_chain, test_default_fragment);
105 
106   return s;
107 }
108 
109 GST_CHECK_MAIN (gst_gl_upload);
110