+ p_vout->fmt_out.i_width,
+ p_vout->fmt_out.i_height,
+ VLCGL_FORMAT, VLCGL_TYPE, p_sys->pp_buffer[0] );
+#endif
+
+ if( p_sys->p_vout->pf_unlock )
+ {
+ p_sys->p_vout->pf_unlock( p_sys->p_vout );
+ }
+}
+
+
+#ifdef OPENGL_MORE_EFFECT
+/*****************************************************************************
+ * Transform: Calculate the distorted grid coordinates
+ *****************************************************************************/
+static void Transform(float p, int distortion, float width, float height,int i, int j, int i_visible_width, int i_visible_height, double *ix,double *iy)
+{
+ double x,y,xnew,ynew;
+ double r,theta,rnew,thetanew;
+
+ x = (double)i * (width / ((double)i_visible_width));
+ y = (double)j * (height / ((double)i_visible_height));
+
+ x = (2.0 * (double)x / width) - 1;
+ y = (2.0 * (double)y / height) - 1;
+ xnew = x;
+ ynew = y;
+ r = sqrt(x*x+y*y);
+ theta = atan2(y,x);
+
+ switch (distortion)
+ {
+/* GRID2D TRANSFORMATION */
+ case SINEXY:
+ xnew = sin(PID2*x);
+ ynew = sin(PID2*y);
+ break;
+ case SINER:
+ rnew = sin(PID2*r);
+ thetanew = theta;
+ xnew = rnew * cos(thetanew);
+ ynew = rnew * sin(thetanew);
+ break;
+ case SQUAREXY:
+ xnew = x*x*SIGN(x);
+ ynew = y*y*SIGN(y);
+ break;
+ case SQUARER:
+ rnew = r*r;
+ thetanew = theta;
+ xnew = rnew * cos(thetanew);
+ ynew = rnew * sin(thetanew);
+ break;
+ case ASINXY:
+ xnew = asin(x) / PID2;
+ ynew = asin(y) / PID2;
+ break;
+ case ASINR:
+ rnew = asin(r) / PID2;
+ thetanew = theta;
+ xnew = rnew * cos(thetanew);
+ ynew = rnew * sin(thetanew);
+ break;
+/* OTHER WAY: 3D MODEL */
+ default:
+ xnew = x;
+ ynew = y;
+ }
+
+ *ix = width * (xnew + 1) / (2.0);
+ *iy = height * (ynew + 1) / (2.0);
+}
+
+/*****************************************************************************
+ * Z_Compute: Calculate the Z-coordinate
+ *****************************************************************************/
+static float Z_Compute(float p, int distortion, float x, float y)
+{
+ float f_z = 0.0;
+ double d_p = p / 100.0;
+
+ switch (distortion)
+ {
+/* 3D MODEL */
+ case CYLINDER:
+ if (d_p > 0)
+ f_z = (1 - d_p * d_p) / (2 * d_p) - sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x));
+ else
+ f_z = (1 - d_p * d_p) / (2 * d_p) + d_p + sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x));
+ break;
+ case TORUS:
+ if (d_p > 0)
+ f_z = (1 - d_p * d_p) / (d_p) - sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x)) - sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - y * y));
+ else
+ f_z = (1 - d_p * d_p) / (d_p) + 2 * d_p + sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x)) + sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - y * y));
+ break;
+ case SPHERE:
+ if (d_p > 0)
+ f_z = (1 - d_p * d_p) / (2 * d_p) - sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x - y * y));
+ else
+ f_z = (1 - d_p * d_p) / (2 * d_p) + d_p + sqrt(fabs((d_p * d_p + 1) / (2 * d_p) * (d_p * d_p + 1) / (2 * d_p) - x * x - y * y));
+ break;
+/* OTHER WAY: GRID2D TRANSFORMATION */
+ case SINEXY:;
+ case SINER:
+ case SQUAREXY:
+ case SQUARER:;
+ case ASINXY:
+ case ASINR:
+ f_z = 0.0;
+ break;
+ default:
+ f_z = 0.0;
+ }
+ return f_z;
+}
+#endif
+
+
+/*****************************************************************************
+ * DisplayVideo: displays previously rendered output
+ *****************************************************************************/
+static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic )
+{
+ vout_sys_t *p_sys = p_vout->p_sys;
+ float f_width, f_height, f_x, f_y;
+
+ if( p_sys->p_vout->pf_lock &&
+ p_sys->p_vout->pf_lock( p_sys->p_vout ) )
+ {
+ msg_Warn( p_vout, "could not lock OpenGL provider" );
+ return;
+ }
+
+ /* glTexCoord works differently with GL_TEXTURE_2D and
+ GL_TEXTURE_RECTANGLE_EXT */
+#ifdef __APPLE__
+ f_x = (float)p_vout->fmt_out.i_x_offset;
+ f_y = (float)p_vout->fmt_out.i_y_offset;
+ f_width = (float)p_vout->fmt_out.i_x_offset +
+ (float)p_vout->fmt_out.i_visible_width;
+ f_height = (float)p_vout->fmt_out.i_y_offset +
+ (float)p_vout->fmt_out.i_visible_height;
+#else
+ f_x = (float)p_vout->fmt_out.i_x_offset / p_sys->i_tex_width;
+ f_y = (float)p_vout->fmt_out.i_y_offset / p_sys->i_tex_height;
+ f_width = ( (float)p_vout->fmt_out.i_x_offset +
+ p_vout->fmt_out.i_visible_width ) / p_sys->i_tex_width;
+ f_height = ( (float)p_vout->fmt_out.i_y_offset +
+ p_vout->fmt_out.i_visible_height ) / p_sys->i_tex_height;