diff options
author | David Schleef <ds@schleef.org> | 2007-12-24 20:53:56 +0000 |
---|---|---|
committer | David Schleef <ds@schleef.org> | 2007-12-24 20:53:56 +0000 |
commit | 15dbe49f8103bfcf493a225868734fdf8c924d03 (patch) | |
tree | 5ac354b0499d853579c2c3df188dcf9558ec662f /sys/glsink/gstglbuffer.c | |
parent | c131493ccecb74544dfdcaf03be980e47c71896d (diff) | |
download | gst-plugins-bad-15dbe49f8103bfcf493a225868734fdf8c924d03.tar.gz gst-plugins-bad-15dbe49f8103bfcf493a225868734fdf8c924d03.tar.bz2 gst-plugins-bad-15dbe49f8103bfcf493a225868734fdf8c924d03.zip |
sys/glsink/: Rewrite a bunch of code to use textures as the intermediate instead of renderbuffers. upload, download,...
Original commit message from CVS:
* sys/glsink/glimagesink.c:
* sys/glsink/glimagesink.h:
* sys/glsink/glvideo.c:
* sys/glsink/glvideo.h:
* sys/glsink/gstglbuffer.c:
* sys/glsink/gstglbuffer.h:
* sys/glsink/gstgldownload.c:
* sys/glsink/gstglfilter.c:
* sys/glsink/gstglupload.c:
Rewrite a bunch of code to use textures as the intermediate
instead of renderbuffers. upload, download, filtering all
work.
Diffstat (limited to 'sys/glsink/gstglbuffer.c')
-rw-r--r-- | sys/glsink/gstglbuffer.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/sys/glsink/gstglbuffer.c b/sys/glsink/gstglbuffer.c index da4093d4..f85179bc 100644 --- a/sys/glsink/gstglbuffer.c +++ b/sys/glsink/gstglbuffer.c @@ -27,6 +27,9 @@ gst_gl_buffer_finalize (GstGLBuffer * buffer) case GST_GL_BUFFER_RBO: glDeleteRenderbuffersEXT (1, &buffer->rbo); break; + case GST_GL_BUFFER_TEXTURE: + glDeleteTextures (1, &buffer->texture); + break; default: g_assert_not_reached (); break; @@ -88,14 +91,14 @@ gst_gl_buffer_new (GstGLDisplay * display, GstVideoFormat format, GstGLBuffer *buffer; XGCValues values = { 0 }; - g_return_val_if_fail (format == GST_VIDEO_FORMAT_RGB, NULL); + g_return_val_if_fail (format == GST_VIDEO_FORMAT_RGBx, NULL); g_return_val_if_fail (width > 0, NULL); g_return_val_if_fail (height > 0, NULL); buffer = (GstGLBuffer *) gst_mini_object_new (GST_TYPE_GL_BUFFER); buffer->display = g_object_ref (display); - buffer->type = GST_GL_BUFFER_RBO; + buffer->type = GST_GL_BUFFER_TEXTURE; buffer->width = width; buffer->height = height; @@ -147,6 +150,8 @@ gst_gl_buffer_new (GstGLDisplay * display, GstVideoFormat format, gst_gl_display_unlock (buffer->display); break; } + case GST_GL_BUFFER_TEXTURE: + break; default: g_assert_not_reached (); } @@ -236,6 +241,11 @@ gst_gl_buffer_upload (GstGLBuffer * buffer, void *data) break; } + case GST_GL_BUFFER_TEXTURE: + buffer->texture = + gst_gl_display_upload_texture_rectangle (buffer->display, + GST_VIDEO_FORMAT_RGBx, data, buffer->width, buffer->height); + break; default: g_assert_not_reached (); } @@ -287,6 +297,29 @@ gst_gl_buffer_download (GstGLBuffer * buffer, void *data) break; } + case GST_GL_BUFFER_TEXTURE: + { + unsigned int fbo; + + glGenFramebuffersEXT (1, &fbo); + glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, fbo); + + glFramebufferTexture2DEXT (GL_FRAMEBUFFER_EXT, + GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_RECTANGLE_ARB, + buffer->texture, 0); + + glDrawBuffer (GL_COLOR_ATTACHMENT1_EXT); + glReadBuffer (GL_COLOR_ATTACHMENT1_EXT); + + g_assert (glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT) == + GL_FRAMEBUFFER_COMPLETE_EXT); + + glReadPixels (0, 0, buffer->width, buffer->height, GL_RGBA, + GL_UNSIGNED_BYTE, data); + + glDeleteFramebuffersEXT (1, &fbo); + } + break; default: g_assert_not_reached (); } |