Commit bb13e227 authored by Gildas Bazin's avatar Gildas Bazin

* modules/video_output/x11/*: the glx "opengl provider" makes use of xcommon.c.

* modules/video_output/opengl.c: new platform independant OpenGL vout (uses an "opengl provider" module).
* modules/visualization/galaktos/*: uses the new "opengl provider" module.
parent 6129f1ce
...@@ -2414,6 +2414,24 @@ if test "${enable_xvideo}" != "no" && ...@@ -2414,6 +2414,24 @@ if test "${enable_xvideo}" != "no" &&
CPPFLAGS="${CPPFLAGS_save}") CPPFLAGS="${CPPFLAGS_save}")
fi fi
dnl
dnl GLX module
dnl (enabled by default except on win32)
dnl
AC_ARG_ENABLE(glx,
[ --enable-glx X11 OpenGL (GLX) support (default enabled)])
if test "${enable_glx}" != "no" &&
(test "${SYS}" != "mingw32" || test "${enable_glx}" = "yes"); then
CPPFLAGS="${CPPFLAGS_save} -I${x_includes}"
AC_CHECK_HEADERS(X11/Xlib.h, [
AC_CHECK_HEADERS(GL/glx.h, [
VLC_ADD_PLUGINS([glx])
VLC_ADD_LDFLAGS([glx],[-L${x_libraries} -lX11 -lXext -lGL -lGLU])
VLC_ADD_CPPFLAGS([glx],[-I${x_includes}])
]) ])
CPPFLAGS="${CPPFLAGS_save}"
fi
dnl dnl
dnl Check for the Xinerama extension dnl Check for the Xinerama extension
dnl dnl
...@@ -2426,11 +2444,13 @@ if test "${enable_xvideo}" != "no" && ...@@ -2426,11 +2444,13 @@ if test "${enable_xvideo}" != "no" &&
AC_CHECK_LIB(Xinerama_pic, XineramaQueryExtension,[ AC_CHECK_LIB(Xinerama_pic, XineramaQueryExtension,[
VLC_ADD_LDFLAGS([xvideo],[-lXinerama_pic]) VLC_ADD_LDFLAGS([xvideo],[-lXinerama_pic])
VLC_ADD_LDFLAGS([x11],[-lXinerama_pic]) VLC_ADD_LDFLAGS([x11],[-lXinerama_pic])
VLC_ADD_LDFLAGS([glx],[-lXinerama_pic])
ac_cv_have_xinerama="yes" ac_cv_have_xinerama="yes"
],[ ],[
AC_CHECK_LIB(Xinerama, XineramaQueryExtension,[ AC_CHECK_LIB(Xinerama, XineramaQueryExtension,[
VLC_ADD_LDFLAGS([xvideo],[-lXinerama]) VLC_ADD_LDFLAGS([xvideo],[-lXinerama])
VLC_ADD_LDFLAGS([x11],[-lXinerama]) VLC_ADD_LDFLAGS([x11],[-lXinerama])
VLC_ADD_LDFLAGS([glx],[-lXinerama])
ac_cv_have_xinerama="yes" ac_cv_have_xinerama="yes"
]) ])
]) ])
...@@ -2442,6 +2462,20 @@ if test "${enable_xvideo}" != "no" && ...@@ -2442,6 +2462,20 @@ if test "${enable_xvideo}" != "no" &&
CPPFLAGS="${CPPFLAGS_save}" CPPFLAGS="${CPPFLAGS_save}"
fi fi
dnl
dnl GLX module
dnl (enabled by default except on win32)
dnl
AC_ARG_ENABLE(opengl,
[ --enable-opengl OpenGL support (default enabled)])
if test "${enable_opengl}" != "no"; then
AC_CHECK_HEADERS(GL/gl.h, [
VLC_ADD_PLUGINS([opengl])
VLC_ADD_LDFLAGS([opengl],[-L${x_libraries} -lGL -lGLU])
])
CPPFLAGS="${CPPFLAGS_save}"
fi
dnl dnl
dnl SDL module dnl SDL module
dnl dnl
...@@ -2754,18 +2788,6 @@ then ...@@ -2754,18 +2788,6 @@ then
fi ]) fi ])
fi fi
dnl
dnl GLX module
dnl
AC_ARG_ENABLE(glx,
[ --enable-glx X11 OpenGL (GLX) support (default disabled)])
if test "${enable_glx}" = "yes"
then
VLC_ADD_PLUGINS([glx])
VLC_ADD_LDFLAGS([glx],[-lGL -lGLU])
fi
dnl dnl
dnl AA plugin dnl AA plugin
dnl dnl
......
...@@ -102,6 +102,7 @@ struct vout_thread_t ...@@ -102,6 +102,7 @@ struct vout_thread_t
int ( *pf_manage ) ( vout_thread_t * ); int ( *pf_manage ) ( vout_thread_t * );
void ( *pf_render ) ( vout_thread_t *, picture_t * ); void ( *pf_render ) ( vout_thread_t *, picture_t * );
void ( *pf_display ) ( vout_thread_t *, picture_t * ); void ( *pf_display ) ( vout_thread_t *, picture_t * );
void ( *pf_swap ) ( vout_thread_t * ); /* OpenGL only */
int ( *pf_control ) ( vout_thread_t *, int, va_list ); int ( *pf_control ) ( vout_thread_t *, int, va_list );
/**@}*/ /**@}*/
......
/*****************************************************************************
* vlc_opengl.h: OpenGL provider interface
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Cyril Deguet <asmax@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#ifndef _VLC_OPENGL_H
#define _VLC_OPENGL_H 1
struct opengl_t
{
VLC_COMMON_MEMBERS
int i_width; /* window width */
int i_height; /* window height */
int b_fullscreen; /* fullscreen flag */
opengl_sys_t *p_sys; /* private data */
/* Create an OpenGL window of the requested size (if possible) */
int ( *pf_init )( opengl_t *, int i_width, int i_height );
/* Swap front/back buffers */
void ( *pf_swap )( opengl_t * );
/* Handle window events */
int ( *pf_handle_events )( opengl_t * );
};
#endif
...@@ -9,3 +9,4 @@ SOURCES_wingdi = wingdi.c ...@@ -9,3 +9,4 @@ SOURCES_wingdi = wingdi.c
SOURCES_mga = mga.c SOURCES_mga = mga.c
SOURCES_hd1000v = hd1000v.cpp SOURCES_hd1000v = hd1000v.cpp
SOURCES_snapshot = snapshot.c SOURCES_snapshot = snapshot.c
SOURCES_opengl = opengl.c
This diff is collapsed.
...@@ -12,4 +12,6 @@ SOURCES_xvideo = \ ...@@ -12,4 +12,6 @@ SOURCES_xvideo = \
SOURCES_glx = \ SOURCES_glx = \
glx.c \ glx.c \
xcommon.c \
xcommon.h \
$(NULL) $(NULL)
This diff is collapsed.
...@@ -67,6 +67,10 @@ ...@@ -67,6 +67,10 @@
# include <X11/extensions/Xvlib.h> # include <X11/extensions/Xvlib.h>
#endif #endif
#ifdef MODULE_NAME_IS_glx
# include <GL/glx.h>
#endif
#ifdef HAVE_XINERAMA #ifdef HAVE_XINERAMA
# include <X11/extensions/Xinerama.h> # include <X11/extensions/Xinerama.h>
#endif #endif
...@@ -318,7 +322,7 @@ void E_(Deactivate) ( vlc_object_t *p_this ) ...@@ -318,7 +322,7 @@ void E_(Deactivate) ( vlc_object_t *p_this )
{ {
XFreeColormap( p_vout->p_sys->p_display, p_vout->p_sys->colormap ); XFreeColormap( p_vout->p_sys->p_display, p_vout->p_sys->colormap );
} }
#else #elif defined(MODULE_NAME_IS_xvideo)
XVideoReleasePort( p_vout, p_vout->p_sys->i_xvport ); XVideoReleasePort( p_vout, p_vout->p_sys->i_xvport );
#endif #endif
...@@ -368,7 +372,7 @@ static int InitVideo( vout_thread_t *p_vout ) ...@@ -368,7 +372,7 @@ static int InitVideo( vout_thread_t *p_vout )
break; break;
} }
#else #elif defined(MODULE_NAME_IS_x11)
/* Initialize the output structure: RGB with square pixels, whatever /* Initialize the output structure: RGB with square pixels, whatever
* the input format is, since it's the only format we know */ * the input format is, since it's the only format we know */
switch( p_vout->p_sys->i_screen_depth ) switch( p_vout->p_sys->i_screen_depth )
...@@ -431,7 +435,7 @@ static int InitVideo( vout_thread_t *p_vout ) ...@@ -431,7 +435,7 @@ static int InitVideo( vout_thread_t *p_vout )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
* DisplayVideo: displays previously rendered output * DisplayVideo: displays previously rendered output
***************************************************************************** *****************************************************************************
* This function sends the currently rendered image to X11 server. * This function sends the currently rendered image to X11 server.
...@@ -1140,6 +1144,8 @@ static void DestroyWindow( vout_thread_t *p_vout, x11_window_t *p_win ) ...@@ -1140,6 +1144,8 @@ static void DestroyWindow( vout_thread_t *p_vout, x11_window_t *p_win )
*****************************************************************************/ *****************************************************************************/
static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
{ {
#ifndef MODULE_NAME_IS_glx
#ifdef MODULE_NAME_IS_xvideo #ifdef MODULE_NAME_IS_xvideo
int i_plane; int i_plane;
#endif #endif
...@@ -1259,6 +1265,8 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ) ...@@ -1259,6 +1265,8 @@ static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic )
return -1; return -1;
} }
#endif /* !MODULE_NAME_IS_glx */
return 0; return 0;
} }
...@@ -2015,7 +2023,7 @@ static IMAGE_TYPE * CreateImage( vout_thread_t *p_vout, ...@@ -2015,7 +2023,7 @@ static IMAGE_TYPE * CreateImage( vout_thread_t *p_vout,
/* Allocate memory for image */ /* Allocate memory for image */
#ifdef MODULE_NAME_IS_xvideo #ifdef MODULE_NAME_IS_xvideo
p_data = (byte_t *) malloc( i_width * i_height * i_bits_per_pixel / 8 ); p_data = (byte_t *) malloc( i_width * i_height * i_bits_per_pixel / 8 );
#else #elif defined(MODULE_NAME_IS_x11)
i_bytes_per_line = i_width * i_bytes_per_pixel; i_bytes_per_line = i_width * i_bytes_per_pixel;
p_data = (byte_t *) malloc( i_bytes_per_line * i_height ); p_data = (byte_t *) malloc( i_bytes_per_line * i_height );
#endif #endif
...@@ -2046,7 +2054,7 @@ static IMAGE_TYPE * CreateImage( vout_thread_t *p_vout, ...@@ -2046,7 +2054,7 @@ static IMAGE_TYPE * CreateImage( vout_thread_t *p_vout,
#ifdef MODULE_NAME_IS_xvideo #ifdef MODULE_NAME_IS_xvideo
p_image = XvCreateImage( p_display, i_xvport, i_chroma, p_image = XvCreateImage( p_display, i_xvport, i_chroma,
p_data, i_width, i_height ); p_data, i_width, i_height );
#else #elif defined(MODULE_NAME_IS_x11)
p_image = XCreateImage( p_display, p_visual, i_depth, ZPixmap, 0, p_image = XCreateImage( p_display, p_visual, i_depth, ZPixmap, 0,
p_data, i_width, i_height, i_quantum, 0 ); p_data, i_width, i_height, i_quantum, 0 );
#endif #endif
......
...@@ -142,6 +142,13 @@ struct vout_sys_t ...@@ -142,6 +142,13 @@ struct vout_sys_t
vlc_bool_t b_net_wm_state_stays_on_top; vlc_bool_t b_net_wm_state_stays_on_top;
Atom net_wm_state_below; Atom net_wm_state_below;
vlc_bool_t b_net_wm_state_below; vlc_bool_t b_net_wm_state_below;
#ifdef MODULE_NAME_IS_glx
/* GLX properties */
int b_glx13;
GLXContext gwctx;
GLXWindow gwnd;
#endif
}; };
/***************************************************************************** /*****************************************************************************
...@@ -174,6 +181,7 @@ typedef struct mwmhints_t ...@@ -174,6 +181,7 @@ typedef struct mwmhints_t
uint32_t decorations; uint32_t decorations;
int32_t input_mode; int32_t input_mode;
uint32_t status; uint32_t status;
} mwmhints_t; } mwmhints_t;
/***************************************************************************** /*****************************************************************************
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
*****************************************************************************/ *****************************************************************************/
#include "plugin.h" #include "plugin.h"
#include "vlc_opengl.h"
#include <GL/gl.h> #include <GL/gl.h>
#include <GL/glu.h> #include <GL/glu.h>
#include <unistd.h> #include <unistd.h>
...@@ -270,10 +269,12 @@ int galaktos_update( galaktos_thread_t *p_thread ) ...@@ -270,10 +269,12 @@ int galaktos_update( galaktos_thread_t *p_thread )
glFinish(); glFinish();
glFlush(); glFlush();
// printf("Flush %d\n",(SDL_GetTicks()-timestart)); // printf("Flush %d\n",(SDL_GetTicks()-timestart));
(p_thread->p_opengl->pf_swap)( p_thread->p_opengl );
p_thread->p_opengl->pf_swap( p_thread->p_opengl );
/* Process events */ /* Process events */
if( (p_thread->p_opengl->pf_handle_events)( p_thread->p_opengl ) ) if( p_thread->p_opengl->pf_manage &&
p_thread->p_opengl->pf_manage( p_thread->p_opengl ) )
{ {
return 1; return 1;
} }
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include <vlc/input.h> #include <vlc/input.h>
#include <vlc/vout.h> #include <vlc/vout.h>
#include "aout_internal.h" #include "aout_internal.h"
#include "vlc_opengl.h"
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -79,7 +78,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -79,7 +78,6 @@ static int Open( vlc_object_t *p_this )
aout_filter_t *p_filter = (aout_filter_t *)p_this; aout_filter_t *p_filter = (aout_filter_t *)p_this;
aout_filter_sys_t *p_sys; aout_filter_sys_t *p_sys;
galaktos_thread_t *p_thread; galaktos_thread_t *p_thread;
vlc_value_t width, height;
if ( p_filter->input.i_format != VLC_FOURCC('f','l','3','2' ) if ( p_filter->input.i_format != VLC_FOURCC('f','l','3','2' )
|| p_filter->output.i_format != VLC_FOURCC('f','l','3','2') ) || p_filter->output.i_format != VLC_FOURCC('f','l','3','2') )
...@@ -104,25 +102,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -104,25 +102,6 @@ static int Open( vlc_object_t *p_this )
vlc_object_create( p_filter, sizeof( galaktos_thread_t ) ); vlc_object_create( p_filter, sizeof( galaktos_thread_t ) );
vlc_object_attach( p_thread, p_this ); vlc_object_attach( p_thread, p_this );
/* Get on OpenGL provider */
p_thread->p_opengl =
(opengl_t *)vlc_object_create( p_this, VLC_OBJECT_OPENGL );
if( p_thread->p_opengl == NULL )
{
msg_Err( p_filter, "out of memory" );
return VLC_ENOMEM;
}
p_thread->p_module =
module_Need( p_thread->p_opengl, "opengl provider", NULL, 0 );
if( p_thread->p_module == NULL )
{
msg_Err( p_filter, "No OpenGL provider found" );
vlc_object_destroy( p_thread->p_opengl );
p_thread->p_opengl = NULL;
return VLC_ENOOBJ;
}
/* /*
var_Create( p_thread, "galaktos-width", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); var_Create( p_thread, "galaktos-width", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Get( p_thread, "galaktos-width", &width ); var_Get( p_thread, "galaktos-width", &width );
...@@ -155,7 +134,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -155,7 +134,6 @@ static int Open( vlc_object_t *p_this )
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
* float to s16 conversion * float to s16 conversion
*****************************************************************************/ *****************************************************************************/
...@@ -169,7 +147,6 @@ static inline int16_t FloatToInt16( float f ) ...@@ -169,7 +147,6 @@ static inline int16_t FloatToInt16( float f )
return (int16_t)( f * 32768.0 ); return (int16_t)( f * 32768.0 );
} }
/***************************************************************************** /*****************************************************************************
* DoWork: process samples buffer * DoWork: process samples buffer
***************************************************************************** *****************************************************************************
...@@ -221,9 +198,31 @@ static void Thread( vlc_object_t *p_this ) ...@@ -221,9 +198,31 @@ static void Thread( vlc_object_t *p_this )
int timestart=0; int timestart=0;
int mspf=0; int mspf=0;
/* Initialize the opengl provider */ /* Get on OpenGL provider */
(p_thread->p_opengl->pf_init)(p_thread->p_opengl, p_thread->i_width, p_thread->p_opengl =
p_thread->i_height); (vout_thread_t *)vlc_object_create( p_this, VLC_OBJECT_OPENGL );
if( p_thread->p_opengl == NULL )
{
msg_Err( p_thread, "out of memory" );
return;
}
p_thread->p_opengl->i_window_width = p_thread->i_width;
p_thread->p_opengl->i_window_height = p_thread->i_height;
p_thread->p_opengl->render.i_width = p_thread->i_width;
p_thread->p_opengl->render.i_height = p_thread->i_width;
p_thread->p_opengl->render.i_aspect = VOUT_ASPECT_FACTOR;
p_thread->p_module =
module_Need( p_thread->p_opengl, "opengl provider", NULL, 0 );
if( p_thread->p_module == NULL )
{
msg_Err( p_thread, "No OpenGL provider found" );
vlc_object_destroy( p_thread->p_opengl );
return;
}
vlc_object_attach( p_thread->p_opengl, p_this );
setup_opengl( p_thread->i_width, p_thread->i_height ); setup_opengl( p_thread->i_width, p_thread->i_height );
CreateRenderTarget(512, &RenderTargetTextureID, NULL); CreateRenderTarget(512, &RenderTargetTextureID, NULL);
...@@ -275,6 +274,7 @@ static void Close( vlc_object_t *p_this ) ...@@ -275,6 +274,7 @@ static void Close( vlc_object_t *p_this )
/* Free the openGL provider */ /* Free the openGL provider */
module_Unneed( p_sys->p_thread->p_opengl, p_sys->p_thread->p_module ); module_Unneed( p_sys->p_thread->p_opengl, p_sys->p_thread->p_module );
vlc_object_detach( p_sys->p_thread->p_opengl );
vlc_object_destroy( p_sys->p_thread->p_opengl ); vlc_object_destroy( p_sys->p_thread->p_opengl );
/* Free data */ /* Free data */
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/aout.h> #include <vlc/aout.h>
#include <vlc/vout.h>
#define MAX_BLOCKS 10 #define MAX_BLOCKS 10
...@@ -36,7 +37,7 @@ typedef struct ...@@ -36,7 +37,7 @@ typedef struct
char *psz_title; char *psz_title;
/* OpenGL provider */ /* OpenGL provider */
opengl_t *p_opengl; vout_thread_t *p_opengl;
module_t *p_module; module_t *p_module;
/* Window properties */ /* Window properties */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment