Mercurial > mplayer.hg
annotate libvo/vo_gl.c @ 12274:6fbd0aa81550
Suggest -playlist if asf_stream_start fails
Patch by adland
author | rtognimp |
---|---|
date | Sun, 25 Apr 2004 12:46:37 +0000 |
parents | 2e8b305586a0 |
children | d97398ed403e |
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 /* local data */ |
36 static unsigned char *ImageData=NULL; | |
37 | |
38 static GLXContext wsGLXContext; | |
2041
ba8a225d1a18
now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents:
2040
diff
changeset
|
39 static int wsGLXAttrib[] = { GLX_RGBA, |
1 | 40 GLX_RED_SIZE,1, |
41 GLX_GREEN_SIZE,1, | |
42 GLX_BLUE_SIZE,1, | |
43 GLX_DOUBLEBUFFER, | |
44 None }; | |
45 | |
46 | |
47 static uint32_t image_width; | |
48 static uint32_t image_height; | |
49 static uint32_t image_bytes; | |
12159 | 50 static int many_fmts; |
51 static GLenum gl_format; | |
52 static GLenum gl_type; | |
1 | 53 |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10138
diff
changeset
|
54 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
|
55 |
1 | 56 static uint32_t texture_width; |
57 static uint32_t texture_height; | |
58 | |
8654
2c4cebb8637d
- optional slice height for -vo gl (example: -vo gl:32)
arpi
parents:
8148
diff
changeset
|
59 static int slice_height=1; |
2c4cebb8637d
- optional slice height for -vo gl (example: -vo gl:32)
arpi
parents:
8148
diff
changeset
|
60 |
612 | 61 static void resize(int x,int y){ |
11988 | 62 mp_msg(MSGT_VO, MSGL_V, "[gl] Resize: %dx%d\n",x,y); |
1 | 63 glViewport( 0, 0, x, y ); |
64 | |
65 glMatrixMode(GL_PROJECTION); | |
66 glLoadIdentity(); | |
67 glOrtho(0, image_width, image_height, 0, -1,1); | |
68 | |
69 glMatrixMode(GL_MODELVIEW); | |
70 glLoadIdentity(); | |
71 } | |
72 | |
12159 | 73 static int find_gl_format (uint32_t format) |
74 { | |
75 switch (format) { | |
76 case IMGFMT_RGB24: | |
77 gl_format = GL_RGB; | |
78 gl_type = GL_UNSIGNED_BYTE; | |
79 break; | |
80 case IMGFMT_RGB32: | |
81 gl_format = GL_RGBA; | |
82 gl_type = GL_UNSIGNED_BYTE; | |
83 break; | |
84 case IMGFMT_Y800: | |
85 case IMGFMT_Y8: | |
86 gl_format = GL_LUMINANCE; | |
87 gl_type = GL_UNSIGNED_BYTE; | |
88 break; | |
89 #ifdef GL_VERSION_1_2 | |
90 case IMGFMT_RGB8: | |
91 gl_format = GL_RGB; | |
92 gl_type = GL_UNSIGNED_BYTE_3_3_2; | |
93 break; | |
94 case IMGFMT_RGB15: | |
95 gl_format = GL_RGBA; | |
96 gl_type = GL_UNSIGNED_SHORT_5_5_5_1; | |
97 break; | |
98 case IMGFMT_RGB16: | |
99 gl_format = GL_RGB; | |
100 gl_type = GL_UNSIGNED_SHORT_5_6_5; | |
101 break; | |
102 case IMGFMT_BGR8: | |
103 // special case as red and blue have a differen number of bits. | |
104 // GL_BGR and GL_UNSIGNED_BYTE_3_3_2 isn't supported at least | |
105 // by nVidia drivers, and in addition would give more bits to | |
106 // blue than to red, which isn't wanted | |
107 gl_format = GL_RGB; | |
108 gl_type = GL_UNSIGNED_BYTE_2_3_3_REV; | |
109 break; | |
110 case IMGFMT_BGR15: | |
111 gl_format = GL_BGRA; | |
112 gl_type = GL_UNSIGNED_SHORT_5_5_5_1; | |
113 break; | |
114 case IMGFMT_BGR16: | |
115 gl_format = GL_RGB; | |
116 gl_type = GL_UNSIGNED_SHORT_5_6_5_REV; | |
117 break; | |
118 case IMGFMT_BGR24: | |
119 gl_format = GL_BGR; | |
120 gl_type = GL_UNSIGNED_BYTE; | |
121 break; | |
122 case IMGFMT_BGR32: | |
123 gl_format = GL_BGRA; | |
124 gl_type = GL_UNSIGNED_BYTE; | |
125 break; | |
126 #endif | |
127 default: | |
128 gl_format = GL_RGBA; | |
129 gl_type = GL_UNSIGNED_BYTE; | |
130 return 0; | |
131 } | |
132 return 1; | |
133 } | |
134 | |
1 | 135 /* connect to server, create and map window, |
136 * allocate colors and (shared) memory | |
137 */ | |
138 static uint32_t | |
7124
eca7dbad0166
finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents:
7111
diff
changeset
|
139 config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
1 | 140 { |
2041
ba8a225d1a18
now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents:
2040
diff
changeset
|
141 // int screen; |
1 | 142 unsigned int fg, bg; |
143 XSizeHints hint; | |
144 XVisualInfo *vinfo; | |
145 XEvent xev; | |
146 | |
1109 | 147 // XGCValues xgcv; |
1 | 148 |
149 image_height = height; | |
150 image_width = width; | |
12159 | 151 find_gl_format (format); |
10919 | 152 vo_dwidth = d_width; |
153 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
|
154 |
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10138
diff
changeset
|
155 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
|
156 |
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
|
157 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
|
158 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
|
159 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
|
160 |
48f0ac1e9d13
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents:
2057
diff
changeset
|
161 aspect(&d_width,&d_height,A_NOZOOM); |
2040 | 162 #ifdef X11_FULLSCREEN |
6095 | 163 // if( flags&0x01 ){ // (-fs) |
164 // aspect(&d_width,&d_height,A_ZOOM); | |
165 // } | |
2040 | 166 #endif |
1 | 167 hint.x = 0; |
168 hint.y = 0; | |
169 hint.width = d_width; | |
170 hint.height = d_height; | |
171 hint.flags = PPosition | PSize; | |
172 | |
173 /* Get some colors */ | |
174 | |
2041
ba8a225d1a18
now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents:
2040
diff
changeset
|
175 bg = WhitePixel(mDisplay, mScreen); |
ba8a225d1a18
now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents:
2040
diff
changeset
|
176 fg = BlackPixel(mDisplay, mScreen); |
1 | 177 |
178 /* Make the window */ | |
179 | |
2041
ba8a225d1a18
now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents:
2040
diff
changeset
|
180 vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib ); |
1290 | 181 if (vinfo == NULL) |
182 { | |
11988 | 183 mp_msg(MSGT_VO, MSGL_ERR, "[gl] no GLX support present\n"); |
1290 | 184 return -1; |
185 } | |
1 | 186 |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10138
diff
changeset
|
187 |
1137
4c7b219e126c
patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents:
1109
diff
changeset
|
188 |
7777 | 189 if ( vo_window == None ) |
190 { | |
10757
3aea64e0d6d9
Avoid flickering during resizes. Keep video contents even when paused. Fix by Tomas Simonaitis <haden@homelan.lt>
mosu
parents:
10138
diff
changeset
|
191 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
|
192 vinfo->depth, XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone)); |
1 | 193 |
7777 | 194 vo_x11_classhint( mDisplay,vo_window,"gl" ); |
195 vo_hidecursor(mDisplay,vo_window); | |
1 | 196 |
7777 | 197 // if ( flags&0x01 ) vo_x11_decoration( mDisplay,vo_window,0 ); |
198 XSelectInput(mDisplay, vo_window, StructureNotifyMask); | |
199 /* 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
|
200 XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint); |
7777 | 201 /* Map window. */ |
202 XMapWindow(mDisplay, vo_window); | |
203 if ( flags&1 ) vo_x11_fullscreen(); | |
4017 | 204 #ifdef HAVE_XINERAMA |
7777 | 205 vo_x11_xinerama_move(mDisplay,vo_window); |
4017 | 206 #endif |
1 | 207 |
7777 | 208 /* Wait for map. */ |
209 do | |
210 { | |
2041
ba8a225d1a18
now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents:
2040
diff
changeset
|
211 XNextEvent(mDisplay, &xev); |
7777 | 212 } |
213 while (xev.type != MapNotify || xev.xmap.event != vo_window); | |
1 | 214 |
7777 | 215 XSelectInput(mDisplay, vo_window, NoEventMask); |
216 } | |
1 | 217 |
7777 | 218 if ( vo_config_count ) glXDestroyContext( mDisplay,wsGLXContext ); |
219 wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True ); | |
220 glXMakeCurrent( mDisplay,vo_window,wsGLXContext ); | |
1 | 221 |
2041
ba8a225d1a18
now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents:
2040
diff
changeset
|
222 XFlush(mDisplay); |
ba8a225d1a18
now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents:
2040
diff
changeset
|
223 XSync(mDisplay, False); |
1 | 224 |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6212
diff
changeset
|
225 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
|
226 | ButtonPressMask | ButtonReleaseMask | ExposureMask |
4658 | 227 ); |
1 | 228 |
229 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
|
230 while(texture_width<image_width || texture_width<image_height) texture_width*=2; |
1 | 231 texture_height=texture_width; |
232 | |
10138
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
233 image_bytes=(IMGFMT_RGB_DEPTH(format)+7)/8; |
1 | 234 |
7777 | 235 if ( ImageData ) free( ImageData ); |
1 | 236 ImageData=malloc(texture_width*texture_height*image_bytes); |
237 memset(ImageData,128,texture_width*texture_height*image_bytes); | |
238 | |
239 glDisable(GL_BLEND); | |
240 glDisable(GL_DEPTH_TEST); | |
241 glDepthMask(GL_FALSE); | |
242 glDisable(GL_CULL_FACE); | |
243 | |
244 glEnable(GL_TEXTURE_2D); | |
245 | |
11988 | 246 mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n",texture_width,texture_height); |
1 | 247 |
248 #if 1 | |
249 // glBindTexture(GL_TEXTURE_2D, texture_id); | |
250 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
251 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); | |
10138
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
252 /* Old OpenGL 1.0 used the third parameter (known as internalFormat) as an |
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
253 integer, which indicated the bytes per pixel (bpp). Later in OpenGL 1.1 |
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
254 they switched to constants, like GL_RGB8. GL_RGB8 means 8 bits for each |
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
255 channel (R,G,B), so it's equal to RGB24. It should be safe to pass the |
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
256 image_bytes to internalFormat with newer OpenGL versions. |
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
257 Anyway, I'm leaving this so as it was, it doesn't hurt, as OpenGL 1.1 is |
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
258 about 10 years old too. -- alex |
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
259 */ |
1 | 260 #ifdef TEXTUREFORMAT_32BPP |
261 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture_width, texture_height, 0, | |
262 #else | |
10138
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
263 glTexImage2D(GL_TEXTURE_2D, 0, image_bytes, texture_width, texture_height, 0, |
1 | 264 #endif |
265 (image_bytes==4)?GL_RGBA:GL_BGR, GL_UNSIGNED_BYTE, ImageData); | |
266 #endif | |
267 | |
268 resize(d_width,d_height); | |
269 | |
270 glClearColor( 1.0f,0.0f,1.0f,0.0f ); | |
271 glClear( GL_COLOR_BUFFER_BIT ); | |
272 | |
273 // printf("OpenGL setup OK!\n"); | |
274 | |
2041
ba8a225d1a18
now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents:
2040
diff
changeset
|
275 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
|
276 |
11542 | 277 if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop); |
278 | |
1 | 279 return 0; |
280 } | |
281 | |
31 | 282 static void check_events(void) |
1 | 283 { |
2041
ba8a225d1a18
now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents:
2040
diff
changeset
|
284 int e=vo_x11_check_events(mDisplay); |
31 | 285 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
|
286 if(e&VO_EVENT_EXPOSE && int_pause) flip_page(); |
31 | 287 } |
1 | 288 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1302
diff
changeset
|
289 static void draw_osd(void) |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1302
diff
changeset
|
290 { |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1302
diff
changeset
|
291 } |
31 | 292 |
293 static void | |
294 flip_page(void) | |
295 { | |
296 | |
1 | 297 // glEnable(GL_TEXTURE_2D); |
298 // glBindTexture(GL_TEXTURE_2D, texture_id); | |
299 | |
300 glColor3f(1,1,1); | |
301 glBegin(GL_QUADS); | |
302 glTexCoord2f(0,0);glVertex2i(0,0); | |
303 glTexCoord2f(0,1);glVertex2i(0,texture_height); | |
304 glTexCoord2f(1,1);glVertex2i(texture_width,texture_height); | |
305 glTexCoord2f(1,0);glVertex2i(texture_width,0); | |
306 glEnd(); | |
307 | |
308 // glFlush(); | |
309 glFinish(); | |
6095 | 310 glXSwapBuffers( mDisplay,vo_window ); |
311 | |
1 | 312 } |
313 | |
314 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num) | |
315 static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) | |
316 { | |
317 return 0; | |
318 } | |
319 | |
320 | |
10138
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
321 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
|
322 draw_frame(uint8_t *src[]) |
1 | 323 { |
324 int i; | |
325 uint8_t *ImageData=src[0]; | |
326 | |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
327 if (slice_height == 0) |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
328 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image_width, image_height, |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
329 gl_format, gl_type, ImageData); |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
330 else |
8654
2c4cebb8637d
- optional slice height for -vo gl (example: -vo gl:32)
arpi
parents:
8148
diff
changeset
|
331 for(i=0;i<image_height;i+=slice_height){ |
1 | 332 glTexSubImage2D( GL_TEXTURE_2D, // target |
333 0, // level | |
334 0, // x offset | |
335 // image_height-1-i, // y offset | |
336 i, // y offset | |
337 image_width, // width | |
8654
2c4cebb8637d
- optional slice height for -vo gl (example: -vo gl:32)
arpi
parents:
8148
diff
changeset
|
338 (i+slice_height<=image_height)?slice_height:image_height-i, // height |
12159 | 339 gl_format, |
340 gl_type, | |
1 | 341 ImageData+i*image_bytes*image_width ); // *pixels |
342 } | |
343 | |
344 return 0; | |
345 } | |
346 | |
347 static uint32_t | |
348 query_format(uint32_t format) | |
349 { | |
10138
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
350 if ((format == IMGFMT_RGB24) || (format == IMGFMT_RGB32)) |
6212 | 351 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; |
12159 | 352 if (many_fmts && find_gl_format(format)) |
353 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; | |
1 | 354 return 0; |
355 } | |
356 | |
357 | |
358 static void | |
359 uninit(void) | |
360 { | |
6095 | 361 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
|
362 saver_on(mDisplay); // screen saver back on |
6095 | 363 vo_x11_uninit(); |
1 | 364 } |
4352 | 365 |
366 static uint32_t preinit(const char *arg) | |
367 { | |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
368 int parse_err = 0; |
12159 | 369 many_fmts = 0; |
370 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
|
371 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
|
372 { |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
373 char *parse_pos = &arg[0]; |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
374 while (parse_pos[0] && !parse_err) { |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
375 if (strncmp (parse_pos, "manyfmts", 8) == 0) { |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
376 parse_pos = &parse_pos[8]; |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
377 many_fmts = 1; |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
378 } else if (strncmp (parse_pos, "slice-height=", 13) == 0) { |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
379 parse_pos = &parse_pos[13]; |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
380 slice_height = strtol(parse_pos, &parse_pos, 0); |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
381 if (slice_height < 0) parse_err = 1; |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
382 } |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
383 if (parse_pos[0] == ':') parse_pos = &parse_pos[1]; |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
384 else if (parse_pos[0]) parse_err = 1; |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
385 } |
8654
2c4cebb8637d
- optional slice height for -vo gl (example: -vo gl:32)
arpi
parents:
8148
diff
changeset
|
386 } |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
387 if (parse_err) { |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
388 mp_msg(MSGT_VO, MSGL_ERR, |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
389 "\n-vo gl command line help:\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
390 "Example: mplayer -vo gl:slice-height=4\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
391 "\nOptions:\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
392 " manyfmts\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
393 " Enable extended color formats for OpenGL 1.2 and later\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
394 " slice-height=<0-...>\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
395 " Slice size for texture transfer, 0 for whole image\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
396 "\n" ); |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
397 return -1; |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
398 } |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
399 if (many_fmts) |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
400 mp_msg (MSGT_VO, MSGL_WARN, "[gl] using extended formats.\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
401 "Make sure you have OpenGL >= 1.2 and used corresponding " |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
402 "headers for compiling!\n"); |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
403 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
|
404 "(0 means image height).\n", slice_height); |
7931 | 405 if( !vo_init() ) return -1; // Can't open X11 |
7777 | 406 |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4658
diff
changeset
|
407 return 0; |
4352 | 408 } |
409 | |
4596 | 410 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 411 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4448
diff
changeset
|
412 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
|
413 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
|
414 case VOCTRL_RESUME: return (int_pause=0); |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4448
diff
changeset
|
415 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4448
diff
changeset
|
416 return query_format(*((uint32_t*)data)); |
11542 | 417 case VOCTRL_ONTOP: |
418 vo_x11_ontop(); | |
419 return VO_TRUE; | |
6095 | 420 case VOCTRL_FULLSCREEN: |
421 vo_x11_fullscreen(); | |
422 return VO_TRUE; | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4448
diff
changeset
|
423 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4448
diff
changeset
|
424 return VO_NOTIMPL; |
4352 | 425 } |