Mercurial > mplayer.hg
comparison libvo/vo_gl.c @ 6095:891cff8aba60
some cleanup, gl/gl2 updated to use vo_window
author | arpi |
---|---|
date | Tue, 14 May 2002 23:44:35 +0000 |
parents | b8d8d72776f2 |
children | 2001affedb75 |
comparison
equal
deleted
inserted
replaced
6094:0f4dbbe57c08 | 6095:891cff8aba60 |
---|---|
50 /* local data */ | 50 /* local data */ |
51 static unsigned char *ImageData=NULL; | 51 static unsigned char *ImageData=NULL; |
52 | 52 |
53 /* X11 related variables */ | 53 /* X11 related variables */ |
54 //static Display *mydisplay; | 54 //static Display *mydisplay; |
55 static Window mywindow; | 55 //static Window vo_window; |
56 //static GC mygc; | 56 //static GC mygc; |
57 //static XImage *myximage; | 57 //static XImage *myximage; |
58 //static int depth,mode; | 58 //static int depth,mode; |
59 //static XWindowAttributes attribs; | 59 //static XWindowAttributes attribs; |
60 static int X_already_started = 0; | |
61 | |
62 //static int texture_id=1; | 60 //static int texture_id=1; |
63 | 61 |
64 static GLXContext wsGLXContext; | 62 static GLXContext wsGLXContext; |
65 //XVisualInfo * wsVisualInfo; | 63 //XVisualInfo * wsVisualInfo; |
66 static int wsGLXAttrib[] = { GLX_RGBA, | 64 static int wsGLXAttrib[] = { GLX_RGBA, |
113 | 111 |
114 image_height = height; | 112 image_height = height; |
115 image_width = width; | 113 image_width = width; |
116 image_format = format; | 114 image_format = format; |
117 | 115 |
118 if (X_already_started) return -1; | |
119 if(!vo_init()) return -1; | 116 if(!vo_init()) return -1; |
120 | 117 |
121 aspect_save_orig(width,height); | 118 aspect_save_orig(width,height); |
122 aspect_save_prescale(d_width,d_height); | 119 aspect_save_prescale(d_width,d_height); |
123 aspect_save_screenres(vo_screenwidth,vo_screenheight); | 120 aspect_save_screenres(vo_screenwidth,vo_screenheight); |
124 | 121 |
125 X_already_started++; | |
126 | |
127 aspect(&d_width,&d_height,A_NOZOOM); | 122 aspect(&d_width,&d_height,A_NOZOOM); |
128 #ifdef X11_FULLSCREEN | 123 #ifdef X11_FULLSCREEN |
129 if( flags&0x01 ){ // (-fs) | 124 // if( flags&0x01 ){ // (-fs) |
130 aspect(&d_width,&d_height,A_ZOOM); | 125 // aspect(&d_width,&d_height,A_ZOOM); |
131 } | 126 // } |
132 #endif | 127 #endif |
133 hint.x = 0; | 128 hint.x = 0; |
134 hint.y = 0; | 129 hint.y = 0; |
135 hint.width = d_width; | 130 hint.width = d_width; |
136 hint.height = d_height; | 131 hint.height = d_height; |
158 // xswa.colormap = XCreateColormap(mDisplay, mRootWin, vinfo.visual, AllocNone); | 153 // xswa.colormap = XCreateColormap(mDisplay, mRootWin, vinfo.visual, AllocNone); |
159 xswa.colormap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone); | 154 xswa.colormap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone); |
160 xswamask = CWBackPixel | CWBorderPixel | CWColormap; | 155 xswamask = CWBackPixel | CWBorderPixel | CWColormap; |
161 // xswamask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWCursor | CWOverrideRedirect | CWSaveUnder | CWX | CWY | CWWidth | CWHeight; | 156 // xswamask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWCursor | CWOverrideRedirect | CWSaveUnder | CWX | CWY | CWWidth | CWHeight; |
162 | 157 |
163 mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen), | 158 vo_window = XCreateWindow(mDisplay, mRootWin, |
164 hint.x, hint.y, hint.width, hint.height, 4, vinfo->depth,CopyFromParent,vinfo->visual,xswamask,&xswa); | 159 hint.x, hint.y, hint.width, hint.height, 4, vinfo->depth,CopyFromParent,vinfo->visual,xswamask,&xswa); |
165 | 160 |
166 vo_x11_classhint( mDisplay,mywindow,"gl" ); | 161 vo_x11_classhint( mDisplay,vo_window,"gl" ); |
167 vo_hidecursor(mDisplay,mywindow); | 162 vo_hidecursor(mDisplay,vo_window); |
168 | 163 |
169 wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True ); | 164 wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True ); |
170 // XStoreName( wsDisplay,wsMyWin,wsSysName ); | 165 // XStoreName( wsDisplay,wsMyWin,wsSysName ); |
171 | 166 |
172 // printf("GLXcontext ok\n"); | 167 // printf("GLXcontext ok\n"); |
173 | 168 |
174 if ( flags&0x01 ) vo_x11_decoration( mDisplay,mywindow,0 ); | 169 // if ( flags&0x01 ) vo_x11_decoration( mDisplay,vo_window,0 ); |
175 | 170 |
176 XSelectInput(mDisplay, mywindow, StructureNotifyMask); | 171 XSelectInput(mDisplay, vo_window, StructureNotifyMask); |
177 | 172 |
178 /* Tell other applications about this window */ | 173 /* Tell other applications about this window */ |
179 | 174 |
180 XSetStandardProperties(mDisplay, mywindow, hello, hello, None, NULL, 0, &hint); | 175 XSetStandardProperties(mDisplay, vo_window, hello, hello, None, NULL, 0, &hint); |
181 | 176 |
182 /* Map window. */ | 177 /* Map window. */ |
183 | 178 |
184 XMapWindow(mDisplay, mywindow); | 179 XMapWindow(mDisplay, vo_window); |
180 if ( flags&1 ) vo_x11_fullscreen(); | |
185 #ifdef HAVE_XINERAMA | 181 #ifdef HAVE_XINERAMA |
186 vo_x11_xinerama_move(mDisplay,mywindow); | 182 vo_x11_xinerama_move(mDisplay,vo_window); |
187 #endif | 183 #endif |
188 | 184 |
189 /* Wait for map. */ | 185 /* Wait for map. */ |
190 do | 186 do |
191 { | 187 { |
192 XNextEvent(mDisplay, &xev); | 188 XNextEvent(mDisplay, &xev); |
193 } | 189 } |
194 while (xev.type != MapNotify || xev.xmap.event != mywindow); | 190 while (xev.type != MapNotify || xev.xmap.event != vo_window); |
195 | 191 |
196 XSelectInput(mDisplay, mywindow, NoEventMask); | 192 XSelectInput(mDisplay, vo_window, NoEventMask); |
197 | 193 |
198 glXMakeCurrent( mDisplay,mywindow,wsGLXContext ); | 194 glXMakeCurrent( mDisplay,vo_window,wsGLXContext ); |
199 | 195 |
200 XFlush(mDisplay); | 196 XFlush(mDisplay); |
201 XSync(mDisplay, False); | 197 XSync(mDisplay, False); |
202 | 198 |
203 // mygc = XCreateGC(mDisplay, mywindow, 0L, &xgcv); | 199 // mygc = XCreateGC(mDisplay, vo_window, 0L, &xgcv); |
204 | 200 |
205 // myximage = XGetImage(mDisplay, mywindow, 0, 0, | 201 // myximage = XGetImage(mDisplay, vo_window, 0, 0, |
206 // width, image_height, AllPlanes, ZPixmap); | 202 // width, image_height, AllPlanes, ZPixmap); |
207 // ImageData = myximage->data; | 203 // ImageData = myximage->data; |
208 // bpp = myximage->bits_per_pixel; | 204 // bpp = myximage->bits_per_pixel; |
209 | 205 |
210 //XSelectInput(mDisplay, mywindow, StructureNotifyMask); // !!!! | 206 //XSelectInput(mDisplay, vo_window, StructureNotifyMask); // !!!! |
211 XSelectInput(mDisplay, mywindow, StructureNotifyMask | KeyPressMask | PointerMotionMask | 207 XSelectInput(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask |
212 #ifdef HAVE_NEW_INPUT | 208 #ifdef HAVE_NEW_INPUT |
213 | ButtonPressMask | ButtonReleaseMask | 209 | ButtonPressMask | ButtonReleaseMask |
214 #endif | 210 #endif |
215 ); | 211 ); |
216 | 212 |
323 glTexCoord2f(1,0);glVertex2i(texture_width,0); | 319 glTexCoord2f(1,0);glVertex2i(texture_width,0); |
324 glEnd(); | 320 glEnd(); |
325 | 321 |
326 // glFlush(); | 322 // glFlush(); |
327 glFinish(); | 323 glFinish(); |
328 glXSwapBuffers( mDisplay,mywindow ); | 324 glXSwapBuffers( mDisplay,vo_window ); |
329 | 325 |
330 } | 326 } |
331 | 327 |
332 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num) | 328 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num) |
333 static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) | 329 static uint32_t draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) |
334 { | 330 { |
467 | 463 |
468 | 464 |
469 static void | 465 static void |
470 uninit(void) | 466 uninit(void) |
471 { | 467 { |
468 if ( !vo_config_count ) return; | |
472 saver_on(mDisplay); // screen saver back on | 469 saver_on(mDisplay); // screen saver back on |
473 | 470 vo_x11_uninit(); |
474 vo_x11_uninit(mDisplay, mywindow); | |
475 } | 471 } |
476 | 472 |
477 static uint32_t preinit(const char *arg) | 473 static uint32_t preinit(const char *arg) |
478 { | 474 { |
479 if(arg) | 475 if(arg) |
487 static uint32_t control(uint32_t request, void *data, ...) | 483 static uint32_t control(uint32_t request, void *data, ...) |
488 { | 484 { |
489 switch (request) { | 485 switch (request) { |
490 case VOCTRL_QUERY_FORMAT: | 486 case VOCTRL_QUERY_FORMAT: |
491 return query_format(*((uint32_t*)data)); | 487 return query_format(*((uint32_t*)data)); |
488 case VOCTRL_FULLSCREEN: | |
489 vo_x11_fullscreen(); | |
490 return VO_TRUE; | |
492 } | 491 } |
493 return VO_NOTIMPL; | 492 return VO_NOTIMPL; |
494 } | 493 } |