Mercurial > mplayer.hg
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 |
rev | line source |
---|---|
1 | 1 #define TEXTUREFORMAT_32BPP |
2 | |
3 #include <stdio.h> | |
4 #include <stdlib.h> | |
5 #include <string.h> | |
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 | 8 |
11988 | 9 #include "mp_msg.h" |
1 | 10 #include "config.h" |
11 #include "video_out.h" | |
12 #include "video_out_internal.h" | |
13 | |
14 #include <X11/Xlib.h> | |
15 #include <X11/Xutil.h> | |
16 //#include <X11/keysym.h> | |
17 #include <GL/glx.h> | |
18 #include <errno.h> | |
19 | |
20 #include <GL/gl.h> | |
21 | |
31 | 22 #include "x11_common.h" |
2057 | 23 #include "aspect.h" |
31 | 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 | 26 { |
27 "X11 (OpenGL)", | |
28 "gl", | |
29 "Arpad Gereoffy <arpi@esp-team.scene.hu>", | |
30 "" | |
31 }; | |
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 | 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 | 37 GLX_RED_SIZE,1, |
38 GLX_GREEN_SIZE,1, | |
39 GLX_BLUE_SIZE,1, | |
40 GLX_DOUBLEBUFFER, | |
41 None }; | |
42 | |
43 | |
44 static uint32_t image_width; | |
45 static uint32_t image_height; | |
46 static uint32_t image_bytes; | |
12159 | 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 | 49 static GLenum gl_format; |
50 static GLenum gl_type; | |
1 | 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 | 54 static uint32_t texture_width; |
55 static uint32_t texture_height; | |
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 | 59 static void resize(int x,int y){ |
11988 | 60 mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y); |
1 | 61 glViewport( 0, 0, x, y ); |
62 | |
63 glMatrixMode(GL_PROJECTION); | |
64 glLoadIdentity(); | |
65 glOrtho(0, image_width, image_height, 0, -1,1); | |
66 | |
67 glMatrixMode(GL_MODELVIEW); | |
68 glLoadIdentity(); | |
69 } | |
70 | |
12159 | 71 static int find_gl_format (uint32_t format) |
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 | 75 switch (format) { |
76 case IMGFMT_RGB24: | |
77 gl_format = GL_RGB; | |
78 gl_type = GL_UNSIGNED_BYTE; | |
79 break; | |
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 | 82 gl_format = GL_RGBA; |
83 gl_type = GL_UNSIGNED_BYTE; | |
84 break; | |
85 case IMGFMT_Y800: | |
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 | 89 gl_format = GL_LUMINANCE; |
90 gl_type = GL_UNSIGNED_BYTE; | |
91 break; | |
92 #ifdef GL_VERSION_1_2 | |
93 case IMGFMT_RGB8: | |
94 gl_format = GL_RGB; | |
95 gl_type = GL_UNSIGNED_BYTE_3_3_2; | |
96 break; | |
97 case IMGFMT_RGB15: | |
98 gl_format = GL_RGBA; | |
99 gl_type = GL_UNSIGNED_SHORT_5_5_5_1; | |
100 break; | |
101 case IMGFMT_RGB16: | |
102 gl_format = GL_RGB; | |
103 gl_type = GL_UNSIGNED_SHORT_5_6_5; | |
104 break; | |
105 case IMGFMT_BGR8: | |
106 // special case as red and blue have a differen number of bits. | |
107 // GL_BGR and GL_UNSIGNED_BYTE_3_3_2 isn't supported at least | |
108 // by nVidia drivers, and in addition would give more bits to | |
109 // blue than to red, which isn't wanted | |
110 gl_format = GL_RGB; | |
111 gl_type = GL_UNSIGNED_BYTE_2_3_3_REV; | |
112 break; | |
113 case IMGFMT_BGR15: | |
114 gl_format = GL_BGRA; | |
115 gl_type = GL_UNSIGNED_SHORT_5_5_5_1; | |
116 break; | |
117 case IMGFMT_BGR16: | |
118 gl_format = GL_RGB; | |
119 gl_type = GL_UNSIGNED_SHORT_5_6_5_REV; | |
120 break; | |
121 case IMGFMT_BGR24: | |
122 gl_format = GL_BGR; | |
123 gl_type = GL_UNSIGNED_BYTE; | |
124 break; | |
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 | 127 gl_format = GL_BGRA; |
128 gl_type = GL_UNSIGNED_BYTE; | |
129 break; | |
130 #endif | |
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 | 133 gl_format = GL_RGBA; |
134 gl_type = GL_UNSIGNED_BYTE; | |
135 return 0; | |
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 | 140 return 1; |
141 } | |
142 | |
1 | 143 /* connect to server, create and map window, |
144 * allocate colors and (shared) memory | |
145 */ | |
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 | 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 | 151 unsigned int fg, bg; |
152 XSizeHints hint; | |
153 XVisualInfo *vinfo; | |
154 XEvent xev; | |
155 | |
1109 | 156 // XGCValues xgcv; |
1 | 157 |
158 image_height = height; | |
159 image_width = width; | |
12159 | 160 find_gl_format (format); |
10919 | 161 vo_dwidth = d_width; |
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 | 171 #ifdef X11_FULLSCREEN |
6095 | 172 // if( flags&0x01 ){ // (-fs) |
173 // aspect(&d_width,&d_height,A_ZOOM); | |
174 // } | |
2040 | 175 #endif |
1 | 176 hint.x = 0; |
177 hint.y = 0; | |
178 hint.width = d_width; | |
179 hint.height = d_height; | |
180 hint.flags = PPosition | PSize; | |
181 | |
182 /* Get some colors */ | |
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 | 186 |
187 /* Make the window */ | |
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 | 190 if (vinfo == NULL) |
191 { | |
11988 | 192 mp_msg(MSGT_VO, MSGL_ERR, "[gl] no GLX support present\n"); |
1290 | 193 return -1; |
194 } | |
1 | 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 | 198 if ( vo_window == None ) |
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 | 202 |
7777 | 203 vo_x11_classhint( mDisplay,vo_window,"gl" ); |
204 vo_hidecursor(mDisplay,vo_window); | |
1 | 205 |
7777 | 206 // if ( flags&0x01 ) vo_x11_decoration( mDisplay,vo_window,0 ); |
207 XSelectInput(mDisplay, vo_window, StructureNotifyMask); | |
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 | 210 /* Map window. */ |
211 XMapWindow(mDisplay, vo_window); | |
212 if ( flags&1 ) vo_x11_fullscreen(); | |
4017 | 213 #ifdef HAVE_XINERAMA |
7777 | 214 vo_x11_xinerama_move(mDisplay,vo_window); |
4017 | 215 #endif |
1 | 216 |
7777 | 217 /* Wait for map. */ |
218 do | |
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 | 221 } |
222 while (xev.type != MapNotify || xev.xmap.event != vo_window); | |
1 | 223 |
7777 | 224 XSelectInput(mDisplay, vo_window, NoEventMask); |
225 } | |
1 | 226 |
7777 | 227 if ( vo_config_count ) glXDestroyContext( mDisplay,wsGLXContext ); |
228 wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True ); | |
229 glXMakeCurrent( mDisplay,vo_window,wsGLXContext ); | |
1 | 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 | 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 | 236 ); |
1 | 237 |
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 | 240 texture_height=texture_width; |
241 | |
242 ImageData=malloc(texture_width*texture_height*image_bytes); | |
243 memset(ImageData,128,texture_width*texture_height*image_bytes); | |
244 | |
245 glDisable(GL_BLEND); | |
246 glDisable(GL_DEPTH_TEST); | |
247 glDepthMask(GL_FALSE); | |
248 glDisable(GL_CULL_FACE); | |
249 | |
250 glEnable(GL_TEXTURE_2D); | |
251 | |
11988 | 252 mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n",texture_width,texture_height); |
1 | 253 |
254 #if 1 | |
255 // glBindTexture(GL_TEXTURE_2D, texture_id); | |
256 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
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 | 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 | 263 |
264 resize(d_width,d_height); | |
265 | |
266 glClearColor( 1.0f,0.0f,1.0f,0.0f ); | |
267 glClear( GL_COLOR_BUFFER_BIT ); | |
268 | |
269 // printf("OpenGL setup OK!\n"); | |
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 | 273 if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop); |
274 | |
1 | 275 return 0; |
276 } | |
277 | |
31 | 278 static void check_events(void) |
1 | 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 | 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 | 283 } |
1 | 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 | 288 |
289 static void | |
290 flip_page(void) | |
291 { | |
292 | |
1 | 293 // glEnable(GL_TEXTURE_2D); |
294 // glBindTexture(GL_TEXTURE_2D, texture_id); | |
295 | |
296 glColor3f(1,1,1); | |
297 glBegin(GL_QUADS); | |
298 glTexCoord2f(0,0);glVertex2i(0,0); | |
299 glTexCoord2f(0,1);glVertex2i(0,texture_height); | |
300 glTexCoord2f(1,1);glVertex2i(texture_width,texture_height); | |
301 glTexCoord2f(1,0);glVertex2i(texture_width,0); | |
302 glEnd(); | |
303 | |
304 // glFlush(); | |
305 glFinish(); | |
6095 | 306 glXSwapBuffers( mDisplay,vo_window ); |
307 | |
1 | 308 } |
309 | |
310 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num) | |
311 static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) | |
312 { | |
313 return 0; | |
314 } | |
315 | |
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 | 319 { |
320 int i; | |
321 uint8_t *ImageData=src[0]; | |
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 | 328 glTexSubImage2D( GL_TEXTURE_2D, // target |
329 0, // level | |
330 0, // x offset | |
331 // image_height-1-i, // y offset | |
332 i, // y offset | |
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 | 335 gl_format, |
336 gl_type, | |
1 | 337 ImageData+i*image_bytes*image_width ); // *pixels |
338 } | |
339 | |
340 return 0; | |
341 } | |
342 | |
343 static uint32_t | |
344 query_format(uint32_t format) | |
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 | 347 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; |
12159 | 348 if (many_fmts && find_gl_format(format)) |
349 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; | |
1 | 350 return 0; |
351 } | |
352 | |
353 | |
354 static void | |
355 uninit(void) | |
356 { | |
6095 | 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 | 359 vo_x11_uninit(); |
1 | 360 } |
4352 | 361 |
362 static uint32_t preinit(const char *arg) | |
363 { | |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
364 int parse_err = 0; |
12159 | 365 many_fmts = 0; |
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 | 401 if( !vo_init() ) return -1; // Can't open X11 |
7777 | 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 | 404 } |
405 | |
4596 | 406 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 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 | 413 case VOCTRL_ONTOP: |
414 vo_x11_ontop(); | |
415 return VO_TRUE; | |
6095 | 416 case VOCTRL_FULLSCREEN: |
417 vo_x11_fullscreen(); | |
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 | 421 } |