annotate libvo/vo_gl.c @ 10672:011339e153fd

sync
author gabucino
date Wed, 20 Aug 2003 08:58:51 +0000
parents 5e286cc6ad21
children 3aea64e0d6d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 #define TEXTUREFORMAT_32BPP
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
8
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 #include <X11/Xlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 #include <X11/Xutil.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 //#include <X11/keysym.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #include <GL/glx.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #include <errno.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 #include <GL/gl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
21 #include "x11_common.h"
2057
378aed6b232d Use aspect()
atmos4
parents: 2041
diff changeset
22 #include "aspect.h"
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
23
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7931
diff changeset
24 static vo_info_t info =
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 "X11 (OpenGL)",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 "gl",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 "Arpad Gereoffy <arpi@esp-team.scene.hu>",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 ""
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31
8148
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7931
diff changeset
32 LIBVO_EXTERN(gl)
5b39e79af5fe removed get_info, using the same sheme as in libmpcodecs instead
alex
parents: 7931
diff changeset
33
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34 /* local data */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35 static unsigned char *ImageData=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 static GLXContext wsGLXContext;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
38 static int wsGLXAttrib[] = { GLX_RGBA,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 GLX_RED_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 GLX_GREEN_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 GLX_BLUE_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 GLX_DOUBLEBUFFER,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 None };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 static uint32_t image_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 static uint32_t image_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 static uint32_t image_bytes;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 static uint32_t texture_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 static uint32_t texture_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
53 static int slice_height=1;
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
54
612
77e0094f0cce some warnings killed
szabii
parents: 384
diff changeset
55 static void resize(int x,int y){
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
56 printf("[gl] Resize: %dx%d\n",x,y);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 glViewport( 0, 0, x, y );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 glMatrixMode(GL_PROJECTION);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 glLoadIdentity();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 glOrtho(0, image_width, image_height, 0, -1,1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 glMatrixMode(GL_MODELVIEW);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 glLoadIdentity();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 /* connect to server, create and map window,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 * allocate colors and (shared) memory
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 static uint32_t
7124
eca7dbad0166 finally removed query_vaa, bes_da and vo_tune_info - the obsoleted libvo api
alex
parents: 7111
diff changeset
71 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
72 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
73 // int screen;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 unsigned int fg, bg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 XSizeHints hint;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 XVisualInfo *vinfo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 XEvent xev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78
1109
a013b2124f05 -Wall like fixes
al3x
parents: 614
diff changeset
79 // XGCValues xgcv;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 XSetWindowAttributes xswa;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 unsigned long xswamask;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 image_height = height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 image_width = width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85
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
86 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
87 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
88 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
89
48f0ac1e9d13 Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
atmos4
parents: 2057
diff changeset
90 aspect(&d_width,&d_height,A_NOZOOM);
2040
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
91 #ifdef X11_FULLSCREEN
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
92 // if( flags&0x01 ){ // (-fs)
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
93 // aspect(&d_width,&d_height,A_ZOOM);
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
94 // }
2040
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
95 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 hint.x = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 hint.y = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 hint.width = d_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 hint.height = d_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 hint.flags = PPosition | PSize;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 /* Get some colors */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
104 bg = WhitePixel(mDisplay, mScreen);
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
105 fg = BlackPixel(mDisplay, mScreen);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 /* Make the window */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
109 vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib );
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
110 if (vinfo == NULL)
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
111 {
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
112 printf("[gl] no GLX support present\n");
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
113 return -1;
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
114 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 xswa.background_pixel = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117 xswa.border_pixel = 1;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
118 xswa.colormap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119 xswamask = CWBackPixel | CWBorderPixel | CWColormap;
1137
4c7b219e126c patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents: 1109
diff changeset
120
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
121 if ( vo_window == None )
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
122 {
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
123 vo_window = XCreateWindow(mDisplay, mRootWin,
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
124 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
125
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
126 vo_x11_classhint( mDisplay,vo_window,"gl" );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
127 vo_hidecursor(mDisplay,vo_window);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
129 // if ( flags&0x01 ) vo_x11_decoration( mDisplay,vo_window,0 );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
130 XSelectInput(mDisplay, vo_window, StructureNotifyMask);
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
131 /* 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
132 XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint);
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
133 /* Map window. */
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
134 XMapWindow(mDisplay, vo_window);
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
135 if ( flags&1 ) vo_x11_fullscreen();
4017
21a75ab24703 Xinerama patch number two by attila.
atmos4
parents: 2732
diff changeset
136 #ifdef HAVE_XINERAMA
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
137 vo_x11_xinerama_move(mDisplay,vo_window);
4017
21a75ab24703 Xinerama patch number two by attila.
atmos4
parents: 2732
diff changeset
138 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
140 /* Wait for map. */
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
141 do
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
142 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
143 XNextEvent(mDisplay, &xev);
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
144 }
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
145 while (xev.type != MapNotify || xev.xmap.event != vo_window);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
147 XSelectInput(mDisplay, vo_window, NoEventMask);
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
148 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
150 if ( vo_config_count ) glXDestroyContext( mDisplay,wsGLXContext );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
151 wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True );
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
152 glXMakeCurrent( mDisplay,vo_window,wsGLXContext );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
154 XFlush(mDisplay);
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
155 XSync(mDisplay, False);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156
6953
ce67cc1f0beb ignore BadAccess error at XSelectInput() (grabbing mouse etc) with warning
arpi
parents: 6212
diff changeset
157 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
158 | ButtonPressMask | ButtonReleaseMask
93d562ad1c22 Added new input mouse support in x11 vo
albeu
parents: 4596
diff changeset
159 );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 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
162 while(texture_width<image_width || texture_width<image_height) texture_width*=2;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 texture_height=texture_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164
10138
5e286cc6ad21 Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents: 8654
diff changeset
165 image_bytes=(IMGFMT_RGB_DEPTH(format)+7)/8;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
167 if ( ImageData ) free( ImageData );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 ImageData=malloc(texture_width*texture_height*image_bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 memset(ImageData,128,texture_width*texture_height*image_bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 glDisable(GL_BLEND);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 glDisable(GL_DEPTH_TEST);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173 glDepthMask(GL_FALSE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 glDisable(GL_CULL_FACE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176 glEnable(GL_TEXTURE_2D);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
178 printf("[gl] Creating %dx%d texture...\n",texture_width,texture_height);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 #if 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 // glBindTexture(GL_TEXTURE_2D, texture_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 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
184 /* 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
185 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
186 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
187 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
188 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
189 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
190 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
191 */
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192 #ifdef TEXTUREFORMAT_32BPP
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture_width, texture_height, 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194 #else
10138
5e286cc6ad21 Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents: 8654
diff changeset
195 glTexImage2D(GL_TEXTURE_2D, 0, image_bytes, texture_width, texture_height, 0,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 (image_bytes==4)?GL_RGBA:GL_BGR, GL_UNSIGNED_BYTE, ImageData);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 resize(d_width,d_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 glClearColor( 1.0f,0.0f,1.0f,0.0f );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 glClear( GL_COLOR_BUFFER_BIT );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 // printf("OpenGL setup OK!\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
207 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
208
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
212 static void check_events(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
214 int e=vo_x11_check_events(mDisplay);
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
215 if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
216 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
218 static void draw_osd(void)
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
219 {
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
220 }
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
221
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
222 static void
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
223 flip_page(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
224 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
225
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 // glEnable(GL_TEXTURE_2D);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 // glBindTexture(GL_TEXTURE_2D, texture_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 glColor3f(1,1,1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 glBegin(GL_QUADS);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 glTexCoord2f(0,0);glVertex2i(0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 glTexCoord2f(0,1);glVertex2i(0,texture_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 glTexCoord2f(1,1);glVertex2i(texture_width,texture_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 glTexCoord2f(1,0);glVertex2i(texture_width,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 glEnd();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 // glFlush();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 glFinish();
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
239 glXSwapBuffers( mDisplay,vo_window );
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
240
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 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
245 {
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249
10138
5e286cc6ad21 Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents: 8654
diff changeset
250 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
251 draw_frame(uint8_t *src[])
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 uint8_t *ImageData=src[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
256 for(i=0;i<image_height;i+=slice_height){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 0, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260 // image_height-1-i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 image_width, // width
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
263 (i+slice_height<=image_height)?slice_height:image_height-i, // height
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 (image_bytes==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 ImageData+i*image_bytes*image_width ); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 {
10138
5e286cc6ad21 Removed YUV (YV12) and BGR support, leaving the native RGB support. Also cleaned some other parts.
alex
parents: 8654
diff changeset
275 if ((format == IMGFMT_RGB24) || (format == IMGFMT_RGB32))
6212
2001affedb75 query_format revised
alex
parents: 6095
diff changeset
276 return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 return 0;
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282 uninit(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 {
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
284 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
285 saver_on(mDisplay); // screen saver back on
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
286 vo_x11_uninit();
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 }
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
288
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
289 static uint32_t preinit(const char *arg)
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
290 {
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4658
diff changeset
291 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
292 {
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
293 slice_height = atoi(arg);
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
294 if (slice_height <= 0)
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
295 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
296 }
8654
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
297 else
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
298 {
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
299 slice_height = 4;
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
300 }
2c4cebb8637d - optional slice height for -vo gl (example: -vo gl:32)
arpi
parents: 8148
diff changeset
301 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
302
7931
48c71b6c7389 vo_init() moved to/fixed in preinit()
arpi
parents: 7777
diff changeset
303 if( !vo_init() ) return -1; // Can't open X11
7777
ed7b05575aab -fixed-vo support
pontscho
parents: 7124
diff changeset
304
4737
32e1f5042f65 I don't like such reports: '-vo dga:vidix or -vo x11:vidix works fine for me'
nick
parents: 4658
diff changeset
305 return 0;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
306 }
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
307
4596
c35d7ce151b3 10000hl to Holm... control MUST BE static...
arpi
parents: 4592
diff changeset
308 static uint32_t control(uint32_t request, void *data, ...)
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
309 {
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
310 switch (request) {
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
311 case VOCTRL_QUERY_FORMAT:
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
312 return query_format(*((uint32_t*)data));
6095
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
313 case VOCTRL_FULLSCREEN:
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
314 vo_x11_fullscreen();
891cff8aba60 some cleanup, gl/gl2 updated to use vo_window
arpi
parents: 5651
diff changeset
315 return VO_TRUE;
4592
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
316 }
5fbfd8545c3b query_ stuff replaced by new control() - patch by David Holm
arpi
parents: 4448
diff changeset
317 return VO_NOTIMPL;
4352
ed5b85b713a3 Extensions for video accelerated architecture
nick
parents: 4017
diff changeset
318 }