Changeset 4994baa7237b561a0f9259c606332baea2383ea1

Show
Ignore:
Timestamp:
22/07/04 00:38:49 (4 years ago)
Author:
Cyril Deguet <asmax@videolan.org>
git-committer:
Cyril Deguet <asmax@videolan.org> 1090449529 +0000
git-parent:

[42d17b9d6a9abb8bdfc306e868f29692da3e8f8c]

git-author:
Cyril Deguet <asmax@videolan.org> 1090449529 +0000
Message:
  • all: created a new module type "opengl provider", which provides a
    simple interface to create and use OpenGL windows
  • modules/video_output/x11/glx.c: the GLX vout now implements the
    "opengl provider" interface
  • modules/visualization/galaktos/*: no more dependency on GLX: we use
    the generic opengl provider interface instead.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_common.h

    re414aa3 r4994baa  
    340340typedef struct httpd_redirect_t httpd_redirect_t; 
    341341typedef struct httpd_stream_t httpd_stream_t; 
     342 
     343/* opengl */ 
     344typedef struct opengl_t     opengl_t; 
     345typedef struct opengl_sys_t opengl_sys_t; 
    342346 
    343347/* divers */ 
  • include/vlc_objects.h

    r53b4094 r4994baa  
    5353#define VLC_OBJECT_ACCESS     (-19) 
    5454#define VLC_OBJECT_STREAM     (-20) 
     55#define VLC_OBJECT_OPENGL     (-21) 
    5556 
    5657#define VLC_OBJECT_GENERIC  (-666) 
  • modules/video_output/x11/glx.c

    r5d041dd r4994baa  
    3333#include <vlc/vout.h> 
    3434 
     35/* For the opengl provider interface */ 
     36#include "vlc_opengl.h" 
     37 
    3538#include <X11/Xlib.h> 
    3639#include <X11/Xutil.h> 
    3740#include <GL/glx.h> 
    3841 
     42 
     43/* Data common to vout and opengl provider structures */ 
     44typedef struct glx_t 
     45{ 
     46    Display     *p_display; 
     47    int         b_glx13; 
     48    int         i_width; 
     49    int         i_height; 
     50    int         b_fullscreen; 
     51    GLXContext  gwctx; 
     52    Window      wnd; 
     53    GLXWindow   gwnd; 
     54    Atom        wm_delete; 
     55} glx_t; 
     56 
     57 
     58/***************************************************************************** 
     59 * Vout interface 
     60 *****************************************************************************/ 
     61static int  CreateVout   ( vlc_object_t * ); 
     62static void DestroyVout  ( vlc_object_t * ); 
     63static int  Init         ( vout_thread_t * ); 
     64static void End          ( vout_thread_t * ); 
     65static int  Manage       ( vout_thread_t * ); 
     66static void Render       ( vout_thread_t *p_vout, picture_t *p_pic ); 
     67static void DisplayVideo ( vout_thread_t *, picture_t * ); 
     68 
     69/***************************************************************************** 
     70 * OpenGL providerinterface 
     71 *****************************************************************************/ 
     72static int  CreateOpenGL ( vlc_object_t * ); 
     73static void DestroyOpenGL( vlc_object_t * ); 
     74static int  InitOpenGL   ( opengl_t *, int, int ); 
     75static void SwapBuffers  ( opengl_t * ); 
     76static int  HandleEvents ( opengl_t * ); 
     77 
    3978/***************************************************************************** 
    4079 * Local prototypes 
    4180 *****************************************************************************/ 
    42 static int  Create      ( vlc_object_t * ); 
    43 static void Destroy     ( vlc_object_t * ); 
    44  
    45 static int  Init        ( vout_thread_t * ); 
    46 static void End         ( vout_thread_t * ); 
    47 static int  Manage      ( vout_thread_t * ); 
    48 static void Render      ( vout_thread_t *p_vout, picture_t *p_pic ); 
    49 static void DisplayVideo( vout_thread_t *, picture_t * ); 
    50  
    51 static int  OpenDisplay ( vout_thread_t * ); 
    52 static void CloseDisplay( vout_thread_t * ); 
    53 static int  InitGLX12   ( vout_thread_t *p_vout ); 
    54 static int  InitGLX13   ( vout_thread_t *p_vout ); 
    55 static void CreateWindow( vout_thread_t *p_vout, XVisualInfo *p_vi ); 
    56 static void SwitchContext( vout_thread_t *p_vout ); 
     81static int  OpenDisplay ( vlc_object_t *, glx_t * ); 
     82static void CloseDisplay( glx_t * ); 
     83static int  InitGLX12   ( vlc_object_t *, glx_t * ); 
     84static int  InitGLX13   ( vlc_object_t *, glx_t * ); 
     85static void CreateWindow( vlc_object_t *, glx_t *, XVisualInfo *); 
     86static int  HandleX11Events( vlc_object_t *, glx_t * ); 
     87static void SwitchContext( glx_t * ); 
    5788 
    5889static inline int GetAlignedSize( int i_size ); 
     
    6596    set_capability( "video output", 20 ); 
    6697    add_shortcut( "glx" ); 
    67     set_callbacks( Create, Destroy ); 
     98    set_callbacks( CreateVout, DestroyVout ); 
     99 
     100    add_submodule(); 
     101    set_description( _("X11 OpenGL provider") ); 
     102    set_capability( "opengl provider", 50 ); 
     103    set_callbacks( CreateOpenGL, DestroyOpenGL ); 
    68104vlc_module_end(); 
     105 
    69106 
    70107/***************************************************************************** 
     
    78115    uint8_t     *p_buffer; 
    79116    int         i_index; 
    80  
    81117    int         i_tex_width; 
    82118    int         i_tex_height; 
    83  
    84     int         i_width; 
    85     int         i_height; 
    86     int         b_fullscreen; 
    87  
    88     Display     *p_display; 
    89     int         b_glx13; 
    90     GLXContext  gwctx; 
    91     Window      wnd; 
    92     GLXWindow   gwnd; 
    93     Atom        wm_delete; 
    94  
    95119    GLuint      texture; 
    96  
    97120    int         i_effect; //XXX 
     121 
     122    glx_t       glx; 
    98123}; 
     124 
     125struct opengl_sys_t 
     126{ 
     127    glx_t       glx; 
     128}; 
     129 
    99130 
    100131#define MWM_HINTS_DECORATIONS   (1L << 1) 
     
    111142 
    112143/***************************************************************************** 
    113  * Create: allocates GLX video thread output method 
     144 * CreateVout: allocates GLX video thread output method 
    114145 ***************************************************************************** 
    115146 * This function allocates and initializes a GLX vout method. 
    116147 *****************************************************************************/ 
    117 static int Create( vlc_object_t *p_this ) 
     148static int CreateVout( vlc_object_t *p_this ) 
    118149{ 
    119150    vout_thread_t *p_vout = (vout_thread_t *)p_this; 
     
    130161    p_vout->p_sys->i_effect = 1; 
    131162 
    132    /* p_vout->p_sys->i_width = p_vout->i_window_width; 
    133     p_vout->p_sys->i_height = p_vout->i_window_height; */ 
    134     p_vout->p_sys->i_width = 700; 
    135     p_vout->p_sys->i_height = 700; 
    136     p_vout->p_sys->b_fullscreen = 0; 
     163   /* p_vout->p_sys->glx.i_width = p_vout->i_window_width; 
     164    p_vout->p_sys->glx.i_height = p_vout->i_window_height; */ 
     165    p_vout->p_sys->glx.i_width = 700; 
     166    p_vout->p_sys->glx.i_height = 700; 
     167    p_vout->p_sys->glx.b_fullscreen = 0; 
    137168 
    138169    /* A texture must have a size aligned on a power of 2 */ 
     
    144175 
    145176    /* Open and initialize device */ 
    146     if( OpenDisplay( p_vout ) ) 
     177    if( OpenDisplay( p_this, &p_vout->p_sys->glx ) ) 
    147178    { 
    148179        msg_Err( p_vout, "cannot open display" ); 
     
    201232    p_pic->i_planes = 1; 
    202233 
     234    p_vout->p_sys->p_buffer = 
     235        malloc( p_vout->p_sys->i_tex_width * p_vout->p_sys->i_tex_height * 4 ); 
     236    if( !p_vout->p_sys->p_buffer ) 
     237    { 
     238        msg_Err( p_vout, "Out of memory" ); 
     239        return -1; 
     240    } 
    203241 
    204242    p_pic->p->p_pixels = p_vout->p_sys->p_buffer 
     
    218256    I_OUTPUTPICTURES = 1; 
    219257 
    220     SwitchContext( p_vout ); 
     258    SwitchContext( &p_vout->p_sys->glx ); 
    221259 
    222260    /* Set the texture parameters */ 
     
    227265    { 
    228266        glEnable( GL_CULL_FACE); 
    229         /*glDisable( GL_DEPTH_TEST ); 
     267/*        glDisable( GL_DEPTH_TEST ); 
    230268        glEnable( GL_BLEND ); 
    231269        glBlendFunc( GL_SRC_ALPHA, GL_ONE );*/ 
     
    254292 * Destroy: destroy GLX video thread output method 
    255293 ***************************************************************************** 
    256  * Terminate an output method created by Create 
    257  *****************************************************************************/ 
    258 static void Destroy( vlc_object_t *p_this ) 
     294 * Terminate an output method created by CreateVout 
     295 *****************************************************************************/ 
     296static void DestroyVout( vlc_object_t *p_this ) 
    259297{ 
    260298    vout_thread_t *p_vout = (vout_thread_t *)p_this; 
    261299 
    262     CloseDisplay( p_vout ); 
     300    CloseDisplay( &p_vout->p_sys->glx ); 
    263301 
    264302    /* Free the texture buffer*/ 
     
    270308    free( p_vout->p_sys ); 
    271309} 
     310 
     311 
     312/***************************************************************************** 
     313 * CreateOpenGL: initialize an OpenGL provider 
     314 *****************************************************************************/ 
     315static int CreateOpenGL( vlc_object_t *p_this ) 
     316{ 
     317    opengl_t *p_opengl = (opengl_t*)p_this; 
     318 
     319    /* Allocate the structure */ 
     320    p_opengl->p_sys = malloc(sizeof(opengl_sys_t)); 
     321 
     322    /* Set the function pointers */ 
     323    p_opengl->pf_init = InitOpenGL; 
     324    p_opengl->pf_swap = SwapBuffers; 
     325    p_opengl->pf_handle_events = HandleEvents; 
     326 
     327    p_opengl->p_sys->glx.wnd = None; 
     328 
     329    return VLC_SUCCESS; 
     330} 
     331 
     332 
     333/***************************************************************************** 
     334 * DestroyOpenGL: destroys an OpenGL provider 
     335 *****************************************************************************/ 
     336static void DestroyOpenGL( vlc_object_t *p_this ) 
     337{ 
     338    opengl_t *p_opengl = (opengl_t*)p_this; 
     339 
     340    /* Free the structure */ 
     341    free(p_opengl->p_sys); 
     342} 
     343 
     344/***************************************************************************** 
     345 * InitOpenGL: creates the OpenGL window 
     346 *****************************************************************************/ 
     347static int InitOpenGL( opengl_t *p_opengl, int i_width, int i_height ) 
     348{ 
     349    p_opengl->p_sys->glx.i_width = i_width; 
     350    p_opengl->p_sys->glx.i_height = i_height; 
     351    p_opengl->p_sys->glx.b_fullscreen = 0; 
     352 
     353    if( OpenDisplay( (vlc_object_t*)p_opengl, &p_opengl->p_sys->glx ) ) 
     354    { 
     355        msg_Err( p_opengl, "Cannot create OpenGL window" ); 
     356        return VLC_EGENERIC; 
     357    } 
     358 
     359    /* Set the OpenGL context _for the current thread_ */ 
     360    SwitchContext( &p_opengl->p_sys->glx ); 
     361 
     362    return VLC_SUCCESS; 
     363} 
     364 
     365 
     366/***************************************************************************** 
     367 * SwapBuffers: swap front/back buffers 
     368 *****************************************************************************/ 
     369static void SwapBuffers( opengl_t *p_opengl ) 
     370{ 
     371    if( p_opengl->p_sys->glx.b_glx13 ) 
     372    { 
     373        glXSwapBuffers( p_opengl->p_sys->glx.p_display, 
     374                        p_opengl->p_sys->glx.gwnd ); 
     375    } 
     376    else 
     377    { 
     378        glXSwapBuffers( p_opengl->p_sys->glx.p_display, 
     379                        p_opengl->p_sys->glx.wnd ); 
     380    } 
     381} 
     382 
     383 
     384/***************************************************************************** 
     385 * HandleEvents: handle window events 
     386 *****************************************************************************/ 
     387static int HandleEvents( opengl_t *p_opengl ) 
     388{ 
     389    int i_ret = 
     390        HandleX11Events( (vlc_object_t*)p_opengl, &p_opengl->p_sys->glx ); 
     391    if( i_ret ) 
     392    { 
     393        /* close the window */ 
     394        CloseDisplay( &p_opengl->p_sys->glx ); 
     395    } 
     396    return i_ret; 
     397} 
     398 
    272399 
    273400/***************************************************************************** 
     
    279406static int Manage( vout_thread_t *p_vout ) 
    280407{ 
     408    if( HandleX11Events( (vlc_object_t*)p_vout, &p_vout->p_sys->glx ) ) 
     409    { 
     410        /* the user wants to close the window */ 
     411        playlist_t * p_playlist = 
     412            (playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST, 
     413                                           FIND_ANYWHERE ); 
     414        if( p_playlist != NULL ) 
     415        { 
     416            playlist_Stop( p_playlist ); 
     417            vlc_object_release( p_playlist ); 
     418        } 
     419    } 
     420    return 0; 
     421} 
     422 
     423 
     424static int HandleX11Events( vlc_object_t *p_thread, glx_t *p_glx ) 
     425{ 
    281426    Display *p_display; 
    282427 
    283     p_display = p_vout->p_sys->p_display; 
     428    p_display = p_glx->p_display; 
    284429 
    285430    /* loop on X11 events */ 
     
    294439                /* Delete notification */ 
    295440                if( (evt.xclient.format == 32) && 
    296                     ((Atom)evt.xclient.data.l[0] == p_vout->p_sys->wm_delete) ) 
     441                    ((Atom)evt.xclient.data.l[0] == 
     442                     p_glx->wm_delete) ) 
    297443                { 
    298                     /* the user wants to close the window */ 
    299                     playlist_t * p_playlist = 
    300                         (playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST, 
    301                                                        FIND_ANYWHERE ); 
    302                     if( p_playlist != NULL ) 
    303                     { 
    304                         playlist_Stop( p_playlist ); 
    305                         vlc_object_release( p_playlist ); 
    306                     } 
     444                    return -1; 
    307445                } 
    308446                break; 
     
    312450    return 0; 
    313451} 
     452 
    314453 
    315454/***************************************************************************** 
     
    422561    } 
    423562    glDisable( GL_TEXTURE_2D); 
    424      
    425    
    426 
     563
     564 
    427565 
    428566/***************************************************************************** 
     
    431569static void DisplayVideo( vout_thread_t *p_vout, picture_t *p_pic ) 
    432570{ 
    433     if( p_vout->p_sys->b_glx13 ) 
    434     { 
    435         glXSwapBuffers( p_vout->p_sys->p_display, p_vout->p_sys->gwnd ); 
     571    if( p_vout->p_sys->glx.b_glx13 ) 
     572    { 
     573        glXSwapBuffers( p_vout->p_sys->glx.p_display, 
     574                        p_vout->p_sys->glx.gwnd ); 
    436575    } 
    437576    else 
    438577    { 
    439         glXSwapBuffers( p_vout->p_sys->p_display, p_vout->p_sys->wnd ); 
    440     } 
    441  
    442 
    443  
    444 /* following functions are local */ 
     578        glXSwapBuffers( p_vout->p_sys->glx.p_display, 
     579                        p_vout->p_sys->glx.wnd ); 
     580    } 
     581
     582 
    445583 
    446584/***************************************************************************** 
    447585 * OpenDisplay: open and initialize OpenGL device 
    448586 *****************************************************************************/ 
    449  
    450 static int OpenDisplay( vout_thread_t *p_vout ) 
     587static int OpenDisplay( vlc_object_t *p_thread, glx_t *p_glx ) 
    451588{ 
    452589    Display *p_display; 
     
    455592 
    456593    /* Open the display */ 
    457     p_vout->p_sys->p_display = p_display = XOpenDisplay( NULL ); 
     594    p_glx->p_display = p_display = XOpenDisplay( NULL ); 
    458595    if( !p_display ) 
    459596    { 
    460         msg_Err( p_vout, "Cannot open display" ); 
     597        msg_Err( p_thread, "Cannot open display" ); 
    461598        return -1; 
    462599    } 
     
    465602    if( !XQueryExtension( p_display, "GLX", &i_opcode, &i_evt, &i_err ) ) 
    466603    { 
    467         msg_Err( p_vout, "GLX extension not supported" ); 
     604        msg_Err( p_thread, "GLX extension not supported" ); 
    468605        return -1; 
    469606    } 
    470607    if( !glXQueryExtension( p_display, &i_err, &i_evt ) ) 
    471608    { 
    472         msg_Err( p_vout, "glXQueryExtension failed" ); 
     609        msg_Err( p_thread, "glXQueryExtension failed" ); 
    473610        return -1; 
    474611    } 
     
    477614    if (!glXQueryVersion( p_display, &i_maj, &i_min ) ) 
    478615    { 
    479         msg_Err( p_vout, "glXQueryVersion failed" ); 
     616        msg_Err( p_thread, "glXQueryVersion failed" ); 
    480617        return -1; 
    481618    } 
    482619    if( i_maj <= 0 || ((i_maj == 1) && (i_min < 3)) ) 
    483620    { 
    484         p_vout->p_sys->b_glx13 = 0; 
    485         msg_Dbg( p_vout, "Using GLX 1.2 API" ); 
    486         if( InitGLX12( p_vout ) == -1 ) 
     621        p_glx->b_glx13 = 0; 
     622        msg_Dbg( p_thread, "Using GLX 1.2 API" ); 
     623        if( InitGLX12( p_thread, p_glx ) == -1 ) 
    487624        { 
    488625            return -1; 
     
    491628    else 
    492629    { 
    493         p_vout->p_sys->b_glx13 = 1; 
    494         msg_Dbg( p_vout, "Using GLX 1.3 API" ); 
    495         if( InitGLX13( p_vout ) == -1 ) 
     630        p_glx->b_glx13 = 1; 
     631        msg_Dbg( p_thread, "Using GLX 1.3 API" ); 
     632        if( InitGLX13( p_thread, p_glx ) == -1 ) 
    496633        { 
    497634            return -1; 
     
    499636    } 
    500637 
    501     XMapWindow( p_display, p_vout->p_sys->wnd ); 
    502     if( p_vout->p_sys->b_fullscreen ) 
     638    XMapWindow( p_display, p_glx->wnd ); 
     639    if( p_glx->b_fullscreen ) 
    503640    { 
    504641        //XXX 
    505         XMoveWindow( p_display, p_vout->p_sys->wnd, 0, 0 ); 
     642        XMoveWindow( p_display, p_glx->wnd, 0, 0 ); 
    506643    } 
    507644    XFlush( p_display ); 
    508  
    509     /* Allocate the texture buffer */ 
    510     p_vout->p_sys->p_buffer = 
    511         malloc( p_vout->p_sys->i_tex_width * p_vout->p_sys->i_tex_height * 4 ); 
    512     if( !p_vout->p_sys->p_buffer ) 
    513     { 
    514         msg_Err( p_vout, "Out of memory" ); 
    515         return -1; 
    516     } 
    517645    return 0; 
    518646} 
     
    524652 * state of the device. 
    525653 *****************************************************************************/ 
    526 static void CloseDisplay( vout_thread_t *p_vout
     654static void CloseDisplay( glx_t *p_glx
    527655{ 
    528656    Display *p_display; 
    529657 
     658    if (p_glx->wnd == None ) 
     659    { 
     660        // Already closed or not opened... 
     661        return; 
     662    } 
     663 
    530664    glFlush(); 
    531  
    532     p_display = p_vout->p_sys->p_display; 
    533     glXDestroyContext( p_display, p_vout->p_sys->gwctx ); 
    534     if( p_vout->p_sys->b_glx13 ) 
    535     { 
    536         glXDestroyWindow( p_display, p_vout->p_sys->gwnd ); 
    537     } 
    538     XDestroyWindow( p_display, p_vout->p_sys->wnd ); 
    539     XCloseDisplay( p_display ); 
    540  
    541 
    542  
    543  
    544 int InitGLX12( vout_thread_t *p_vout ) 
     665    p_display = p_glx->p_display; 
     666    glXDestroyContext( p_display, p_glx->gwctx ); 
     667    if( p_glx->b_glx13 ) 
     668    { 
     669        glXDestroyWindow( p_display, p_glx->gwnd ); 
     670    } 
     671    XDestroyWindow( p_display, p_glx->wnd ); 
     672    p_glx->wnd = None; 
     673
     674 
     675 
     676int InitGLX12( vlc_object_t *p_thread, glx_t *p_glx ) 
    545677{ 
    546678    Display *p_display; 
     
    551683                     0 }; 
    552684 
    553     p_display = p_vout->p_sys->p_display; 
     685    p_display = p_glx->p_display; 
    554686 
    555687    p_vi = glXChooseVisual( p_display, DefaultScreen( p_display), p_attr ); 
    556688    if(! p_vi ) 
    557689    { 
    558         msg_Err( p_vout, "Cannot get GLX 1.2 visual" ); 
     690        msg_Err( p_thread, "Cannot get GLX 1.2 visual" ); 
    559691        return -1; 
    560692    } 
    561693 
    562694    /* Create the window */ 
    563     CreateWindow( p_vout, p_vi ); 
     695    CreateWindow( p_thread, p_glx, p_vi ); 
    564696 
    565697     /* Create an OpenGL context */ 
    566     p_vout->p_sys->gwctx = gwctx = glXCreateContext( p_display, p_vi, 0, True ); 
     698    p_glx->gwctx = gwctx = glXCreateContext( p_display, p_vi, 0, True ); 
    567699    if( !gwctx ) 
    568700    { 
    569         msg_Err( p_vout, "Cannot create OpenGL context"); 
     701        msg_Err( p_thread, "Cannot create OpenGL context"); 
    570702        XFree( p_vi ); 
    571703        return -1; 
     
    577709 
    578710 
    579 int InitGLX13( vout_thread_t *p_vout
     711int InitGLX13( vlc_object_t *p_thread, glx_t *p_glx
    580712{ 
    581713    Display *p_display; 
     
    588720                     GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, 0 }; 
    589721 
    590     p_display = p_vout->p_sys->p_display; 
     722    p_display = p_glx->p_display; 
    591723 
    592724    /* Get the FB configuration */ 
     
    594726    if( (i_nbelem <= 0) || !p_fbconfs ) 
    595727    { 
    596         msg_Err( p_vout, "Cannot get FB configurations"); 
     728        msg_Err( p_thread, "Cannot get FB configurations"); 
    597729        if( p_fbconfs ) 
    598730        { 
     
    607739    if( !p_vi ) 
    608740    { 
    609         msg_Err( p_vout, "Cannot get X11 visual" ); 
     741        msg_Err( p_thread, "Cannot get X11 visual" ); 
    610742        XFree( p_fbconfs ); 
    611743        return -1; 
     
    613745 
    614746    /* Create the window */ 
    615     CreateWindow( p_vout, p_vi ); 
     747    CreateWindow( p_thread, p_glx, p_vi ); 
    616748 
    617749    XFree( p_vi ); 
    618750 
    619751    /* Create the GLX window */ 
    620     p_vout->p_sys->gwnd = glXCreateWindow( p_display, fbconf, p_vout->p_sys->wnd, NULL ); 
    621     if( p_vout->p_sys->gwnd == None ) 
    622     { 
    623         msg_Err( p_vout, "Cannot create GLX window" ); 
     752    p_glx->gwnd = glXCreateWindow( p_display, fbconf, p_glx->wnd, NULL ); 
     753    if( p_glx->gwnd == None ) 
     754    { 
     755        msg_Err( p_thread, "Cannot create GLX window" ); 
    624756        return -1; 
    625757    } 
    626758 
    627759    /* Create an OpenGL context */ 
    628     p_vout->p_sys->gwctx = gwctx = glXCreateNewContext( p_display, fbconf, 
     760    p_glx->gwctx = gwctx = glXCreateNewContext( p_display, fbconf, 
    629761                                                  GLX_RGBA_TYPE, NULL, True ); 
    630762    if( !gwctx ) 
    631763    { 
    632         msg_Err( p_vout, "Cannot create OpenGL context"); 
     764        msg_Err( p_thread, "Cannot create OpenGL context"); 
    633765        XFree( p_fbconfs ); 
    634766        return -1; 
     
    640772 
    641773 
    642  
    643 void CreateWindow( vout_thread_t *p_vout, XVisualInfo *p_vi ) 
     774void CreateWindow( vlc_object_t *p_thread, glx_t *p_glx, XVisualInfo *p_vi ) 
    644775{ 
    645776    Display *p_display; 
     
    651782    mwmhints_t mwmhints; 
    652783 
    653     p_display = p_vout->p_sys->p_display; 
     784    p_display = p_glx->p_display; 
    654785 
    655786    /* Create a colormap */ 
     
    661792    xattr.border_pixel = 0; 
    662793    xattr.colormap = cm; 
    663     p_vout->p_sys->wnd = wnd = XCreateWindow( p_display, DefaultRootWindow(p_display), 
    664             0, 0, p_vout->p_sys->i_width, p_vout->p_sys->i_height, 0, p_vi->depth, 
     794    p_glx->wnd = wnd = XCreateWindow( p_display, DefaultRootWindow(p_display), 
     795            0, 0, p_glx->i_width, p_glx->i_height, 0, p_vi->depth, 
    665796            InputOutput, p_vi->visual, 
    666797            CWBackPixel | CWBorderPixel | CWColormap, &xattr); 
    667798 
    668799    /* Allow the window to be deleted by the window manager */ 
    669     p_vout->p_sys->wm_delete = XInternAtom( p_display, "WM_DELETE_WINDOW", False ); 
    670     XSetWMProtocols( p_display, wnd, &p_vout->p_sys->wm_delete, 1 ); 
    671  
    672     if( p_vout->p_sys->b_fullscreen ) 
     800    p_glx->wm_delete = XInternAtom( p_display, "WM_DELETE_WINDOW", False ); 
     801    XSetWMProtocols( p_display, wnd, &p_glx->wm_delete, 1 ); 
     802 
     803    if( p_glx->b_fullscreen ) 
    673804    { 
    674805        mwmhints.flags = MWM_HINTS_DECORATIONS; 
     
    684815        p_size_hints = XAllocSizeHints(); 
    685816        p_size_hints->flags = PMinSize | PMaxSize; 
    686         p_size_hints->min_width = p_vout->p_sys->i_width; 
    687         p_size_hints->min_height = p_vout->p_sys->i_height; 
    688         p_size_hints->max_width = p_vout->p_sys->i_width; 
    689         p_size_hints->max_height = p_vout->p_sys->i_height; 
     817        p_size_hints->min_width = p_glx->i_width; 
     818        p_size_hints->min_height = p_glx->i_height; 
     819        p_size_hints->max_width = p_glx->i_width; 
     820        p_size_hints->max_height = p_glx->i_height; 
    690821        XSetWMNormalHints( p_display, wnd, p_size_hints ); 
    691822        XFree( p_size_hints ); 
     
    695826 
    696827 
    697 void SwitchContext( vout_thread_t *p_vout
     828void SwitchContext( glx_t *p_glx
    698829{ 
    699830    /* Change the current OpenGL context */ 
    700     if( p_vout->p_sys->b_glx13 ) 
    701     { 
    702         glXMakeContextCurrent( p_vout->p_sys->p_display, p_vout->p_sys->gwnd, 
    703                                p_vout->p_sys->gwnd, p_vout->p_sys->gwctx ); 
     831    if( p_glx->b_glx13 ) 
     832    { 
     833        glXMakeContextCurrent( p_glx->p_display, p_glx->gwnd, 
     834                               p_glx->gwnd, p_glx->gwctx ); 
    704835    } 
    705836    else 
    706837    { 
    707         glXMakeCurrent( p_vout->p_sys->p_display, p_vout->p_sys->wnd, 
    708                         p_vout->p_sys->gwctx ); 
     838        glXMakeCurrent( p_glx->p_display, p_glx->wnd, 
     839                        p_glx->gwctx ); 
    709840    } 
    710841} 
  • modules/visualization/galaktos/Modules.am

    rb45ccdd r4994baa  
    11SOURCES_galaktos = plugin.c \ 
    22                   plugin.h \ 
    3                    glx.c \ 
    4                    glx.h \ 
    53                   main.c \ 
    64                   main.h \ 
  • modules/visualization/galaktos/main.c

    rc0a1dbe r4994baa  
    2323 *****************************************************************************/ 
    2424 
    25 #include "glx.h" 
     25#include "plugin.h" 
     26#include "vlc_opengl.h" 
    2627#include <GL/gl.h> 
    2728#include <GL/glu.h> 
     
    270271    glFlush(); 
    271272    //  printf("Flush %d\n",(SDL_GetTicks()-timestart)); 
    272     galaktos_glx_swap( p_thread ); 
    273  
    274     /* Process X11 events */ 
    275     if( galaktos_glx_handle_events( p_thread ) == 1
     273    (p_thread->p_opengl->pf_swap)( p_thread->p_opengl ); 
     274 
     275    /* Process events */ 
     276    if( (p_thread->p_opengl->pf_handle_events)( p_thread->p_opengl )
    276277    { 
    277278        return 1; 
  • modules/visualization/galaktos/plugin.c

    r1e4bfd0 r4994baa  
    3030 
    3131#include "plugin.h" 
    32 #include "glx.h" 
    3332#include "main.h" 
    3433#include "PCM.h" 
     
    3938#include <vlc/vout.h> 
    4039#include "aout_internal.h" 
     40#include "vlc_opengl.h" 
    4141 
    4242/***************************************************************************** 
     
    7979    aout_filter_t     *p_filter = (aout_filter_t *)p_this; 
    8080    aout_filter_sys_t *p_sys; 
    81     galaktos_thread_t     *p_thread; 
     81    galaktos_thread_t *p_thread; 
    8282    vlc_value_t       width, height; 
    8383 
     
    104104        vlc_object_create( p_filter, sizeof( galaktos_thread_t ) ); 
    105105    vlc_object_attach( p_thread, p_this ); 
     106 
     107    /* Get on OpenGL provider */ 
     108    p_thread->p_opengl = 
     109        (opengl_t *)vlc_object_create( p_this, VLC_OBJECT_OPENGL ); 
     110    if( p_thread->p_opengl == NULL ) 
     111    { 
     112        msg_Err( p_filter, "out of memory" ); 
     113        return VLC_ENOMEM; 
     114    } 
     115 
     116    p_thread->p_module = 
     117        module_Need( p_thread->p_opengl, "opengl provider", NULL, 0 ); 
     118    if( p_thread->p_module == NULL ) 
     119    { 
     120        msg_Err( p_filter, "No OpenGL provider found" ); 
     121        vlc_object_destroy( p_thread->p_opengl ); 
     122        p_thread->p_opengl = NULL; 
     123        return VLC_ENOOBJ; 
     124    } 
    106125 
    107126/* 
     
    117136    p_thread->i_height = 600; 
    118137    p_thread->b_fullscreen = 0; 
    119     galaktos_glx_init( p_thread ); 
    120138    galaktos_init( p_thread ); 
    121139 
     
    204222    int mspf=0; 
    205223 
    206     galaktos_glx_activate_window( p_thread ); 
     224    /* Initialize the opengl provider */ 
     225    (p_thread->p_opengl->pf_init)(p_thread->p_opengl, p_thread->i_width, 
     226                                  p_thread->i_height); 
     227 
    207228    setup_opengl( p_thread->i_width, p_thread->i_height ); 
    208229    CreateRenderTarget(512, &RenderTargetTextureID, NULL); 
     
    236257        timestart=mdate()/1000; 
    237258    } 
    238  
    239     galaktos_glx_done( p_thread ); 
    240259} 
    241260 
     
    254273 
    255274    vlc_thread_join( p_sys->p_thread ); 
     275 
     276    /* Free the openGL provider */ 
     277    module_Unneed( p_sys->p_thread->p_opengl, p_sys->p_thread->p_module ); 
     278    vlc_object_destroy( p_sys->p_thread->p_opengl ); 
    256279 
    257280    /* Free data */ 
  • modules/visualization/galaktos/plugin.h

    r1e4bfd0 r4994baa  
    3636    char          *psz_title; 
    3737 
     38    /* OpenGL provider */ 
     39    opengl_t      *p_opengl; 
     40    module_t      *p_module; 
     41 
    3842    /* Window properties */ 
    3943    int           i_width; 
  • src/misc/objects.c

    r2455945 r4994baa  
    4949#include "vlc_codec.h" 
    5050 
     51#include "vlc_opengl.h" 
     52 
    5153#include "vlc_httpd.h" 
    5254#include "vlc_vlm.h" 
     
    170172            psz_type = "vlm dameon"; 
    171173            break; 
     174        case VLC_OBJECT_OPENGL: 
     175            i_size = sizeof( opengl_t ); 
     176            psz_type = "opengl provider"; 
     177            break; 
    172178        case VLC_OBJECT_ANNOUNCE: 
    173179            i_size = sizeof( announce_handler_t );