summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/check/libs/gstglcontext.c29
-rw-r--r--tests/check/libs/gstglupload.c43
2 files changed, 61 insertions, 11 deletions
diff --git a/tests/check/libs/gstglcontext.c b/tests/check/libs/gstglcontext.c
index 25f3e00cf..6b4778f16 100644
--- a/tests/check/libs/gstglcontext.c
+++ b/tests/check/libs/gstglcontext.c
@@ -42,9 +42,9 @@ teardown (void)
gst_object_unref (display);
}
-static GstGLMemory *gl_tex;
+static GstGLMemory *gl_tex, *gl_tex2;
static GLuint vbo, vbo_indices, vao;
-static GstGLFramebuffer *fbo;
+static GstGLFramebuffer *fbo, *fbo2;
static GstGLShader *shader;
static GLint shader_attr_position_loc;
static GLint shader_attr_texture_loc;
@@ -82,6 +82,9 @@ init (gpointer data)
gl_tex =
(GstGLMemory *) gst_gl_base_memory_alloc ((GstGLBaseMemoryAllocator *)
allocator, (GstGLAllocationParams *) params);
+ gl_tex2 =
+ (GstGLMemory *) gst_gl_base_memory_alloc ((GstGLBaseMemoryAllocator *)
+ allocator, (GstGLAllocationParams *) params);
gst_object_unref (allocator);
gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
fail_if (gl_tex == NULL, "failed to create texture");
@@ -106,6 +109,7 @@ deinit (gpointer data)
gst_object_unref (fbo);
gst_object_unref (shader);
gst_memory_unref (GST_MEMORY_CAST (gl_tex));
+ gst_memory_unref (GST_MEMORY_CAST (gl_tex2));
}
static gboolean
@@ -194,6 +198,10 @@ init_blit (gpointer data)
gl->BindBuffer (GL_ARRAY_BUFFER, 0);
gl->BindBuffer (GL_ELEMENT_ARRAY_BUFFER, 0);
}
+ /* has to be called in the thread that is going to use the framebuffer */
+ fbo2 = gst_gl_framebuffer_new_with_default_depth (context, 320, 240);
+
+ fail_if (fbo2 == NULL, "failed to create framebuffer object");
}
static void
@@ -211,13 +219,14 @@ deinit_blit (gpointer data)
if (vao)
gl->DeleteVertexArrays (1, &vao);
vao = 0;
+ gst_object_unref (fbo2);
+ fbo2 = NULL;
}
-static void
-draw_render (gpointer data)
+static gboolean
+blit_tex (gpointer data)
{
GstGLContext *context = data;
- GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context);
const GstGLFuncs *gl = context->gl_vtable;
gl->Clear (GL_COLOR_BUFFER_BIT);
@@ -240,7 +249,14 @@ draw_render (gpointer data)
else
_unbind_buffer (context);
- context_class->swap_buffers (context);
+ return TRUE;
+}
+
+static void
+draw_render (gpointer data)
+{
+ gst_gl_framebuffer_draw_to_texture (fbo2, gl_tex2,
+ (GstGLFramebufferFunc) blit_tex, data);
}
GST_START_TEST (test_share)
@@ -379,7 +395,6 @@ GST_START_TEST (test_wrapped_context)
fail_if (error != NULL, "Error creating secondary context %s\n",
error ? error->message : "Unknown Error");
- /* make the window visible */
gst_gl_window_set_preferred_size (window, 320, 240);
gst_gl_window_draw (window);
diff --git a/tests/check/libs/gstglupload.c b/tests/check/libs/gstglupload.c
index 707adb62c..af4322177 100644
--- a/tests/check/libs/gstglupload.c
+++ b/tests/check/libs/gstglupload.c
@@ -38,6 +38,8 @@ static GstGLShader *shader;
static GLint shader_attr_position_loc;
static GLint shader_attr_texture_loc;
static guint vbo, vbo_indices, vao;
+static GstGLFramebuffer *fbo;
+static GstGLMemory *fbo_tex;
static const GLfloat vertices[] = {
1.0f, 1.0f, 0.0f, 1.0f, 0.0f,
@@ -153,6 +155,25 @@ init (gpointer data)
shader_attr_texture_loc =
gst_gl_shader_get_attribute_location (shader, "a_texcoord");
+ fbo = gst_gl_framebuffer_new_with_default_depth (context, WIDTH, HEIGHT);
+
+ {
+ GstGLMemoryAllocator *allocator;
+ GstGLVideoAllocationParams *params;
+ GstVideoInfo v_info;
+
+ allocator = gst_gl_memory_allocator_get_default (context);
+ gst_video_info_set_format (&v_info, GST_VIDEO_FORMAT_RGBA, WIDTH, HEIGHT);
+ params =
+ gst_gl_video_allocation_params_new (context, NULL, &v_info, 0, NULL,
+ GST_GL_TEXTURE_TARGET_2D, FORMAT);
+ fbo_tex =
+ (GstGLMemory *) gst_gl_base_memory_alloc ((GstGLBaseMemoryAllocator *)
+ allocator, (GstGLAllocationParams *) params);
+ gst_object_unref (allocator);
+ gst_gl_allocation_params_free ((GstGLAllocationParams *) params);
+ }
+
if (!vbo) {
if (gl->GenVertexArrays) {
gl->GenVertexArrays (1, &vao);
@@ -194,13 +215,20 @@ deinit (gpointer data)
if (vao)
gl->DeleteVertexArrays (1, &vao);
vao = 0;
+
+ if (fbo)
+ gst_object_unref (fbo);
+ fbo = NULL;
+
+ if (fbo_tex)
+ gst_memory_unref (GST_MEMORY_CAST (fbo_tex));
+ fbo_tex = NULL;
}
-static void
-draw_render (gpointer data)
+static gboolean
+blit_tex (gpointer data)
{
GstGLContext *context = data;
- GstGLContextClass *context_class = GST_GL_CONTEXT_GET_CLASS (context);
const GstGLFuncs *gl = context->gl_vtable;
gl->Clear (GL_COLOR_BUFFER_BIT);
@@ -223,7 +251,14 @@ draw_render (gpointer data)
else
_unbind_buffer (context);
- context_class->swap_buffers (context);
+ return TRUE;
+}
+
+static void
+draw_render (gpointer data)
+{
+ gst_gl_framebuffer_draw_to_texture (fbo, fbo_tex,
+ (GstGLFramebufferFunc) blit_tex, data);
}
GST_START_TEST (test_upload_data)