[599/906] GL|ES2: fix typos from recent changes and make downloading RGB formats work again

This commit is contained in:
Matthew Waters 2012-09-26 07:18:53 +00:00
parent 86cdbad63c
commit 11508f6f7a
3 changed files with 39 additions and 26 deletions

View file

@ -541,7 +541,9 @@ _init_download (GstGLDisplay * display, GstGLDownload * download)
case GST_VIDEO_FORMAT_RGB:
case GST_VIDEO_FORMAT_BGR:
/* color space conversion is not needed */
#ifndef OPENGL_ES2
break;
#endif
case GST_VIDEO_FORMAT_YUY2:
case GST_VIDEO_FORMAT_UYVY:
case GST_VIDEO_FORMAT_I420:
@ -699,7 +701,7 @@ _init_download_shader (GstGLDisplay * display, GstGLDownload * download)
gst_gl_shader_compile (download->shader, &error);
if (error) {
gst_gl_display_set_error (download, "%s", error->message);
gst_gl_display_set_error (display, "%s", error->message);
g_error_free (error);
error = NULL;
gst_gl_shader_use (NULL);
@ -723,8 +725,11 @@ _init_download_shader (GstGLDisplay * display, GstGLDownload * download)
case GST_VIDEO_FORMAT_AYUV:
/* color space conversion is needed */
{
#ifdef OPENGL_ES2
GError *error = NULL;
#endif
/* check if fragment shader is available, then load them
* GLSL is a requirement for donwload
* GLSL is a requirement for download
*/
if (!GLEW_ARB_fragment_shader) {
/* colorspace conversion is not possible */
@ -732,9 +737,6 @@ _init_download_shader (GstGLDisplay * display, GstGLDownload * download)
"Context, ARB_fragment_shader supported: no");
return;
}
#ifdef OPENGL_ES2
GError *error = NULL;
#endif
switch (v_format) {
case GST_VIDEO_FORMAT_YUY2:
@ -941,9 +943,6 @@ _do_download_draw_rgb (GstGLDisplay * display, GstGLDownload * download)
#else
guint out_width, out_height;
out_width = GST_VIDEO_INFO_WIDTH (&download->info);
out_height = GST_VIDEO_INFO_HEIGHT (&download->info);
const GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f,
1.0f, 0.0f,
-1.0f, -1.0f, 0.0f,
@ -956,6 +955,11 @@ _do_download_draw_rgb (GstGLDisplay * display, GstGLDownload * download)
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
out_width = GST_VIDEO_INFO_WIDTH (&download->info);
out_height = GST_VIDEO_INFO_HEIGHT (&download->info);
glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, download->fbo);
glViewport (0, 0, out_width, out_height);
glClearColor (0.0, 0.0, 0.0, 0.0);
@ -1005,7 +1009,7 @@ _do_download_draw_rgb (GstGLDisplay * display, GstGLDownload * download)
#endif /* G_BYTE_ORDER */
#else /* OPENGL_ES2 */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
glReadPixels (0, 0, out_width, out_eight, GL_BGRA,
glReadPixels (0, 0, out_width, out_height, GL_BGRA,
GL_UNSIGNED_INT_8_8_8_8, download->data[0]);
#else
glReadPixels (0, 0, out_width, out_eight, GL_BGRA,
@ -1068,13 +1072,13 @@ _do_download_draw_yuv (GstGLDisplay * display, GstGLDownload * download)
GstVideoFormat v_format;
guint out_width, out_height;
#ifndef OPENGL_ES2
GLenum multipleRT[] = {
GL_COLOR_ATTACHMENT0_EXT,
GL_COLOR_ATTACHMENT1_EXT,
GL_COLOR_ATTACHMENT2_EXT
};
#ifdef OPENGL_ES2
#else
GLint viewport_dim[4];
const GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f,

View file

@ -565,7 +565,7 @@ _init_upload (GstGLDisplay * display, GstGLUpload * upload)
error = NULL;
gst_gl_shader_use (NULL);
g_object_unref (G_OBJECT (upload->shader));
display->shader = NULL;
upload->shader = NULL;
} else {
upload->shader_attr_position_loc =
gst_gl_shader_get_attribute_location
@ -609,13 +609,13 @@ _init_upload (GstGLDisplay * display, GstGLUpload * upload)
g_error_free (error);
error = NULL;
gst_gl_shader_use (NULL);
g_object_unref (G_OBJECT (display->shader));
display->shader = NULL;
g_object_unref (G_OBJECT (upload->shader));
upload->shader = NULL;
} else {
display->shader_attr_position_loc =
upload->shader_attr_position_loc =
gst_gl_shader_get_attribute_location
(upload->shader, "a_position");
display->shader_upload_attr_texture_loc =
upload->shader_attr_texture_loc =
gst_gl_shader_get_attribute_location
(upload->shader, "a_texCoord");
}
@ -642,7 +642,8 @@ _init_upload (GstGLDisplay * display, GstGLUpload * upload)
#ifndef OPENGL_ES2
if (!gst_gl_shader_compile_and_check
(upload->shader, text_shader, GST_GL_SHADER_FRAGMENT_SOURCE)) {
(upload->shader, text_shader_I420_YV12,
GST_GL_SHADER_FRAGMENT_SOURCE)) {
gst_gl_display_set_error (display,
"Failed to initialize shader for uploading I420 or YV12");
g_object_unref (G_OBJECT (upload->shader));
@ -651,7 +652,8 @@ _init_upload (GstGLDisplay * display, GstGLUpload * upload)
#else
gst_gl_shader_set_vertex_source (upload->shader,
text_vertex_shader);
gst_gl_shader_set_fragment_source (upload->shader, text_shader);
gst_gl_shader_set_fragment_source (upload->shader,
text_shader_I420_YV12);
gst_gl_shader_compile (upload->shader, &error);
if (error) {
@ -660,12 +662,12 @@ _init_upload (GstGLDisplay * display, GstGLUpload * upload)
error = NULL;
gst_gl_shader_use (NULL);
g_object_unref (G_OBJECT (upload->shader));
display->shader = NULL;
upload->shader = NULL;
} else {
display->shader_attr_position_loc =
upload->shader_attr_position_loc =
gst_gl_shader_get_attribute_location
(upload->shader, "a_position");
display->shader_attr_texture_loc =
upload->shader_attr_texture_loc =
gst_gl_shader_get_attribute_location
(upload->shader, "a_texCoord");
}
@ -702,7 +704,7 @@ _init_upload (GstGLDisplay * display, GstGLUpload * upload)
upload->shader_attr_position_loc =
gst_gl_shader_get_attribute_location
(upload->shader, "a_position");
upload->shader_upload_attr_texture_loc =
upload->shader_attr_texture_loc =
gst_gl_shader_get_attribute_location
(upload->shader, "a_texCoord");
}
@ -1214,9 +1216,11 @@ void
_do_upload_draw (GstGLDisplay * display, GstGLUpload * upload)
{
GstVideoFormat v_format;
guint in_width, in_height, out_width, out_height;
guint out_width, out_height;
#ifdef OPENGL_ES2
#ifndef OPENGL_ES2
guint in_width, in_height;
#else
GLint viewport_dim[4];
const GLfloat vVertices[] = { 1.0f, -1.0f, 0.0f,
@ -1232,8 +1236,6 @@ _do_upload_draw (GstGLDisplay * display, GstGLUpload * upload)
GLushort indices[] = { 0, 1, 2, 0, 2, 3 };
#endif
in_width = upload->in_width;
in_height = upload->in_height;
out_width = GST_VIDEO_INFO_WIDTH (&upload->info);
out_height = GST_VIDEO_INFO_HEIGHT (&upload->info);
v_format = GST_VIDEO_INFO_FORMAT (&upload->info);
@ -1242,6 +1244,9 @@ _do_upload_draw (GstGLDisplay * display, GstGLUpload * upload)
/* setup a texture to render to */
#ifndef OPENGL_ES2
in_width = upload->in_width;
in_height = upload->in_height;
glEnable (GL_TEXTURE_RECTANGLE_ARB);
#endif
glBindTexture (GL_TEXTURE_RECTANGLE_ARB, upload->out_texture);

View file

@ -19,6 +19,10 @@
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/check/gstcheck.h>
#ifndef GST_DISABLE_PARSE