Add an uninit function.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16434 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2005-09-09 14:47:54 +00:00
parent a50169fe46
commit bb0c8b3df5
1 changed files with 29 additions and 15 deletions

View File

@ -53,7 +53,7 @@ static GLuint osdatex[MAX_OSD_PARTS];
//! Display lists that draw the OSD parts //! Display lists that draw the OSD parts
static GLuint osdDispList[MAX_OSD_PARTS]; static GLuint osdDispList[MAX_OSD_PARTS];
//! How many parts the OSD currently consists of //! How many parts the OSD currently consists of
static int osdtexCnt = 0; static int osdtexCnt;
static int use_aspect; static int use_aspect;
static int use_rectangle; static int use_rectangle;
@ -126,10 +126,34 @@ static void texSize(int w, int h, int *texw, int *texh) {
} }
} }
static void clearOSD() {
int i;
glDeleteTextures(osdtexCnt, osdtex);
#ifndef FAST_OSD
glDeleteTextures(osdtexCnt, osdatex);
#endif
for (i = 0; i < osdtexCnt; i++)
glDeleteLists(osdDispList[i], 1);
osdtexCnt = 0;
}
/**
* \brief uninitialize OpenGL context, freeing textures, buffers etc.
*/
static void uninitGl() {
clearOSD();
if (DeleteBuffers && gl_buffer)
DeleteBuffers(1, &gl_buffer);
gl_buffer = 0; gl_buffersize = 0;
err_shown = 0;
}
/** /**
* \brief Initialize a (new or reused) OpenGL context. * \brief Initialize a (new or reused) OpenGL context.
* set global gl-related variables to their default values
*/ */
static int initGl(uint32_t d_width, uint32_t d_height) { static int initGl(uint32_t d_width, uint32_t d_height) {
osdtexCnt = 0; gl_buffer = 0; gl_buffersize = 0; err_shown = 0;
texSize(image_width, image_height, &texture_width, &texture_height); texSize(image_width, image_height, &texture_width, &texture_height);
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -150,10 +174,6 @@ static int initGl(uint32_t d_width, uint32_t d_height) {
glClear( GL_COLOR_BUFFER_BIT ); glClear( GL_COLOR_BUFFER_BIT );
if (SwapInterval && swap_interval >= 0) if (SwapInterval && swap_interval >= 0)
SwapInterval(swap_interval); SwapInterval(swap_interval);
osdtexCnt = 0;
gl_buffer = 0;
gl_buffersize = 0;
err_shown = 0;
return 1; return 1;
} }
@ -280,6 +300,8 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
#endif #endif
glconfig: glconfig:
if (vo_config_count)
uninitGl();
setGlWindow(&gl_vinfo, &gl_context, vo_window); setGlWindow(&gl_vinfo, &gl_context, vo_window);
initGl(vo_dwidth, vo_dheight); initGl(vo_dwidth, vo_dheight);
@ -364,17 +386,8 @@ static void draw_osd(void)
{ {
if (!use_osd) return; if (!use_osd) return;
if (vo_osd_changed(0)) { if (vo_osd_changed(0)) {
int i;
int osd_h, osd_w; int osd_h, osd_w;
glDeleteTextures(osdtexCnt, osdtex); clearOSD();
#ifndef FAST_OSD
glDeleteTextures(osdtexCnt, osdatex);
#endif
for (i = 0; i < osdtexCnt; i++) {
glDeleteLists(osdDispList[i], 1);
}
osdtexCnt = 0;
osd_w = (scaled_osd) ? image_width : vo_dwidth; osd_w = (scaled_osd) ? image_width : vo_dwidth;
osd_h = (scaled_osd) ? image_height : vo_dheight; osd_h = (scaled_osd) ? image_height : vo_dheight;
vo_draw_text(osd_w, osd_h, create_osd_texture); vo_draw_text(osd_w, osd_h, create_osd_texture);
@ -507,6 +520,7 @@ static void
uninit(void) uninit(void)
{ {
if ( !vo_config_count ) return; if ( !vo_config_count ) return;
uninitGl();
releaseGlContext(&gl_vinfo, &gl_context); releaseGlContext(&gl_vinfo, &gl_context);
#ifdef GL_WIN32 #ifdef GL_WIN32
vo_w32_uninit(); vo_w32_uninit();