# HG changeset patch # User reimar # Date 1150361021 0 # Node ID 5d01eb066fa39288588c9cdc6304450fd8d455db # Parent 7ef29a590f3f342df8a1b3f954408455dfad0a16 Reduce number of OpenGL state changes when drawing OSD by first drawing alpha. diff -r 7ef29a590f3f -r 5d01eb066fa3 libvo/vo_gl.c --- a/libvo/vo_gl.c Thu Jun 15 08:09:03 2006 +0000 +++ b/libvo/vo_gl.c Thu Jun 15 08:43:41 2006 +0000 @@ -53,6 +53,9 @@ #endif //! Display lists that draw the OSD parts static GLuint osdDispList[MAX_OSD_PARTS]; +#ifndef FAST_OSD +static GLuint osdaDispList[MAX_OSD_PARTS]; +#endif //! How many parts the OSD currently consists of static int osdtexCnt; static int osd_color; @@ -210,6 +213,8 @@ glDeleteTextures(osdtexCnt, osdtex); #ifndef FAST_OSD glDeleteTextures(osdtexCnt, osdatex); + for (i = 0; i < osdtexCnt; i++) + glDeleteLists(osdaDispList[i], 1); #endif for (i = 0; i < osdtexCnt; i++) glDeleteLists(osdDispList[i], 1); @@ -473,16 +478,17 @@ BindTexture(gl_target, 0); // Create a list for rendering this OSD part +#ifndef FAST_OSD + osdaDispList[osdtexCnt] = glGenLists(1); + glNewList(osdaDispList[osdtexCnt], GL_COMPILE); + // render alpha + BindTexture(gl_target, osdatex[osdtexCnt]); + glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0, 0); + glEndList(); +#endif osdDispList[osdtexCnt] = glGenLists(1); glNewList(osdDispList[osdtexCnt], GL_COMPILE); -#ifndef FAST_OSD - // render alpha - glBlendFunc(GL_ZERO, GL_SRC_ALPHA); - BindTexture(gl_target, osdatex[osdtexCnt]); - glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0, 0); -#endif // render OSD - glBlendFunc (GL_ONE, GL_ONE); BindTexture(gl_target, osdtex[osdtexCnt]); glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0, 0); glEndList(); @@ -529,6 +535,11 @@ glEnable(GL_BLEND); glColor4ub((osd_color >> 16) & 0xff, (osd_color >> 8) & 0xff, osd_color & 0xff, 0xff); // draw OSD +#ifndef FAST_OSD + glBlendFunc(GL_ZERO, GL_SRC_ALPHA); + glCallLists(osdtexCnt, GL_UNSIGNED_INT, osdaDispList); +#endif + glBlendFunc(GL_ONE, GL_ONE); glCallLists(osdtexCnt, GL_UNSIGNED_INT, osdDispList); // set rendering parameters back to defaults glDisable (GL_BLEND);