コード例 #1
0
static gboolean
gst_vaapi_window_glx_ensure_context (GstVaapiWindow * window,
    GLXContext foreign_context)
{
  GstVaapiWindowGLXPrivate *const priv =
      GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
  GLContextState old_cs;
  guint width, height;

  if (!_gst_vaapi_window_glx_ensure_context (window, foreign_context))
    return FALSE;

  priv->gl_context->window = GST_VAAPI_WINDOW_ID (window);
  if (!gl_set_current_context (priv->gl_context, &old_cs)) {
    GST_DEBUG ("could not make newly created GLX context current");
    return FALSE;
  }

  glDisable (GL_DEPTH_TEST);
  glDepthMask (GL_FALSE);
  glDisable (GL_CULL_FACE);
  glDrawBuffer (GL_BACK);
  glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
  glEnable (GL_BLEND);
  glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

  gst_vaapi_window_get_size (window, &width, &height);
  gl_resize (width, height);

  gl_set_bgcolor (0);
  glClear (GL_COLOR_BUFFER_BIT);
  gl_set_current_context (&old_cs, NULL);
  return TRUE;
}
コード例 #2
0
static gboolean
gst_vaapi_window_glx_resize (GstVaapiWindow * window, guint width, guint height)
{
  GstVaapiWindowGLXPrivate *const priv =
      GST_VAAPI_WINDOW_GLX_GET_PRIVATE (window);
  const GstVaapiWindowClass *const parent_klass =
      GST_VAAPI_WINDOW_CLASS (gst_vaapi_window_glx_parent_class);
  Display *const dpy = GST_VAAPI_WINDOW_NATIVE_DISPLAY (window);
  GLContextState old_cs;

  if (!parent_klass->resize (window, width, height))
    return FALSE;

  GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
  XSync (dpy, False);           /* make sure resize completed */
  if (gl_set_current_context (priv->gl_context, &old_cs)) {
    gl_resize (width, height);
    gl_set_current_context (&old_cs, NULL);
  }
  GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
  return TRUE;
}
コード例 #3
0
ファイル: main.c プロジェクト: kissthink/clabs
int main( void )
{
    int fullscreen;
    XEvent event;

    if( gl_data() )
    {
        fprintf( stderr, "gl_data failed\n" );
        return( 1 );
    }

    fullscreen = 0;

    do
    {
        modeswitch  = 0;
        fullscreen ^= 1;

        if( glx_init( fullscreen ) )
        {
            fprintf( stderr, "glx_init failed\n" );
            return( 1 );
        }

        if( gl_init() )
        {
            fprintf( stderr, "gl_init failed\n" );
            return( 1 );
        }

        gl_resize();

        run = 1;

        while( run )
        {
            if( active )
            {
                gl_draw();
                glXSwapBuffers( dpy, win );
            }
            else
            {
                XPeekEvent( dpy, &event );
            }

            while( XPending( dpy ) )
            {
                XNextEvent( dpy, &event );

                switch( event.type )
                {
                case ButtonPress:
                {
                    int x = event.xmotion.x,
                        y = event.xmotion.y;

                    switch( event.xbutton.button )
                    {
                    case Button1:
                        gl_event( 0, 0, x, y );
                        break;
                    case Button3:
                        gl_event( 0, 1, x, y );
                        break;
                    }

                    break;
                }

                case ButtonRelease:
                {
                    int x = event.xmotion.x,
                        y = event.xmotion.y;

                    switch( event.xbutton.button )
                    {
                    case Button1:
                        gl_event( 1, 0, x, y );
                        break;
                    case Button3:
                        gl_event( 1, 1, x, y );
                        break;
                    }

                    break;
                }

                case MotionNotify:
                {
                    int x = event.xmotion.x,
                        y = event.xmotion.y;

                    switch( event.xbutton.button )
                    {
                    case Button1:
                        gl_event( 2,  0, x, y );
                        break;
                    case Button3:
                        gl_event( 2,  1, x, y );
                        break;
                    default:
                        gl_event( 2, -1, x, y );
                        break;
                    }

                    break;
                }

                case KeyPress:
                {
                    break;
                }

                case KeyRelease:
                {
                    int key = XLookupKeysym( &event.xkey, 0 );

                    switch( key )
                    {
                    case XK_Tab:

                        modeswitch = 1;

                    case XK_Escape:

                        run = 0;
                        break;

                    default:

                        gl_event( 4, key, -1, -1 );
                        break;
                    }

                    break;
                }

                case UnmapNotify:
                    active = 0;
                    break;
                case   MapNotify:
                    active = 1;
                    break;

                case ConfigureNotify:
                {
                    width  = event.xconfigure.width;
                    height = event.xconfigure.height;
                    gl_resize();
                    break;
                }

                case ClientMessage:
                {
                    if( event.xclient.data.l[0] == (int) wmDelete )
                    {
                        active = run = 0;
                    }
                    break;
                }

                case ReparentNotify:
                    break;

                default:
                {
                    printf( "caught unknown event, type %d\n",
                            event.type );
                    break;
                }
                }
            }
        }

        glXMakeCurrent( dpy, None, NULL );
        glXDestroyContext( dpy, ctx );
        XDestroyWindow( dpy, win );
        XCloseDisplay( dpy );
    }
    while( modeswitch );

    return( 0 );
}