Mercurial > mplayer.hg
annotate libvo/vo_gl.c @ 13491:d6f9b3cfe039
MEncoder-users mailing list created.
author | diego |
---|---|
date | Mon, 27 Sep 2004 18:13:23 +0000 |
parents | f85c105bfeaa |
children | d3ef52aafb54 |
rev | line source |
---|---|
12843
52d493f0ac79
changed misleading TEXTUREFORMAT_32BPP (was 24bpp!) to vo_gl2 style TEXTUREFORMAT_ALWAYS
reimar
parents:
12749
diff
changeset
|
1 #define TEXTUREFORMAT_ALWAYS GL_RGB8 |
1 | 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 | |
13237
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
57 static unsigned int slice_height = 1; |
8654
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; | |
13206
6e8d1ac141fc
Using updated colorspace specifications from colorspaces.txt.
reimar
parents:
13188
diff
changeset
|
80 case IMGFMT_RGBA: |
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; | |
13206
6e8d1ac141fc
Using updated colorspace specifications from colorspaces.txt.
reimar
parents:
13188
diff
changeset
|
95 gl_type = GL_UNSIGNED_BYTE_2_3_3_REV; |
12159 | 96 break; |
97 case IMGFMT_RGB15: | |
98 gl_format = GL_RGBA; | |
13206
6e8d1ac141fc
Using updated colorspace specifications from colorspaces.txt.
reimar
parents:
13188
diff
changeset
|
99 gl_type = GL_UNSIGNED_SHORT_1_5_5_5_REV; |
12159 | 100 break; |
101 case IMGFMT_RGB16: | |
102 gl_format = GL_RGB; | |
13206
6e8d1ac141fc
Using updated colorspace specifications from colorspaces.txt.
reimar
parents:
13188
diff
changeset
|
103 gl_type = GL_UNSIGNED_SHORT_5_6_5_REV; |
12159 | 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; | |
13206
6e8d1ac141fc
Using updated colorspace specifications from colorspaces.txt.
reimar
parents:
13188
diff
changeset
|
111 gl_type = GL_UNSIGNED_BYTE_3_3_2; |
12159 | 112 break; |
113 case IMGFMT_BGR15: | |
114 gl_format = GL_BGRA; | |
13206
6e8d1ac141fc
Using updated colorspace specifications from colorspaces.txt.
reimar
parents:
13188
diff
changeset
|
115 gl_type = GL_UNSIGNED_SHORT_1_5_5_5_REV; |
12159 | 116 break; |
117 case IMGFMT_BGR16: | |
118 gl_format = GL_RGB; | |
13206
6e8d1ac141fc
Using updated colorspace specifications from colorspaces.txt.
reimar
parents:
13188
diff
changeset
|
119 gl_type = GL_UNSIGNED_SHORT_5_6_5; |
12159 | 120 break; |
121 case IMGFMT_BGR24: | |
122 gl_format = GL_BGR; | |
123 gl_type = GL_UNSIGNED_BYTE; | |
124 break; | |
13206
6e8d1ac141fc
Using updated colorspace specifications from colorspaces.txt.
reimar
parents:
13188
diff
changeset
|
125 case IMGFMT_BGRA: |
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 } | |
12843
52d493f0ac79
changed misleading TEXTUREFORMAT_32BPP (was 24bpp!) to vo_gl2 style TEXTUREFORMAT_ALWAYS
reimar
parents:
12749
diff
changeset
|
137 #ifdef TEXTUREFORMAT_ALWAYS |
52d493f0ac79
changed misleading TEXTUREFORMAT_32BPP (was 24bpp!) to vo_gl2 style TEXTUREFORMAT_ALWAYS
reimar
parents:
12749
diff
changeset
|
138 gl_texfmt = TEXTUREFORMAT_ALWAYS; |
12445
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 XSync(mDisplay, False); |
1 | 232 |
6953
ce67cc1f0beb
ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents:
6212
diff
changeset
|
233 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
|
234 | ButtonPressMask | ButtonReleaseMask | ExposureMask |
4658 | 235 ); |
1 | 236 |
237 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
|
238 while(texture_width<image_width || texture_width<image_height) texture_width*=2; |
1 | 239 texture_height=texture_width; |
240 | |
241 ImageData=malloc(texture_width*texture_height*image_bytes); | |
242 memset(ImageData,128,texture_width*texture_height*image_bytes); | |
243 | |
244 glDisable(GL_BLEND); | |
245 glDisable(GL_DEPTH_TEST); | |
246 glDepthMask(GL_FALSE); | |
247 glDisable(GL_CULL_FACE); | |
248 | |
249 glEnable(GL_TEXTURE_2D); | |
250 | |
11988 | 251 mp_msg(MSGT_VO, MSGL_V, "[gl] Creating %dx%d texture...\n",texture_width,texture_height); |
1 | 252 |
253 #if 1 | |
254 // glBindTexture(GL_TEXTURE_2D, texture_id); | |
255 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR); | |
256 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
|
257 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
|
258 gl_format, gl_type, ImageData); |
1 | 259 #endif |
12445
d97398ed403e
changes to get manyfmts nearer to working and fixed memory leak
reimar
parents:
12212
diff
changeset
|
260 |
d97398ed403e
changes to get manyfmts nearer to working and fixed memory leak
reimar
parents:
12212
diff
changeset
|
261 free (ImageData); |
1 | 262 |
263 resize(d_width,d_height); | |
264 | |
265 glClearColor( 1.0f,0.0f,1.0f,0.0f ); | |
266 glClear( GL_COLOR_BUFFER_BIT ); | |
267 | |
268 // printf("OpenGL setup OK!\n"); | |
269 | |
11542 | 270 if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop); |
271 | |
1 | 272 return 0; |
273 } | |
274 | |
31 | 275 static void check_events(void) |
1 | 276 { |
2041
ba8a225d1a18
now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents:
2040
diff
changeset
|
277 int e=vo_x11_check_events(mDisplay); |
31 | 278 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
|
279 if(e&VO_EVENT_EXPOSE && int_pause) flip_page(); |
31 | 280 } |
1 | 281 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1302
diff
changeset
|
282 static void draw_osd(void) |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1302
diff
changeset
|
283 { |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1302
diff
changeset
|
284 } |
31 | 285 |
286 static void | |
287 flip_page(void) | |
288 { | |
289 | |
1 | 290 // glEnable(GL_TEXTURE_2D); |
291 // glBindTexture(GL_TEXTURE_2D, texture_id); | |
292 | |
293 glColor3f(1,1,1); | |
294 glBegin(GL_QUADS); | |
295 glTexCoord2f(0,0);glVertex2i(0,0); | |
296 glTexCoord2f(0,1);glVertex2i(0,texture_height); | |
297 glTexCoord2f(1,1);glVertex2i(texture_width,texture_height); | |
298 glTexCoord2f(1,0);glVertex2i(texture_width,0); | |
299 glEnd(); | |
300 | |
301 // glFlush(); | |
302 glFinish(); | |
6095 | 303 glXSwapBuffers( mDisplay,vo_window ); |
304 | |
1 | 305 } |
306 | |
307 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num) | |
308 static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) | |
309 { | |
310 return 0; | |
311 } | |
312 | |
313 | |
10138
5e286cc6ad21
Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents:
8654
diff
changeset
|
314 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
|
315 draw_frame(uint8_t *src[]) |
1 | 316 { |
13237
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
317 unsigned int i; |
1 | 318 uint8_t *ImageData=src[0]; |
319 | |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
320 if (slice_height == 0) |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
321 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image_width, image_height, |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
322 gl_format, gl_type, ImageData); |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
323 else |
8654
2c4cebb8637d
- optional slice height for -vo gl (example: -vo gl:32)
arpi
parents:
8148
diff
changeset
|
324 for(i=0;i<image_height;i+=slice_height){ |
1 | 325 glTexSubImage2D( GL_TEXTURE_2D, // target |
326 0, // level | |
327 0, // x offset | |
328 // image_height-1-i, // y offset | |
329 i, // y offset | |
330 image_width, // width | |
8654
2c4cebb8637d
- optional slice height for -vo gl (example: -vo gl:32)
arpi
parents:
8148
diff
changeset
|
331 (i+slice_height<=image_height)?slice_height:image_height-i, // height |
12159 | 332 gl_format, |
333 gl_type, | |
1 | 334 ImageData+i*image_bytes*image_width ); // *pixels |
335 } | |
336 | |
337 return 0; | |
338 } | |
339 | |
340 static uint32_t | |
341 query_format(uint32_t format) | |
342 { | |
13206
6e8d1ac141fc
Using updated colorspace specifications from colorspaces.txt.
reimar
parents:
13188
diff
changeset
|
343 if ((format == IMGFMT_RGB24) || (format == IMGFMT_RGBA)) |
6212 | 344 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; |
12159 | 345 if (many_fmts && find_gl_format(format)) |
346 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW; | |
1 | 347 return 0; |
348 } | |
349 | |
350 | |
351 static void | |
352 uninit(void) | |
353 { | |
6095 | 354 if ( !vo_config_count ) return; |
355 vo_x11_uninit(); | |
1 | 356 } |
4352 | 357 |
358 static uint32_t preinit(const char *arg) | |
359 { | |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
360 int parse_err = 0; |
13237
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
361 unsigned int parse_pos = 0; |
12159 | 362 many_fmts = 0; |
363 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
|
364 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
|
365 { |
13237
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
366 while (arg[parse_pos] && !parse_err) { |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
367 if (strncmp (&arg[parse_pos], "manyfmts", 8) == 0) { |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
368 parse_pos += 8; |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
369 many_fmts = 1; |
13237
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
370 } else if (strncmp (&arg[parse_pos], "nomanyfmts", 10) == 0) { |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
371 parse_pos += 10; |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
372 many_fmts = 0; |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
373 } else if (strncmp (&arg[parse_pos], "slice-height=", 13) == 0) { |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
374 int val; |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
375 char *end; |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
376 parse_pos += 13; |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
377 val = strtol(&arg[parse_pos], &end, 0); |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
378 if (val < 0) parse_err = 1; |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
379 else { |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
380 slice_height = val; |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
381 parse_pos = end - arg; |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
382 } |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
383 } |
13237
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
384 if (arg[parse_pos] == ':') parse_pos++; |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
385 else if (arg[parse_pos]) parse_err = 1; |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
386 } |
8654
2c4cebb8637d
- optional slice height for -vo gl (example: -vo gl:32)
arpi
parents:
8148
diff
changeset
|
387 } |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
388 if (parse_err) { |
13237
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
389 unsigned int i; |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
390 mp_msg(MSGT_VO, MSGL_FATAL, "Could not parse arguments:\n%s\n", arg); |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
391 for (i = 0; i < parse_pos; i++) |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
392 mp_msg(MSGT_VO, MSGL_FATAL, " "); |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
393 mp_msg(MSGT_VO, MSGL_FATAL, "^\n"); |
f85c105bfeaa
improved suboption parsing, fixes also compiler warnings
reimar
parents:
13206
diff
changeset
|
394 mp_msg(MSGT_VO, MSGL_FATAL, |
12212
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
395 "\n-vo gl command line help:\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
396 "Example: mplayer -vo gl:slice-height=4\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
397 "\nOptions:\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
398 " manyfmts\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
399 " Enable extended color formats for OpenGL 1.2 and later\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
400 " slice-height=<0-...>\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
401 " Slice size for texture transfer, 0 for whole image\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
402 "\n" ); |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
403 return -1; |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
404 } |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
405 if (many_fmts) |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
406 mp_msg (MSGT_VO, MSGL_WARN, "[gl] using extended formats.\n" |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
407 "Make sure you have OpenGL >= 1.2 and used corresponding " |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
408 "headers for compiling!\n"); |
2e8b305586a0
fixed suboption parsing, added help for suboptions
reimar
parents:
12159
diff
changeset
|
409 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
|
410 "(0 means image height).\n", slice_height); |
7931 | 411 if( !vo_init() ) return -1; // Can't open X11 |
7777 | 412 |
4737
32e1f5042f65
I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents:
4658
diff
changeset
|
413 return 0; |
4352 | 414 } |
415 | |
4596 | 416 static uint32_t control(uint32_t request, void *data, ...) |
4352 | 417 { |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4448
diff
changeset
|
418 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
|
419 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
|
420 case VOCTRL_RESUME: return (int_pause=0); |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4448
diff
changeset
|
421 case VOCTRL_QUERY_FORMAT: |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4448
diff
changeset
|
422 return query_format(*((uint32_t*)data)); |
11542 | 423 case VOCTRL_ONTOP: |
424 vo_x11_ontop(); | |
425 return VO_TRUE; | |
6095 | 426 case VOCTRL_FULLSCREEN: |
427 vo_x11_fullscreen(); | |
428 return VO_TRUE; | |
4592
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4448
diff
changeset
|
429 } |
5fbfd8545c3b
query_ stuff replaced by new control() - patch by David Holm
arpi
parents:
4448
diff
changeset
|
430 return VO_NOTIMPL; |
4352 | 431 } |