comparison libvo/vo_gl.c @ 16593:1c13fb2ba5a9

Allow specifying a custom (ppm) texture for texture unit 3
author reimar
date Sun, 25 Sep 2005 16:31:58 +0000
parents 26b156d7a68d
children b3a9fb41f475
comparison
equal deleted inserted replaced
16592:1bb2b2696451 16593:1c13fb2ba5a9
74 static int gl_buffersize; 74 static int gl_buffersize;
75 static GLuint fragprog; 75 static GLuint fragprog;
76 static GLuint uvtexs[2]; 76 static GLuint uvtexs[2];
77 static GLuint lookupTex; 77 static GLuint lookupTex;
78 static char *custom_prog; 78 static char *custom_prog;
79 static char *custom_tex;
80 static int custom_tlin;
79 81
80 static int int_pause; 82 static int int_pause;
81 static int eq_bri = 0; 83 static int eq_bri = 0;
82 static int eq_cont = 0; 84 static int eq_cont = 0;
83 static int eq_sat = 0; 85 static int eq_sat = 0;
172 free(prog); 174 free(prog);
173 } 175 }
174 ProgramEnvParameter4f(GL_FRAGMENT_PROGRAM, 0, 176 ProgramEnvParameter4f(GL_FRAGMENT_PROGRAM, 0,
175 1.0 / texture_width, 1.0 / texture_height, 0, 0); 177 1.0 / texture_width, 1.0 / texture_height, 0, 0);
176 } 178 }
179 if (custom_tex) {
180 FILE *f = fopen(custom_tex, "r");
181 if (!f)
182 mp_msg(MSGT_VO, MSGL_WARN,
183 "[gl] Could not read customtex %s\n", custom_tex);
184 else {
185 int width, height, maxval;
186 ActiveTexture(GL_TEXTURE3);
187 if (glCreatePPMTex(GL_TEXTURE_2D, 3,
188 custom_tlin?GL_LINEAR:GL_NEAREST,
189 f, &width, &height, &maxval))
190 ProgramEnvParameter4f(GL_FRAGMENT_PROGRAM, 1,
191 1.0 / width, 1.0 / height, 1.0 / maxval, 0);
192 else
193 mp_msg(MSGT_VO, MSGL_WARN,
194 "[gl] Error parsing customtex %s\n", custom_tex);
195 fclose(f);
196 ActiveTexture(GL_TEXTURE0);
197 }
198 }
177 } 199 }
178 200
179 /** 201 /**
180 * \brief remove all OSD textures and display-lists, thus clearing it. 202 * \brief remove all OSD textures and display-lists, thus clearing it.
181 */ 203 */
650 if ( !vo_config_count ) return; 672 if ( !vo_config_count ) return;
651 uninitGl(); 673 uninitGl();
652 releaseGlContext(&gl_vinfo, &gl_context); 674 releaseGlContext(&gl_vinfo, &gl_context);
653 if (custom_prog) free(custom_prog); 675 if (custom_prog) free(custom_prog);
654 custom_prog = NULL; 676 custom_prog = NULL;
677 if (custom_tex) free(custom_tex);
678 custom_tex = NULL;
655 #ifdef GL_WIN32 679 #ifdef GL_WIN32
656 vo_w32_uninit(); 680 vo_w32_uninit();
657 #else 681 #else
658 vo_x11_uninit(); 682 vo_x11_uninit();
659 #endif 683 #endif
668 {"rectangle", OPT_ARG_INT, &use_rectangle,(opt_test_f)int_non_neg}, 692 {"rectangle", OPT_ARG_INT, &use_rectangle,(opt_test_f)int_non_neg},
669 {"yuv", OPT_ARG_INT, &use_yuv, (opt_test_f)int_non_neg}, 693 {"yuv", OPT_ARG_INT, &use_yuv, (opt_test_f)int_non_neg},
670 {"glfinish", OPT_ARG_BOOL, &use_glFinish, NULL}, 694 {"glfinish", OPT_ARG_BOOL, &use_glFinish, NULL},
671 {"swapinterval", OPT_ARG_INT, &swap_interval,NULL}, 695 {"swapinterval", OPT_ARG_INT, &swap_interval,NULL},
672 {"customprog", OPT_ARG_MSTRZ,&custom_prog, NULL}, 696 {"customprog", OPT_ARG_MSTRZ,&custom_prog, NULL},
697 {"customtex", OPT_ARG_MSTRZ,&custom_tex, NULL},
698 {"customtlin", OPT_ARG_BOOL, &custom_tlin, NULL},
673 {NULL} 699 {NULL}
674 }; 700 };
675 701
676 static int preinit(const char *arg) 702 static int preinit(const char *arg)
677 { 703 {
684 use_rectangle = 0; 710 use_rectangle = 0;
685 use_glFinish = 0; 711 use_glFinish = 0;
686 swap_interval = 1; 712 swap_interval = 1;
687 slice_height = 4; 713 slice_height = 4;
688 custom_prog = NULL; 714 custom_prog = NULL;
715 custom_tex = NULL;
716 custom_tlin = 1;
689 if (subopt_parse(arg, subopts) != 0) { 717 if (subopt_parse(arg, subopts) != 0) {
690 mp_msg(MSGT_VO, MSGL_FATAL, 718 mp_msg(MSGT_VO, MSGL_FATAL,
691 "\n-vo gl command line help:\n" 719 "\n-vo gl command line help:\n"
692 "Example: mplayer -vo gl:slice-height=4\n" 720 "Example: mplayer -vo gl:slice-height=4\n"
693 "\nOptions:\n" 721 "\nOptions:\n"
717 " 4: use fragment program with gamma correction via lookup.\n" 745 " 4: use fragment program with gamma correction via lookup.\n"
718 " customprog=<filename>\n" 746 " customprog=<filename>\n"
719 " use a custom YUV conversion program\n" 747 " use a custom YUV conversion program\n"
720 " customtex=<filename>\n" 748 " customtex=<filename>\n"
721 " use a custom YUV conversion lookup texture\n" 749 " use a custom YUV conversion lookup texture\n"
750 " nocustomtlin\n"
751 " use GL_NEAREST scaling for customtex texture\n"
722 "\n" ); 752 "\n" );
723 return -1; 753 return -1;
724 } 754 }
725 if (use_rectangle == 1) 755 if (use_rectangle == 1)
726 gl_target = GL_TEXTURE_RECTANGLE; 756 gl_target = GL_TEXTURE_RECTANGLE;