diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-11-01 20:24:37 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-11-01 20:24:37 +0000 |
commit | 1a7a3f8b389b4febd41dd2d3f7c16fb033d98fe7 (patch) | |
tree | 0619ef71f423acd2f182db83235c2e29dcee1bae /libvo/vo_gl.c | |
parent | 0e49449d13c63f3673e6cc5021459bcf30ebe285 (diff) | |
download | mpv-1a7a3f8b389b4febd41dd2d3f7c16fb033d98fe7.tar.bz2 mpv-1a7a3f8b389b4febd41dd2d3f7c16fb033d98fe7.tar.xz |
fullscreen fixes and GUI support for vo_gl
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13844 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/vo_gl.c')
-rw-r--r-- | libvo/vo_gl.c | 131 |
1 files changed, 74 insertions, 57 deletions
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 9337aea074..dac83135fa 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -24,6 +24,9 @@ #include "gl_common.h" #include "x11_common.h" #include "aspect.h" +#ifdef HAVE_NEW_GUI +#include "Gui/interface.h" +#endif static vo_info_t info = { @@ -35,7 +38,8 @@ static vo_info_t info = LIBVO_EXTERN(gl) -static GLXContext wsGLXContext; +static XVisualInfo *gl_vinfo = NULL; +static GLXContext gl_context = 0; static int wsGLXAttrib[] = { GLX_RGBA, GLX_RED_SIZE,1, GLX_GREEN_SIZE,1, @@ -172,26 +176,54 @@ static int find_gl_format (uint32_t format) return 1; } +/** + * \brief Initialize a (new or reused) OpenGL context. + */ +static int initGl(uint32_t d_width, uint32_t d_height) { + unsigned char *ImageData = NULL; + texture_width = 32; + while (texture_width < image_width || + texture_width < image_height) + texture_width *= 2; + texture_height = texture_width; + + glDisable(GL_BLEND); + glDisable(GL_DEPTH_TEST); + glDepthMask(GL_FALSE); + glDisable(GL_CULL_FACE); + glEnable(GL_TEXTURE_2D); + + mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n", + texture_width, texture_height); + + glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + glAdjustAlignment(texture_width * image_bytes); + ImageData = malloc(texture_width * texture_height * image_bytes); + memset(ImageData, 0, texture_width * texture_height * image_bytes); + glTexImage2D(GL_TEXTURE_2D, 0, gl_texfmt, texture_width, texture_height, 0, + gl_format, gl_type, ImageData); + free (ImageData); + + // set alignment as default is 4 which will break some files + glAdjustAlignment(image_width * image_bytes); + + resize(d_width, d_height); + + glClearColor( 0.0f,0.0f,0.0f,0.0f ); + glClear( GL_COLOR_BUFFER_BIT ); +} + /* connect to server, create and map window, * allocate colors and (shared) memory */ static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { - unsigned char *ImageData=NULL; -// int screen; - unsigned int fg, bg; - XSizeHints hint; - XVisualInfo *vinfo; - XEvent xev; - -// XGCValues xgcv; - image_height = height; image_width = width; find_gl_format (format); - vo_dwidth = d_width; - vo_dheight = d_height; sub_bg_alpha = 255; // We need alpha = 255 for invisible part of the OSD int_pause = 0; @@ -207,6 +239,26 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin // aspect(&d_width,&d_height,A_ZOOM); // } #endif +#ifdef HAVE_NEW_GUI + if (use_gui) { + // GUI creates and manages window for us + vo_dwidth = d_width; + vo_dheight= d_height; + guiGetEvent(guiSetShVideo, 0); + setGlWindow(&gl_vinfo, &gl_context, vo_window); + initGl(vo_dwidth, vo_dheight); + return 0; + } +#endif + if ( vo_window == None ) { + unsigned int fg, bg; + XSizeHints hint; + XVisualInfo *vinfo; + XEvent xev; + + vo_dwidth = d_width; + vo_dheight = d_height; + hint.x = 0; hint.y = 0; hint.width = d_width; @@ -229,8 +281,6 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin - if ( vo_window == None ) - { vo_window = vo_x11_create_smooth_window(mDisplay, mRootWin, vinfo->visual, hint.x, hint.y, hint.width, hint.height, vinfo->depth, XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone)); @@ -243,7 +293,6 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint); /* Map window. */ XMapWindow(mDisplay, vo_window); - if ( flags&1 ) vo_x11_fullscreen(); #ifdef HAVE_XINERAMA vo_x11_xinerama_move(mDisplay,vo_window); #endif @@ -256,56 +305,21 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin while (xev.type != MapNotify || xev.xmap.event != vo_window); XSelectInput(mDisplay, vo_window, NoEventMask); - } - - if ( vo_config_count ) glXDestroyContext( mDisplay,wsGLXContext ); - wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True ); - glXMakeCurrent( mDisplay,vo_window,wsGLXContext ); XSync(mDisplay, False); vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask ); - - texture_width=32; - while(texture_width<image_width || texture_width<image_height) texture_width*=2; - texture_height=texture_width; - - ImageData=malloc(texture_width*texture_height*image_bytes); - memset(ImageData,0,texture_width*texture_height*image_bytes); - - glDisable(GL_BLEND); - glDisable(GL_DEPTH_TEST); - glDepthMask(GL_FALSE); - glDisable(GL_CULL_FACE); - - glEnable(GL_TEXTURE_2D); - - // set alignment as default is 4 which will break some files - glAdjustAlignment(image_width * image_bytes); - - mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n",texture_width,texture_height); - -#if 1 -// glBindTexture(GL_TEXTURE_2D, texture_id); - glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, gl_texfmt, texture_width, texture_height, 0, - gl_format, gl_type, ImageData); -#endif - - free (ImageData); - - resize(d_width,d_height); - - glClearColor( 0.0f,0.0f,0.0f,0.0f ); - glClear( GL_COLOR_BUFFER_BIT ); - -// printf("OpenGL setup OK!\n"); - + } if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop); + vo_x11_nofs_sizepos(0, 0, d_width, d_height); + if (vo_fs ^ (flags & VOFLAG_FULLSCREEN)) + vo_x11_fullscreen(); + setGlWindow(&gl_vinfo, &gl_context, vo_window); + initGl(vo_dwidth, vo_dheight); + return 0; } @@ -519,6 +533,7 @@ static void uninit(void) { if ( !vo_config_count ) return; + releaseGlContext(&gl_vinfo, &gl_context); vo_x11_uninit(); } @@ -612,6 +627,8 @@ static uint32_t control(uint32_t request, void *data, ...) case VOCTRL_RESUME: return (int_pause=0); case VOCTRL_QUERY_FORMAT: return query_format(*((uint32_t*)data)); + case VOCTRL_GUISUPPORT: + return VO_TRUE; case VOCTRL_ONTOP: vo_x11_ontop(); return VO_TRUE; |