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;
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");
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
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
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);
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)
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);
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,
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);
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);
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)