annotate libvo/vo_gl.c @ 12648:c12639f67b24

Real codecs and Mac OS X, don't recommend installing Real player.
author diego
date Fri, 25 Jun 2004 16:53:48 +0000
parents d97398ed403e
children 86774b3d5ede
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 #define TEXTUREFORMAT_32BPP
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 #include <math.h>
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4658
diff changeset
7 #include <errno.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8
11988
ccb15c72f331 printf -> mp_msg
attila
parents: 11542
diff changeset
9 #include "mp_msg.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 #include <X11/Xlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 #include <X11/Xutil.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 //#include <X11/keysym.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #include <GL/glx.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 #include <errno.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 #include <GL/gl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
22 #include "x11_common.h"
2057
378aed6b232d Use aspect()
atmos4
parents: 2041
diff changeset
23 #include "aspect.h"
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
24
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7931
diff changeset
25 static vo_info_t info =
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 "X11 (OpenGL)",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 "gl",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 "Arpad Gereoffy <arpi@esp-team.scene.hu>",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 ""
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7931
diff changeset
33 LIBVO_EXTERN(gl)
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7931
diff changeset
34
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 static GLXContext wsGLXContext;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
36 static int wsGLXAttrib[] = { GLX_RGBA,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 GLX_RED_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 GLX_GREEN_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 GLX_BLUE_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 GLX_DOUBLEBUFFER,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 None };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 static uint32_t image_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 static uint32_t image_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 static uint32_t image_bytes;
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
47 static int many_fmts;
12445
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
48 static GLenum gl_texfmt;
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
49 static GLenum gl_format;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
50 static GLenum gl_type;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51
10757
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
52 static int int_pause;
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
53
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 static uint32_t texture_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 static uint32_t texture_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
57 static int slice_height=1;
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
58
612
77e0094f0cce some warnings killed
szabii
parents: 384
diff changeset
59 static void resize(int x,int y){
11988
ccb15c72f331 printf -> mp_msg
attila
parents: 11542
diff changeset
60 mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 glViewport( 0, 0, x, y );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 glMatrixMode(GL_PROJECTION);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 glLoadIdentity();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 glOrtho(0, image_width, image_height, 0, -1,1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 glMatrixMode(GL_MODELVIEW);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 glLoadIdentity();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
71 static int find_gl_format (uint32_t format)
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
72 {
12445
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
73 image_bytes = (IMGFMT_RGB_DEPTH(format)+7)/8;
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
74 gl_texfmt = 3;
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
75 switch (format) {
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
76 case IMGFMT_RGB24:
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
77 gl_format = GL_RGB;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
78 gl_type = GL_UNSIGNED_BYTE;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
79 break;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
80 case IMGFMT_RGB32:
12445
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
81 gl_texfmt = 4;
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
82 gl_format = GL_RGBA;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
83 gl_type = GL_UNSIGNED_BYTE;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
84 break;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
85 case IMGFMT_Y800:
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
86 case IMGFMT_Y8:
12445
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
87 gl_texfmt = 1;
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
88 image_bytes = 1;
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
89 gl_format = GL_LUMINANCE;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
90 gl_type = GL_UNSIGNED_BYTE;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
91 break;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
92 #ifdef GL_VERSION_1_2
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
93 case IMGFMT_RGB8:
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
94 gl_format = GL_RGB;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
95 gl_type = GL_UNSIGNED_BYTE_3_3_2;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
96 break;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
97 case IMGFMT_RGB15:
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
98 gl_format = GL_RGBA;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
99 gl_type = GL_UNSIGNED_SHORT_5_5_5_1;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
100 break;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
101 case IMGFMT_RGB16:
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
102 gl_format = GL_RGB;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
103 gl_type = GL_UNSIGNED_SHORT_5_6_5;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
104 break;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
105 case IMGFMT_BGR8:
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
106 // special case as red and blue have a differen number of bits.
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
107 // GL_BGR and GL_UNSIGNED_BYTE_3_3_2 isn't supported at least
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
108 // by nVidia drivers, and in addition would give more bits to
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
109 // blue than to red, which isn't wanted
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
110 gl_format = GL_RGB;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
111 gl_type = GL_UNSIGNED_BYTE_2_3_3_REV;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
112 break;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
113 case IMGFMT_BGR15:
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
114 gl_format = GL_BGRA;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
115 gl_type = GL_UNSIGNED_SHORT_5_5_5_1;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
116 break;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
117 case IMGFMT_BGR16:
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
118 gl_format = GL_RGB;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
119 gl_type = GL_UNSIGNED_SHORT_5_6_5_REV;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
120 break;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
121 case IMGFMT_BGR24:
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
122 gl_format = GL_BGR;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
123 gl_type = GL_UNSIGNED_BYTE;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
124 break;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
125 case IMGFMT_BGR32:
12445
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
126 gl_texfmt = 4;
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
127 gl_format = GL_BGRA;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
128 gl_type = GL_UNSIGNED_BYTE;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
129 break;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
130 #endif
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
131 default:
12445
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
132 gl_texfmt = 4;
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
133 gl_format = GL_RGBA;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
134 gl_type = GL_UNSIGNED_BYTE;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
135 return 0;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
136 }
12445
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
137 #ifdef TEXTUREFORMAT_32BPP
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
138 gl_texfmt = GL_RGB8;
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
139 #endif
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
140 return 1;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
141 }
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
142
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 /* connect to server, create and map window,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144 * allocate colors and (shared) memory
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 static uint32_t
7124
eca7dbad0166 finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents: 7111
diff changeset
147 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 {
12445
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
149 unsigned char *ImageData=NULL;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
150 // int screen;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 unsigned int fg, bg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 XSizeHints hint;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 XVisualInfo *vinfo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 XEvent xev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155
1109
a013b2124f05 -Wall like fixes
al3x
parents: 614
diff changeset
156 // XGCValues xgcv;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 image_height = height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159 image_width = width;
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
160 find_gl_format (format);
10919
dbb3f474c9de fix fullscreen switching in vo gl and vo gl2
faust3
parents: 10757
diff changeset
161 vo_dwidth = d_width;
dbb3f474c9de fix fullscreen switching in vo gl and vo gl2
faust3
parents: 10757
diff changeset
162 vo_dheight = d_height;
10757
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
163
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
164 int_pause = 0;
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
165
2249
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2057
diff changeset
166 aspect_save_orig(width,height);
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2057
diff changeset
167 aspect_save_prescale(d_width,d_height);
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2057
diff changeset
168 aspect_save_screenres(vo_screenwidth,vo_screenheight);
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2057
diff changeset
169
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2057
diff changeset
170 aspect(&d_width,&d_height,A_NOZOOM);
2040
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
171 #ifdef X11_FULLSCREEN
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
172 // if( flags&0x01 ){ // (-fs)
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
173 // aspect(&d_width,&d_height,A_ZOOM);
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
174 // }
2040
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
175 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 hint.x = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 hint.y = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 hint.width = d_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 hint.height = d_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 hint.flags = PPosition | PSize;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 /* Get some colors */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
184 bg = WhitePixel(mDisplay, mScreen);
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
185 fg = BlackPixel(mDisplay, mScreen);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 /* Make the window */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
189 vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib );
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
190 if (vinfo == NULL)
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
191 {
11988
ccb15c72f331 printf -> mp_msg
attila
parents: 11542
diff changeset
192 mp_msg(MSGT_VO, MSGL_ERR, "[gl] no GLX support present\n");
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
193 return -1;
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
194 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195
10757
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
196
1137
4c7b219e126c patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents: 1109
diff changeset
197
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
198 if ( vo_window == None )
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
199 {
10757
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
200 vo_window = vo_x11_create_smooth_window(mDisplay, mRootWin, vinfo->visual, hint.x, hint.y, hint.width, hint.height,
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
201 vinfo->depth, XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone));
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
203 vo_x11_classhint( mDisplay,vo_window,"gl" );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
204 vo_hidecursor(mDisplay,vo_window);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
206 // if ( flags&0x01 ) vo_x11_decoration( mDisplay,vo_window,0 );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
207 XSelectInput(mDisplay, vo_window, StructureNotifyMask);
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
208 /* Tell other applications about this window */
10138
5e286cc6ad21 Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents: 8654
diff changeset
209 XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint);
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
210 /* Map window. */
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
211 XMapWindow(mDisplay, vo_window);
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
212 if ( flags&1 ) vo_x11_fullscreen();
4017
21a75ab24703 Xinerama patch number two by attila.
atmos4
parents: 2732
diff changeset
213 #ifdef HAVE_XINERAMA
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
214 vo_x11_xinerama_move(mDisplay,vo_window);
4017
21a75ab24703 Xinerama patch number two by attila.
atmos4
parents: 2732
diff changeset
215 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
217 /* Wait for map. */
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
218 do
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
219 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
220 XNextEvent(mDisplay, &xev);
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
221 }
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
222 while (xev.type != MapNotify || xev.xmap.event != vo_window);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
224 XSelectInput(mDisplay, vo_window, NoEventMask);
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
225 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
227 if ( vo_config_count ) glXDestroyContext( mDisplay,wsGLXContext );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
228 wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
229 glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
231 XFlush(mDisplay);
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
232 XSync(mDisplay, False);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233
6953
ce67cc1f0beb ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents: 6212
diff changeset
234 vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
10757
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
235 | ButtonPressMask | ButtonReleaseMask | ExposureMask
4658
93d562ad1c22 Added new input mouse support in x11 vo
albeu
parents: 4596
diff changeset
236 );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 texture_width=32;
10138
5e286cc6ad21 Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents: 8654
diff changeset
239 while(texture_width<image_width || texture_width<image_height) texture_width*=2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 texture_height=texture_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 ImageData=malloc(texture_width*texture_height*image_bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 memset(ImageData,128,texture_width*texture_height*image_bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 glDisable(GL_BLEND);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 glDisable(GL_DEPTH_TEST);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 glDepthMask(GL_FALSE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 glDisable(GL_CULL_FACE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 glEnable(GL_TEXTURE_2D);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251
11988
ccb15c72f331 printf -> mp_msg
attila
parents: 11542
diff changeset
252 mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n",texture_width,texture_height);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 #if 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 // glBindTexture(GL_TEXTURE_2D, texture_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
12445
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
258 glTexImage2D(GL_TEXTURE_2D, 0, gl_texfmt, texture_width, texture_height, 0,
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
259 gl_format, gl_type, ImageData);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260 #endif
12445
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
261
d97398ed403e changes to get manyfmts nearer to working and fixed memory leak
reimar
parents: 12212
diff changeset
262 free (ImageData);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 resize(d_width,d_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 glClearColor( 1.0f,0.0f,1.0f,0.0f );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 glClear( GL_COLOR_BUFFER_BIT );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 // printf("OpenGL setup OK!\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
271 saver_off(mDisplay); // turning off screen saver
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
272
11542
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 10919
diff changeset
273 if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 10919
diff changeset
274
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
278 static void check_events(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
280 int e=vo_x11_check_events(mDisplay);
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
281 if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
10757
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
282 if(e&VO_EVENT_EXPOSE && int_pause) flip_page();
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
283 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
285 static void draw_osd(void)
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
286 {
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
287 }
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
288
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
289 static void
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
290 flip_page(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
291 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
292
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 // glEnable(GL_TEXTURE_2D);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294 // glBindTexture(GL_TEXTURE_2D, texture_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296 glColor3f(1,1,1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297 glBegin(GL_QUADS);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298 glTexCoord2f(0,0);glVertex2i(0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 glTexCoord2f(0,1);glVertex2i(0,texture_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 glTexCoord2f(1,1);glVertex2i(texture_width,texture_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301 glTexCoord2f(1,0);glVertex2i(texture_width,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 glEnd();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
303
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304 // glFlush();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305 glFinish();
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
306 glXSwapBuffers( mDisplay,vo_window );
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
307
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
311 static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
312 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316
10138
5e286cc6ad21 Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents: 8654
diff changeset
317 static uint32_t
5e286cc6ad21 Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents: 8654
diff changeset
318 draw_frame(uint8_t *src[])
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321 uint8_t *ImageData=src[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322
12212
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
323 if (slice_height == 0)
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
324 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image_width, image_height,
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
325 gl_format, gl_type, ImageData);
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
326 else
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
327 for(i=0;i<image_height;i+=slice_height){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330 0, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 // image_height-1-i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 image_width, // width
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
334 (i+slice_height<=image_height)?slice_height:image_height-i, // height
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
335 gl_format,
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
336 gl_type,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337 ImageData+i*image_bytes*image_width ); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
344 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345 {
10138
5e286cc6ad21 Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents: 8654
diff changeset
346 if ((format == IMGFMT_RGB24) || (format == IMGFMT_RGB32))
6212
2001affedb75 query_format revised
alex
parents: 6095
diff changeset
347 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
348 if (many_fmts && find_gl_format(format))
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
349 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 uninit(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356 {
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
357 if ( !vo_config_count ) return;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
358 saver_on(mDisplay); // screen saver back on
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
359 vo_x11_uninit();
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 }
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
361
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
362 static uint32_t preinit(const char *arg)
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
363 {
12212
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
364 int parse_err = 0;
12159
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
365 many_fmts = 0;
9d96071652c4 vo_gl supporting more color formats for testing
reimar
parents: 11988
diff changeset
366 slice_height = 4;
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4658
diff changeset
367 if(arg)
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4658
diff changeset
368 {
12212
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
369 char *parse_pos = &arg[0];
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
370 while (parse_pos[0] && !parse_err) {
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
371 if (strncmp (parse_pos, "manyfmts", 8) == 0) {
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
372 parse_pos = &parse_pos[8];
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
373 many_fmts = 1;
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
374 } else if (strncmp (parse_pos, "slice-height=", 13) == 0) {
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
375 parse_pos = &parse_pos[13];
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
376 slice_height = strtol(parse_pos, &parse_pos, 0);
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
377 if (slice_height < 0) parse_err = 1;
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
378 }
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
379 if (parse_pos[0] == ':') parse_pos = &parse_pos[1];
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
380 else if (parse_pos[0]) parse_err = 1;
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
381 }
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
382 }
12212
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
383 if (parse_err) {
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
384 mp_msg(MSGT_VO, MSGL_ERR,
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
385 "\n-vo gl command line help:\n"
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
386 "Example: mplayer -vo gl:slice-height=4\n"
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
387 "\nOptions:\n"
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
388 " manyfmts\n"
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
389 " Enable extended color formats for OpenGL 1.2 and later\n"
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
390 " slice-height=<0-...>\n"
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
391 " Slice size for texture transfer, 0 for whole image\n"
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
392 "\n" );
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
393 return -1;
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
394 }
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
395 if (many_fmts)
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
396 mp_msg (MSGT_VO, MSGL_WARN, "[gl] using extended formats.\n"
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
397 "Make sure you have OpenGL >= 1.2 and used corresponding "
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
398 "headers for compiling!\n");
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
399 mp_msg (MSGT_VO, MSGL_INFO, "[gl] Using %d as slice height "
2e8b305586a0 fixed suboption parsing, added help for suboptions
reimar
parents: 12159
diff changeset
400 "(0 means image height).\n", slice_height);
7931
48c71b6c7389 vo_init() moved to/fixed in preinit()
arpi
parents: 7777
diff changeset
401 if( !vo_init() ) return -1; // Can't open X11
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
402
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4658
diff changeset
403 return 0;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
404 }
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
405
4596
c35d7ce151b3 10000hl to Holm... control MUST BE static...
arpi
parents: 4592
diff changeset
406 static uint32_t control(uint32_t request, void *data, ...)
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
407 {
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
408 switch (request) {
10757
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
409 case VOCTRL_PAUSE: return (int_pause=1);
3aea64e0d6d9 Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents: 10138
diff changeset
410 case VOCTRL_RESUME: return (int_pause=0);
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
411 case VOCTRL_QUERY_FORMAT:
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
412 return query_format(*((uint32_t*)data));
11542
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 10919
diff changeset
413 case VOCTRL_ONTOP:
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 10919
diff changeset
414 vo_x11_ontop();
85e503ddf65f runtime 'stay-on-top' functionality
joey
parents: 10919
diff changeset
415 return VO_TRUE;
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
416 case VOCTRL_FULLSCREEN:
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
417 vo_x11_fullscreen();
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
418 return VO_TRUE;
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
419 }
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
420 return VO_NOTIMPL;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
421 }