summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGernot Ziegler <gz@lysator.liu.se>2003-10-27 22:07:15 +0000
committerGernot Ziegler <gz@lysator.liu.se>2003-10-27 22:07:15 +0000
commit727677396f615daed5202fe304f119a2d30cbd0b (patch)
tree2137d60578410811dcf34bc7f06b1fced99a3986
parent537084d264c4bb5fc9d02504d7e79961fd8e83c7 (diff)
downloadgstreamer-plugins-bad-727677396f615daed5202fe304f119a2d30cbd0b.tar.gz
improvements to glsink demo mode and autodetection
Original commit message from CVS: improvements to glsink demo mode and autodetection
-rw-r--r--sys/glsink/gstgl_nvimage.c42
-rw-r--r--sys/glsink/gstgl_rgbimage.c83
-rw-r--r--sys/glsink/gstglsink.c3
-rw-r--r--sys/glsink/gstglxwindow.c15
4 files changed, 98 insertions, 45 deletions
diff --git a/sys/glsink/gstgl_nvimage.c b/sys/glsink/gstgl_nvimage.c
index 61d18749a..8b5a567a5 100644
--- a/sys/glsink/gstgl_nvimage.c
+++ b/sys/glsink/gstgl_nvimage.c
@@ -21,6 +21,7 @@
//#include <GL/glext.h>
#include <GL/glu.h>
#include <string.h>
+#include <math.h>
// too lazy to write an API for this ;)
#include "regcomb_yuvrgb.c"
@@ -243,26 +244,26 @@ gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- glTranslatef(0.0, 0.0, -50.0);
+ glTranslatef(0.0, 0.0, -25.0);
glEnable(GL_TEXTURE_2D);
- glPushMatrix();
- //glTranslatef(0,1,0);
- glRotatef(xinfo->rotX,1,0,0);
- glRotatef(xinfo->rotY,0,1,0);
-
if (xinfo->info.demo)
{
- //xinfo->rotX += 0.2;
- //xinfo->rotY -= 0.2;
+
+ glRotatef(180.0*sin(xinfo->rotX),1,0,0);
+ glRotatef(180.0*cos(xinfo->rotY),0,1,0);
+
+ xinfo->rotX += 0.01;
+ xinfo->rotY -= 0.015;
float zoom = xinfo->zoom;
glScalef(zoom,zoom,zoom);
-
- if (xinfo->zoom > 2.0)
- xinfo->zoomdir = -0.05;
+ //glScalef(0.1,0.1,0.1);
- if (xinfo->zoom < 1.0)
- xinfo->zoomdir = 0.05;
+ if (xinfo->zoom > 1.0)
+ xinfo->zoomdir = -0.01;
+
+ if (xinfo->zoom < 0.5)
+ xinfo->zoomdir = 0.01;
xinfo->zoom += xinfo->zoomdir;
}
@@ -285,31 +286,32 @@ gst_gl_nvimage_put_image (GstImageInfo *info, GstImageData *image)
//glColor4f(1,1,1,1); // do NOT set a color here ! Done by Initialize_Backend, or actually SetConst !
glBegin(GL_QUADS);
+ float aspect = img_width/(float)img_height;
+ float hor = 4 * aspect;
+
glNormal3f(0, -1, 0);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,0);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB,0,0);
- glVertex3f(-4,4,0);
+ glVertex3f(-hor,4,0);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,0,ymax);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,0,ymax);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB,0,ymax);
- glVertex3f(-4,-4,0);
+ glVertex3f(-hor,-4,0);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,xmax,ymax);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,xmax,ymax);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB,xmax,ymax);
- glVertex3f(4,-4,0);
+ glVertex3f(hor,-4,0);
glMultiTexCoord2fARB(GL_TEXTURE0_ARB,xmax,0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB,xmax,0);
glMultiTexCoord2fARB(GL_TEXTURE2_ARB,xmax,0);
- glVertex3f(4,4,0);
+ glVertex3f(hor,4,0);
glEnd();
- glPopMatrix();
-
if (xinfo->info.dumpvideo)
{
static int framenr = 0;
@@ -371,7 +373,7 @@ gst_gl_nvimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
GstGLImageInfo *xinfo = gst_gl_nvimage_info (info);
GstGLImageConnection *xconn = gst_gl_nvimage_connection (conn);
- g_warning("Opening NVidia GL context connection, using register combiners.\n");
+ g_print("Opening NVidia connection; OpenGL on Nvidia, using register combiners.\n");
{
Ywidth = TEX_XSIZE; Yheight = TEX_YSIZE; UVwidth = TEX_XSIZE/2; UVheight = TEX_YSIZE/2;
Initialize_Backend(Ywidth,Yheight,UVwidth,UVheight,GL_LINEAR);
diff --git a/sys/glsink/gstgl_rgbimage.c b/sys/glsink/gstgl_rgbimage.c
index 7c2cfb543..7f57c8bc2 100644
--- a/sys/glsink/gstgl_rgbimage.c
+++ b/sys/glsink/gstgl_rgbimage.c
@@ -17,6 +17,7 @@
#include <GL/glx.h>
#include <GL/gl.h>
#include <GL/glu.h>
+#include <math.h>
#include "gstglsink.h"
@@ -231,52 +232,102 @@ gst_gl_rgbimage_put_image (GstImageInfo *info, GstImageData *image)
GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
GstGLImage *im = (GstGLImage *) image;
+ int img_width = im->conn->w;
+ int img_height = im->conn->h;
+
g_assert (xinfo != NULL);
- g_warning("PUTTING IMAGE");
// both upload the video, and redraw the screen
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
- glTranslatef(0.0, 0.0, -50.0);
+ glTranslatef(0.0, 0.0, -25.0);
glEnable(GL_TEXTURE_2D);
- glPushMatrix();
- //glTranslatef(0,1,0);
- glRotatef(xinfo->rotX-250,1,0,0);
- glRotatef(xinfo->rotY,0,1,0);
- int zoom = xinfo->zoom;
- glScaled(zoom,zoom,zoom);
- //Draws the surface rectangle
+ if (xinfo->info.demo)
+ {
+
+ glRotatef(180.0*sin(xinfo->rotX),1,0,0);
+ glRotatef(180.0*cos(xinfo->rotY),0,1,0);
+
+ xinfo->rotX += 0.01;
+ xinfo->rotY -= 0.015;
+ float zoom = xinfo->zoom;
+ glScalef(zoom,zoom,zoom);
+ //glScalef(0.1,0.1,0.1);
+
+ if (xinfo->zoom > 1.0)
+ xinfo->zoomdir = -0.01;
+ if (xinfo->zoom < 0.5)
+ xinfo->zoomdir = 0.01;
+
+ xinfo->zoom += xinfo->zoomdir;
+ }
+
+ //Draws the surface rectangle
glBindTexture(GL_TEXTURE_2D, im->conn->rgbatex_id);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, im->conn->w, im->conn->h, GL_RGBA,
GL_UNSIGNED_BYTE, im->data.data);
xmax = (float)im->conn->w/TEX_XSIZE;
ymax = (float)im->conn->h/TEX_YSIZE;
+ float aspect = img_width/(float)img_height;
+ float hor = 4 * aspect;
+
glColor4f(1,1,1,1);
glBegin(GL_QUADS);
glNormal3f(0, -1, 0);
glTexCoord2f(xmax, 0);
- glVertex3f(4,4,0);
+ glVertex3f(hor,4,0);
glTexCoord2f(0, 0);
- glVertex3f(-4,4,0);
+ glVertex3f(-hor,4,0);
glTexCoord2f(0, ymax);
- glVertex3f(-4,-4,0);
+ glVertex3f(-hor,-4,0);
glTexCoord2f(xmax, ymax);
- glVertex3f(4,-4,0);
-
+ glVertex3f(hor,-4,0);
glEnd();
- glPopMatrix();
+ if (xinfo->info.dumpvideo)
+ {
+ static int framenr = 0;
+ char capfilename[255];
+ static guint8 *cap_image_data = NULL, *cap_image_data2 = NULL;
+ int i;
+
+ // hmmmm, is this reentrant ?!
+ if (cap_image_data == NULL)
+ cap_image_data = (guint8 *)malloc(img_width * img_height * 3);
+
+ if (cap_image_data2 == NULL)
+ cap_image_data2 = (guint8 *)malloc(img_width * img_height * 3);
+
+ printf("Recording frame #%d\n", framenr);
+ glReadPixels(0,0,img_width,img_height,GL_RGB,GL_UNSIGNED_BYTE,cap_image_data);
+ // invert the pixels
+ for (i = 0; i < img_height; i++)
+ memcpy(cap_image_data2 + i * img_width * 3, cap_image_data + (img_height-1-i) * img_width * 3, img_width*3);
+
+ sprintf(capfilename, "cap%04d.ppm", framenr);
+ FILE *outfile = fopen(capfilename, "wb");
+ if (outfile != NULL)
+ {
+ fprintf(outfile, "P6\n");
+ fprintf(outfile,"# created by raw_zb\n");
+ fprintf(outfile,"%d %d\n",img_width,img_height);
+ fprintf(outfile,"255\n");
+ fwrite(cap_image_data2, sizeof(char), img_width*img_height*3, outfile);
+ fclose(outfile);
+ }
+ framenr++;
+ }
glXSwapBuffers(xinfo->dpy, xinfo->win);
}
@@ -295,7 +346,7 @@ gst_gl_rgbimage_free_image (GstImageData *image)
static void
gst_gl_rgbimage_open_conn (GstImageConnection *conn, GstImageInfo *info)
{
- g_warning("!!! Opening Connection !!!");
+ g_warning("Opening RGB Connection; classic OpenGL 1.2 renderer.");
GstGLImageInfo *xinfo = gst_gl_rgbimage_info (info);
GstGLImageConnection *xconn = gst_gl_rgbimage_connection (conn);
diff --git a/sys/glsink/gstglsink.c b/sys/glsink/gstglsink.c
index 62292f1ef..6a11fe5e8 100644
--- a/sys/glsink/gstglsink.c
+++ b/sys/glsink/gstglsink.c
@@ -213,8 +213,7 @@ gst_glsink_class_init (GstGLSinkClass *klass)
/* plugins */
klass->plugins = NULL;
- //klass->plugins = g_list_append (klass->plugins, get_xvimage_plugin ());
- //klass->plugins = g_list_append (klass->plugins, get_gl_rgbimage_plugin ());
+ klass->plugins = g_list_append (klass->plugins, get_gl_rgbimage_plugin ());
klass->plugins = g_list_append (klass->plugins, get_gl_nvimage_plugin ());
}
diff --git a/sys/glsink/gstglxwindow.c b/sys/glsink/gstglxwindow.c
index 5f7231602..f442cf066 100644
--- a/sys/glsink/gstglxwindow.c
+++ b/sys/glsink/gstglxwindow.c
@@ -147,14 +147,14 @@ gst_glxwindow_new (GstElement *sink)
if (vi == NULL)
{
vi = glXChooseVisual(new->dpy, new->screen, attrListSgl);
- g_warning("Only Singlebuffered Visual!\n");
+ GST_DEBUG(0,"Only Singlebuffered Visual!\n");
}
else
{
- g_warning("Got Doublebuffered Visual!\n");
+ GST_DEBUG(0,"Got Doublebuffered Visual!\n");
}
glXQueryVersion(new->dpy, &glxMajorVersion, &glxMinorVersion);
- g_warning("glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
+ GST_DEBUG(0,"glX-Version %d.%d\n", glxMajorVersion, glxMinorVersion);
/* create a GLX context */
new->ctx = glXCreateContext(new->dpy, vi, 0, GL_TRUE);
@@ -172,7 +172,8 @@ gst_glxwindow_new (GstElement *sink)
new->rotX = 0;
new->rotY = 0;
- new->zoom = 2;
+ new->zoom = 1;
+ new->zoomdir = 0.01;
{
/* create a window in window mode*/
@@ -200,11 +201,11 @@ gst_glxwindow_new (GstElement *sink)
&new->width, &new->height, &borderDummy, &new->depth);
printf("Depth %d\n", new->depth);
if (glXIsDirect(new->dpy, new->ctx))
- g_warning("Congrats, you have Direct Rendering!\n");
+ GST_DEBUG (GST_CAT_PLUGIN_INFO, "Congrats, you have Direct Rendering!\n");
else
- g_warning("Sorry, no Direct Rendering possible!\n");
+ GST_DEBUG (GST_CAT_PLUGIN_INFO, "Sorry, no Direct Rendering possible!\n");
- g_warning("Initializing OpenGL parameters");
+ GST_DEBUG(GST_CAT_PLUGIN_INFO, "Initializing OpenGL parameters\n");
/* initialize OpenGL drawing */
glEnable(GL_DEPTH_TEST);
//glShadeModel(GL_SMOOTH);