Mercurial > mplayer.hg
comparison libvo/vo_gl.c @ 16109:519a307e3ccf
OpenGL fixes for windows and vo_gl.c ported to windows.
author | reimar |
---|---|
date | Tue, 26 Jul 2005 13:47:18 +0000 |
parents | 629c54dc7e0d |
children | c81b7c1c14cb |
comparison
equal
deleted
inserted
replaced
16108:ab2504f2d5d6 | 16109:519a307e3ccf |
---|---|
28 "" | 28 "" |
29 }; | 29 }; |
30 | 30 |
31 LIBVO_EXTERN(gl) | 31 LIBVO_EXTERN(gl) |
32 | 32 |
33 #ifdef GL_WIN32 | |
34 static int gl_vinfo = 0; | |
35 static HGLRC gl_context = 0; | |
36 #else | |
33 static XVisualInfo *gl_vinfo = NULL; | 37 static XVisualInfo *gl_vinfo = NULL; |
34 static GLXContext gl_context = 0; | 38 static GLXContext gl_context = 0; |
35 static int wsGLXAttrib[] = { GLX_RGBA, | 39 static int wsGLXAttrib[] = { GLX_RGBA, |
36 GLX_RED_SIZE,1, | 40 GLX_RED_SIZE,1, |
37 GLX_GREEN_SIZE,1, | 41 GLX_GREEN_SIZE,1, |
38 GLX_BLUE_SIZE,1, | 42 GLX_BLUE_SIZE,1, |
39 GLX_DOUBLEBUFFER, | 43 GLX_DOUBLEBUFFER, |
40 None }; | 44 None }; |
45 #endif | |
41 | 46 |
42 static int use_osd; | 47 static int use_osd; |
43 static int scaled_osd; | 48 static int scaled_osd; |
44 //! How many parts the OSD may consist of at most | 49 //! How many parts the OSD may consist of at most |
45 #define MAX_OSD_PARTS 20 | 50 #define MAX_OSD_PARTS 20 |
74 | 79 |
75 static unsigned int slice_height = 1; | 80 static unsigned int slice_height = 1; |
76 | 81 |
77 static void resize(int x,int y){ | 82 static void resize(int x,int y){ |
78 mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y); | 83 mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y); |
84 #ifndef GL_WIN32 | |
79 if (WinID >= 0) { | 85 if (WinID >= 0) { |
80 int top = 0, left = 0, w = x, h = y; | 86 int top = 0, left = 0, w = x, h = y; |
81 geometry(&top, &left, &w, &h, vo_screenwidth, vo_screenheight); | 87 geometry(&top, &left, &w, &h, vo_screenwidth, vo_screenheight); |
82 glViewport(top, left, w, h); | 88 glViewport(top, left, w, h); |
83 } else | 89 } else |
90 #endif | |
84 glViewport( 0, 0, x, y ); | 91 glViewport( 0, 0, x, y ); |
85 | 92 |
86 glMatrixMode(GL_PROJECTION); | 93 glMatrixMode(GL_PROJECTION); |
87 glLoadIdentity(); | 94 glLoadIdentity(); |
88 if (vo_fs && use_aspect) { | 95 if (vo_fs && use_aspect) { |
196 vo_dheight= d_height; | 203 vo_dheight= d_height; |
197 guiGetEvent(guiSetShVideo, 0); | 204 guiGetEvent(guiSetShVideo, 0); |
198 goto glconfig; | 205 goto glconfig; |
199 } | 206 } |
200 #endif | 207 #endif |
208 #ifdef GL_WIN32 | |
209 o_dwidth = d_width; | |
210 o_dheight = d_height; | |
211 vo_fs = flags & VOFLAG_FULLSCREEN; | |
212 vo_vm = flags & VOFLAG_MODESWITCHING; | |
213 vo_dwidth = d_width; | |
214 vo_dheight = d_height; | |
215 if (!createRenderingContext()) | |
216 return -1; | |
217 #else | |
201 if (WinID >= 0) { | 218 if (WinID >= 0) { |
202 Window win_tmp; | 219 Window win_tmp; |
203 int int_tmp; | 220 int int_tmp; |
204 vo_window = WinID ? (Window)WinID : mRootWin; | 221 vo_window = WinID ? (Window)WinID : mRootWin; |
205 goto glconfig; | 222 goto glconfig; |
268 if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop); | 285 if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop); |
269 | 286 |
270 vo_x11_nofs_sizepos(vo_dx, vo_dy, d_width, d_height); | 287 vo_x11_nofs_sizepos(vo_dx, vo_dy, d_width, d_height); |
271 if (vo_fs ^ (flags & VOFLAG_FULLSCREEN)) | 288 if (vo_fs ^ (flags & VOFLAG_FULLSCREEN)) |
272 vo_x11_fullscreen(); | 289 vo_x11_fullscreen(); |
290 #endif | |
273 | 291 |
274 glconfig: | 292 glconfig: |
275 setGlWindow(&gl_vinfo, &gl_context, vo_window); | 293 setGlWindow(&gl_vinfo, &gl_context, vo_window); |
276 initGl(vo_dwidth, vo_dheight); | 294 initGl(vo_dwidth, vo_dheight); |
277 | 295 |
278 return 0; | 296 return 0; |
279 } | 297 } |
280 | 298 |
281 static void check_events(void) | 299 static void check_events(void) |
282 { | 300 { |
301 #ifdef GL_WIN32 | |
302 int e=vo_w32_check_events(); | |
303 #else | |
283 int e=vo_x11_check_events(mDisplay); | 304 int e=vo_x11_check_events(mDisplay); |
305 #endif | |
284 if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight); | 306 if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight); |
285 if(e&VO_EVENT_EXPOSE && int_pause) flip_page(); | 307 if(e&VO_EVENT_EXPOSE && int_pause) flip_page(); |
286 } | 308 } |
287 | 309 |
288 /** | 310 /** |
440 BindTexture(gl_target, 0); | 462 BindTexture(gl_target, 0); |
441 } | 463 } |
442 | 464 |
443 // glFlush(); | 465 // glFlush(); |
444 glFinish(); | 466 glFinish(); |
467 #ifdef GL_WIN32 | |
468 SwapBuffers(vo_hdc); | |
469 #else | |
445 glXSwapBuffers( mDisplay,vo_window ); | 470 glXSwapBuffers( mDisplay,vo_window ); |
471 #endif | |
446 | 472 |
447 if (vo_fs && use_aspect) | 473 if (vo_fs && use_aspect) |
448 glClear(GL_COLOR_BUFFER_BIT); | 474 glClear(GL_COLOR_BUFFER_BIT); |
449 } | 475 } |
450 | 476 |
533 static void | 559 static void |
534 uninit(void) | 560 uninit(void) |
535 { | 561 { |
536 if ( !vo_config_count ) return; | 562 if ( !vo_config_count ) return; |
537 releaseGlContext(&gl_vinfo, &gl_context); | 563 releaseGlContext(&gl_vinfo, &gl_context); |
564 #ifdef GL_WIN32 | |
565 vo_w32_uninit(); | |
566 #else | |
538 vo_x11_uninit(); | 567 vo_x11_uninit(); |
568 #endif | |
539 } | 569 } |
540 | 570 |
541 static opt_t subopts[] = { | 571 static opt_t subopts[] = { |
542 {"manyfmts", OPT_ARG_BOOL, &many_fmts, NULL}, | 572 {"manyfmts", OPT_ARG_BOOL, &many_fmts, NULL}, |
543 {"osd", OPT_ARG_BOOL, &use_osd, NULL}, | 573 {"osd", OPT_ARG_BOOL, &use_osd, NULL}, |
604 case VOCTRL_DRAW_IMAGE: | 634 case VOCTRL_DRAW_IMAGE: |
605 return draw_image(data); | 635 return draw_image(data); |
606 case VOCTRL_GUISUPPORT: | 636 case VOCTRL_GUISUPPORT: |
607 return VO_TRUE; | 637 return VO_TRUE; |
608 case VOCTRL_ONTOP: | 638 case VOCTRL_ONTOP: |
639 #ifdef GL_WIN32 | |
640 vo_w32_ontop(); | |
641 #else | |
609 vo_x11_ontop(); | 642 vo_x11_ontop(); |
643 #endif | |
610 return VO_TRUE; | 644 return VO_TRUE; |
611 case VOCTRL_FULLSCREEN: | 645 case VOCTRL_FULLSCREEN: |
646 #ifdef GL_WIN32 | |
647 vo_w32_fullscreen(); | |
648 resize(vo_dwidth, vo_dheight); | |
649 #else | |
612 vo_x11_fullscreen(); | 650 vo_x11_fullscreen(); |
651 #endif | |
613 return VO_TRUE; | 652 return VO_TRUE; |
614 case VOCTRL_GET_PANSCAN: | 653 case VOCTRL_GET_PANSCAN: |
615 if (!use_aspect) return VO_NOTIMPL; | 654 if (!use_aspect) return VO_NOTIMPL; |
616 return VO_TRUE; | 655 return VO_TRUE; |
617 case VOCTRL_SET_PANSCAN: | 656 case VOCTRL_SET_PANSCAN: |