comparison libvo/vo_gl.c @ 18719:5d01eb066fa3

Reduce number of OpenGL state changes when drawing OSD by first drawing alpha.
author reimar
date Thu, 15 Jun 2006 08:43:41 +0000
parents 96b0da901a7d
children 8c64e049d64b
comparison
equal deleted inserted replaced
18718:7ef29a590f3f 18719:5d01eb066fa3
51 //! Alpha textures for OSD 51 //! Alpha textures for OSD
52 static GLuint osdatex[MAX_OSD_PARTS]; 52 static GLuint osdatex[MAX_OSD_PARTS];
53 #endif 53 #endif
54 //! Display lists that draw the OSD parts 54 //! Display lists that draw the OSD parts
55 static GLuint osdDispList[MAX_OSD_PARTS]; 55 static GLuint osdDispList[MAX_OSD_PARTS];
56 #ifndef FAST_OSD
57 static GLuint osdaDispList[MAX_OSD_PARTS];
58 #endif
56 //! How many parts the OSD currently consists of 59 //! How many parts the OSD currently consists of
57 static int osdtexCnt; 60 static int osdtexCnt;
58 static int osd_color; 61 static int osd_color;
59 62
60 static int use_aspect; 63 static int use_aspect;
208 if (!osdtexCnt) 211 if (!osdtexCnt)
209 return; 212 return;
210 glDeleteTextures(osdtexCnt, osdtex); 213 glDeleteTextures(osdtexCnt, osdtex);
211 #ifndef FAST_OSD 214 #ifndef FAST_OSD
212 glDeleteTextures(osdtexCnt, osdatex); 215 glDeleteTextures(osdtexCnt, osdatex);
216 for (i = 0; i < osdtexCnt; i++)
217 glDeleteLists(osdaDispList[i], 1);
213 #endif 218 #endif
214 for (i = 0; i < osdtexCnt; i++) 219 for (i = 0; i < osdtexCnt; i++)
215 glDeleteLists(osdDispList[i], 1); 220 glDeleteLists(osdDispList[i], 1);
216 osdtexCnt = 0; 221 osdtexCnt = 0;
217 } 222 }
471 #endif 476 #endif
472 477
473 BindTexture(gl_target, 0); 478 BindTexture(gl_target, 0);
474 479
475 // Create a list for rendering this OSD part 480 // Create a list for rendering this OSD part
481 #ifndef FAST_OSD
482 osdaDispList[osdtexCnt] = glGenLists(1);
483 glNewList(osdaDispList[osdtexCnt], GL_COMPILE);
484 // render alpha
485 BindTexture(gl_target, osdatex[osdtexCnt]);
486 glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0, 0);
487 glEndList();
488 #endif
476 osdDispList[osdtexCnt] = glGenLists(1); 489 osdDispList[osdtexCnt] = glGenLists(1);
477 glNewList(osdDispList[osdtexCnt], GL_COMPILE); 490 glNewList(osdDispList[osdtexCnt], GL_COMPILE);
478 #ifndef FAST_OSD
479 // render alpha
480 glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
481 BindTexture(gl_target, osdatex[osdtexCnt]);
482 glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0, 0);
483 #endif
484 // render OSD 491 // render OSD
485 glBlendFunc (GL_ONE, GL_ONE);
486 BindTexture(gl_target, osdtex[osdtexCnt]); 492 BindTexture(gl_target, osdtex[osdtexCnt]);
487 glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0, 0); 493 glDrawTex(x0, y0, w, h, 0, 0, w, h, sx, sy, use_rectangle == 1, 0, 0);
488 glEndList(); 494 glEndList();
489 495
490 osdtexCnt++; 496 osdtexCnt++;
527 glOrtho(0, vo_dwidth, vo_dheight, 0, -1, 1); 533 glOrtho(0, vo_dwidth, vo_dheight, 0, -1, 1);
528 } 534 }
529 glEnable(GL_BLEND); 535 glEnable(GL_BLEND);
530 glColor4ub((osd_color >> 16) & 0xff, (osd_color >> 8) & 0xff, osd_color & 0xff, 0xff); 536 glColor4ub((osd_color >> 16) & 0xff, (osd_color >> 8) & 0xff, osd_color & 0xff, 0xff);
531 // draw OSD 537 // draw OSD
538 #ifndef FAST_OSD
539 glBlendFunc(GL_ZERO, GL_SRC_ALPHA);
540 glCallLists(osdtexCnt, GL_UNSIGNED_INT, osdaDispList);
541 #endif
542 glBlendFunc(GL_ONE, GL_ONE);
532 glCallLists(osdtexCnt, GL_UNSIGNED_INT, osdDispList); 543 glCallLists(osdtexCnt, GL_UNSIGNED_INT, osdDispList);
533 // set rendering parameters back to defaults 544 // set rendering parameters back to defaults
534 glDisable (GL_BLEND); 545 glDisable (GL_BLEND);
535 if (!scaled_osd) 546 if (!scaled_osd)
536 glPopMatrix(); 547 glPopMatrix();