annotate libvo/vo_gl.c @ 8866:f84a5237f914

Remember window layer befor changing it. Works on icemw and fvwm, but not on windowmaker (bug in wmaker...).
author filon
date Thu, 09 Jan 2003 21:23:54 +0000
parents 2c4cebb8637d
children 5e286cc6ad21
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 #define DISP
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 // this can be 3 or 4 (regarding 24bpp and 32bpp)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 #define BYTES_PP 3
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6 #define TEXTUREFORMAT_32BPP
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
7
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 #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
12 #include <errno.h>
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 #include <X11/Xlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 #include <X11/Xutil.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 //#include <X11/keysym.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 #include <GL/glx.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 #include <errno.h>
2732
ae79207a3055 Move yuv2rgb to postprocess
nick
parents: 2249
diff changeset
23 #include "../postproc/rgb2rgb.h"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 #include <GL/gl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
27 #include "x11_common.h"
2057
378aed6b232d Use aspect()
atmos4
parents: 2041
diff changeset
28 #include "aspect.h"
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
29
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7931
diff changeset
30 static vo_info_t info =
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 "X11 (OpenGL)",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 "gl",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 "Arpad Gereoffy <arpi@esp-team.scene.hu>",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 ""
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7931
diff changeset
38 LIBVO_EXTERN(gl)
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7931
diff changeset
39
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 /* local data */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 static unsigned char *ImageData=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 static GLXContext wsGLXContext;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
44 static int wsGLXAttrib[] = { GLX_RGBA,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 GLX_RED_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 GLX_GREEN_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 GLX_BLUE_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 GLX_DOUBLEBUFFER,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 None };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 static uint32_t image_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 static uint32_t image_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 static uint32_t image_format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 static uint32_t image_bpp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 static uint32_t image_bytes;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 static uint32_t texture_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 static uint32_t texture_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
61 static int slice_height=1;
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
62
612
77e0094f0cce some warnings killed
szabii
parents: 384
diff changeset
63 static void resize(int x,int y){
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
64 printf("[gl] Resize: %dx%d\n",x,y);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 glViewport( 0, 0, x, y );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 glMatrixMode(GL_PROJECTION);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 glLoadIdentity();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 glOrtho(0, image_width, image_height, 0, -1,1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 glMatrixMode(GL_MODELVIEW);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 glLoadIdentity();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 /* connect to server, create and map window,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 * allocate colors and (shared) memory
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 static uint32_t
7124
eca7dbad0166 finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents: 7111
diff changeset
79 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
80 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
81 // int screen;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 unsigned int fg, bg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 char *hello = (title == NULL) ? "OpenGL rulez" : title;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
84 // char *name = ":0.0";
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 XSizeHints hint;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 XVisualInfo *vinfo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 XEvent xev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88
1109
a013b2124f05 -Wall like fixes
al3x
parents: 614
diff changeset
89 // XGCValues xgcv;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 XSetWindowAttributes xswa;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 unsigned long xswamask;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 image_height = height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 image_width = width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 image_format = format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96
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
97 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
98 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
99 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
100
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2057
diff changeset
101 aspect(&d_width,&d_height,A_NOZOOM);
2040
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
102 #ifdef X11_FULLSCREEN
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
103 // if( flags&0x01 ){ // (-fs)
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
104 // aspect(&d_width,&d_height,A_ZOOM);
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
105 // }
2040
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
106 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 hint.x = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 hint.y = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 hint.width = d_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 hint.height = d_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 hint.flags = PPosition | PSize;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 /* Get some colors */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
115 bg = WhitePixel(mDisplay, mScreen);
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
116 fg = BlackPixel(mDisplay, mScreen);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 /* Make the window */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
120 vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib );
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
121 if (vinfo == NULL)
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
122 {
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
123 printf("[gl] no GLX support present\n");
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
124 return -1;
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
125 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127 xswa.background_pixel = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 xswa.border_pixel = 1;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
129 xswa.colormap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 xswamask = CWBackPixel | CWBorderPixel | CWColormap;
1137
4c7b219e126c patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents: 1109
diff changeset
131
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
132 if ( vo_window == None )
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
133 {
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
134 vo_window = XCreateWindow(mDisplay, mRootWin,
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
135 hint.x, hint.y, hint.width, hint.height, 4, vinfo->depth,CopyFromParent,vinfo->visual,xswamask,&xswa);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
137 vo_x11_classhint( mDisplay,vo_window,"gl" );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
138 vo_hidecursor(mDisplay,vo_window);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
140 // if ( flags&0x01 ) vo_x11_decoration( mDisplay,vo_window,0 );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
141 XSelectInput(mDisplay, vo_window, StructureNotifyMask);
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
142 /* Tell other applications about this window */
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
143 XSetStandardProperties(mDisplay, vo_window, hello, hello, None, NULL, 0, &hint);
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
144 /* Map window. */
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
145 XMapWindow(mDisplay, vo_window);
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
146 if ( flags&1 ) vo_x11_fullscreen();
4017
21a75ab24703 Xinerama patch number two by attila.
atmos4
parents: 2732
diff changeset
147 #ifdef HAVE_XINERAMA
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
148 vo_x11_xinerama_move(mDisplay,vo_window);
4017
21a75ab24703 Xinerama patch number two by attila.
atmos4
parents: 2732
diff changeset
149 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
151 /* Wait for map. */
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
152 do
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
153 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
154 XNextEvent(mDisplay, &xev);
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
155 }
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
156 while (xev.type != MapNotify || xev.xmap.event != vo_window);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
158 XSelectInput(mDisplay, vo_window, NoEventMask);
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
159 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
161 if ( vo_config_count ) glXDestroyContext( mDisplay,wsGLXContext );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
162 wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
163 glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
165 XFlush(mDisplay);
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
166 XSync(mDisplay, False);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167
6953
ce67cc1f0beb ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents: 6212
diff changeset
168 vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask
4658
93d562ad1c22 Added new input mouse support in x11 vo
albeu
parents: 4596
diff changeset
169 | ButtonPressMask | ButtonReleaseMask
93d562ad1c22 Added new input mouse support in x11 vo
albeu
parents: 4596
diff changeset
170 );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 #if 0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 // If we have blue in the lowest bit then obviously RGB
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 mode = ((myximage->blue_mask & 0x01) != 0) ? MODE_RGB : MODE_BGR;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 #ifdef WORDS_BIGENDIAN
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 if (myximage->byte_order != MSBFirst)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 if (myximage->byte_order != LSBFirst)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 {
1302
2460ebcb6e69 Fixed a typo and wrong varname.
atmos4
parents: 1290
diff changeset
181 printf("[gl] no support for non-native XImage byte order!\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 printf("DEPTH=%d BPP=%d\n",depth,bpp);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
186 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 * If depth is 24 then it may either be a 3 or 4 byte per pixel
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190 * format. We can't use bpp because then we would lose the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 * distinction between 15/16bit depth (2 byte formate assumed).
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 * FIXME - change yuv2rgb_init to take both depth and bpp
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 * parameters
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 texture_width=32;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 while(texture_width<image_width) texture_width*=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 while(texture_width<image_height) texture_width*=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 texture_height=texture_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 if(format==IMGFMT_YV12){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 yuv2rgb_init(8*BYTES_PP, MODE_BGR);
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
204 printf("[gl] YUV init OK!\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 image_bpp=8*BYTES_PP;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 image_bytes=BYTES_PP;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 image_bpp=format&0xFF;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 image_bytes=(image_bpp+7)/8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
212 if ( ImageData ) free( ImageData );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 ImageData=malloc(texture_width*texture_height*image_bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 memset(ImageData,128,texture_width*texture_height*image_bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 glDisable(GL_BLEND);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 glDisable(GL_DEPTH_TEST);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218 glDepthMask(GL_FALSE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 glDisable(GL_CULL_FACE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 glEnable(GL_TEXTURE_2D);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
223 printf("[gl] Creating %dx%d texture...\n",texture_width,texture_height);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 #if 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 // glBindTexture(GL_TEXTURE_2D, texture_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 #ifdef TEXTUREFORMAT_32BPP
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture_width, texture_height, 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 glTexImage2D(GL_TEXTURE_2D, 0, BYTES_PP, texture_width, texture_height, 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 (image_bytes==4)?GL_RGBA:GL_BGR, GL_UNSIGNED_BYTE, ImageData);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 resize(d_width,d_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 glClearColor( 1.0f,0.0f,1.0f,0.0f );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 glClear( GL_COLOR_BUFFER_BIT );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 // printf("OpenGL setup OK!\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
244 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
245
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
249 static void check_events(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
251 int e=vo_x11_check_events(mDisplay);
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
252 if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
253 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
255 static void draw_osd(void)
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
256 {
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
257 }
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
258
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
259 static void
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
260 flip_page(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
261 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
262
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263 // glEnable(GL_TEXTURE_2D);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 // glBindTexture(GL_TEXTURE_2D, texture_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 glColor3f(1,1,1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 glBegin(GL_QUADS);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 glTexCoord2f(0,0);glVertex2i(0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 glTexCoord2f(0,1);glVertex2i(0,texture_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 glTexCoord2f(1,1);glVertex2i(texture_width,texture_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 glTexCoord2f(1,0);glVertex2i(texture_width,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 glEnd();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 // glFlush();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 glFinish();
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
276 glXSwapBuffers( mDisplay,vo_window );
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
277
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281 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
282 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284 int dstride=w*BYTES_PP;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 // dstride=(dstride+15)&(~15);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 yuv2rgb(ImageData, src[0], src[1], src[2],
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 w,h, dstride, stride[0],stride[1]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
291 for(i=0;i<h;i+=slice_height){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294 x, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 y+i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296 w, // width
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
297 (i+slice_height<=h)?slice_height:h-i, // height
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298 (BYTES_PP==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 ImageData+i*dstride ); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
303 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
304 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
305
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
306 static inline uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
307 draw_frame_x11_yv12(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 // printf("Converting YUV->RGB...\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
311 yuv2rgb(ImageData, src[0], src[1], src[2],
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
312 image_width, image_height,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313 image_width*BYTES_PP, image_width, image_width/2 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
315 for(i=0;i<image_height;i+=slice_height){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318 0, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320 image_width, // width
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
321 (i+slice_height<=image_height)?slice_height:image_height-i, // height
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322 (BYTES_PP==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
324 ImageData+i*BYTES_PP*image_width ); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
325 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
328 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
329
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
330
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
331 static inline uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 draw_frame_x11_bgr(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 uint8_t *s=src[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
337 for(i=0;i<image_height;i+=slice_height){
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
338 int h=(i+slice_height<=image_height)?slice_height:image_height-i;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339 uint8_t *d=ImageData;
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
340 uint8_t *de=&ImageData[3*image_width*h];
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 while(d<de){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342 d[0]=s[2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343 d[1]=s[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
344 d[2]=s[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345 s+=3;d+=3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
347 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
348 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349 0, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350 // image_height-1-i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351 i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 image_width, // width
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
353 h, // height
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354 (image_bytes==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356 ImageData); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
357 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362 static inline uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363 draw_frame_x11_rgb(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366 uint8_t *ImageData=src[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
368 for(i=0;i<image_height;i+=slice_height){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
369 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371 0, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
372 // image_height-1-i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
373 i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374 image_width, // width
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
375 (i+slice_height<=image_height)?slice_height:image_height-i, // height
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376 (image_bytes==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
378 ImageData+i*image_bytes*image_width ); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
379 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
380
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
383
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 draw_frame(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388 if(image_format==IMGFMT_YV12)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389 return draw_frame_x11_yv12(src);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 if((image_format&IMGFMT_RGB_MASK)==IMGFMT_RGB)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 return draw_frame_x11_rgb(src);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 return draw_frame_x11_bgr(src);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
399 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400 switch(format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401 case IMGFMT_YV12:
6212
2001affedb75 query_format revised
alex
parents: 6095
diff changeset
402 return VFCAP_CSP_SUPPORTED;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403 case IMGFMT_RGB|24:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 case IMGFMT_BGR|24:
6212
2001affedb75 query_format revised
alex
parents: 6095
diff changeset
405 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
407 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
408 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
409
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 uninit(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413 {
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
414 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
415 saver_on(mDisplay); // screen saver back on
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
416 vo_x11_uninit();
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 }
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
418
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
419 static uint32_t preinit(const char *arg)
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
420 {
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4658
diff changeset
421 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
422 {
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
423 slice_height = atoi(arg);
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
424 if (slice_height <= 0)
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
425 slice_height = 65536;
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4658
diff changeset
426 }
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
427 else
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
428 {
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
429 slice_height = 4;
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
430 }
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
431 printf("[vo_gl] Using %d as slice_height (0 means image_height).\n", slice_height);
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
432
7931
48c71b6c7389 vo_init() moved to/fixed in preinit()
arpi
parents: 7777
diff changeset
433 if( !vo_init() ) return -1; // Can't open X11
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
434
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4658
diff changeset
435 return 0;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
436 }
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
437
4596
c35d7ce151b3 10000hl to Holm... control MUST BE static...
arpi
parents: 4592
diff changeset
438 static uint32_t control(uint32_t request, void *data, ...)
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
439 {
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
440 switch (request) {
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
441 case VOCTRL_QUERY_FORMAT:
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
442 return query_format(*((uint32_t*)data));
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
443 case VOCTRL_FULLSCREEN:
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
444 vo_x11_fullscreen();
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
445 return VO_TRUE;
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
446 }
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
447 return VO_NOTIMPL;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
448 }