annotate libvo/vo_gl.c @ 2060:0048c2a8cc95

alsa9 driver
author gabucino
date Wed, 03 Oct 2001 18:26:06 +0000
parents 378aed6b232d
children 48f0ac1e9d13
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 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9 * video_out_gl.c, X11/OpenGL interface
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 * based on video_out_x11 by Aaron Holtzman,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 * and WS opengl window manager by Pontscho/Fresh!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 #include <stdio.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 #include <stdlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 #include <string.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17 #include <math.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 #include "config.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 #include "video_out.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 #include "video_out_internal.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 LIBVO_EXTERN(gl)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 #include <X11/Xlib.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 #include <X11/Xutil.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 //#include <X11/keysym.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 #include <GL/glx.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
30 #include <errno.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 #include "yuv2rgb.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
33 #include <GL/gl.h>
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
35 #include "x11_common.h"
2057
378aed6b232d Use aspect()
atmos4
parents: 2041
diff changeset
36 #include "aspect.h"
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
37
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 static vo_info_t vo_info =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 "X11 (OpenGL)",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 "gl",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 "Arpad Gereoffy <arpi@esp-team.scene.hu>",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 ""
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 /* private prototypes */
1109
a013b2124f05 -Wall like fixes
al3x
parents: 614
diff changeset
47 // static void Display_Image (unsigned char *ImageData);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 /* local data */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50 static unsigned char *ImageData=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 /* X11 related variables */
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
53 //static Display *mydisplay;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 static Window mywindow;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 //static GC mygc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 //static XImage *myximage;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 //static int depth,mode;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
58 //static XWindowAttributes attribs;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 static int X_already_started = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60
1109
a013b2124f05 -Wall like fixes
al3x
parents: 614
diff changeset
61 //static int texture_id=1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 static GLXContext wsGLXContext;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 //XVisualInfo * wsVisualInfo;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
65 static int wsGLXAttrib[] = { GLX_RGBA,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 GLX_RED_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 GLX_GREEN_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 GLX_BLUE_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 // GLX_DEPTH_SIZE,16,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 GLX_DOUBLEBUFFER,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 None };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 static uint32_t image_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 static uint32_t image_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 static uint32_t image_format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 static uint32_t image_bpp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 static uint32_t image_bytes;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 static uint32_t texture_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 static uint32_t texture_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82
612
77e0094f0cce some warnings killed
szabii
parents: 384
diff changeset
83 static void resize(int x,int y){
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
84 printf("[gl] Resize: %dx%d\n",x,y);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85 glViewport( 0, 0, x, y );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 glMatrixMode(GL_PROJECTION);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 glLoadIdentity();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 glOrtho(0, image_width, image_height, 0, -1,1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 glMatrixMode(GL_MODELVIEW);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 glLoadIdentity();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 /* connect to server, create and map window,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 * allocate colors and (shared) memory
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 static uint32_t
2057
378aed6b232d Use aspect()
atmos4
parents: 2041
diff changeset
99 init(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
100 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
101 // int screen;
2040
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
102 int dwidth,dheight;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 unsigned int fg, bg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 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
105 // char *name = ":0.0";
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 XSizeHints hint;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107 XVisualInfo *vinfo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 XEvent xev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109
1109
a013b2124f05 -Wall like fixes
al3x
parents: 614
diff changeset
110 // XGCValues xgcv;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111 XSetWindowAttributes xswa;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 unsigned long xswamask;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 image_height = height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115 image_width = width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 image_format = format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 if (X_already_started) return -1;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
119 if(!vo_init()) return -1;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
121 X_already_started++;
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122
2040
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
123 dwidth=d_width; dheight=d_height;
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
124 #ifdef X11_FULLSCREEN
2057
378aed6b232d Use aspect()
atmos4
parents: 2041
diff changeset
125 if( flags&0x01 ){ // (-fs)
378aed6b232d Use aspect()
atmos4
parents: 2041
diff changeset
126 aspect(&d_width,&d_height,vo_screenwidth,vo_screenheight);
2040
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
127 dwidth=d_width; dheight=d_height;
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
128 }
bf7764f429c9 -fs fix
atmos4
parents: 1501
diff changeset
129 #endif
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
130 hint.x = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
131 hint.y = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
132 hint.width = d_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
133 hint.height = d_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
134 hint.flags = PPosition | PSize;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
135
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
136 /* Get some colors */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
137
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
138 bg = WhitePixel(mDisplay, mScreen);
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
139 fg = BlackPixel(mDisplay, mScreen);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
140
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
141 /* Make the window */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
142
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
143 // XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
145 // XMatchVisualInfo(mDisplay, screen, depth, TrueColor, &vinfo);
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
146 vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib );
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
147 if (vinfo == NULL)
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
148 {
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
149 printf("[gl] no GLX support present\n");
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
150 return -1;
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
151 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 xswa.background_pixel = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 xswa.border_pixel = 1;
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
155 // xswa.colormap = XCreateColormap(mDisplay, mRootWin, vinfo.visual, AllocNone);
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
156 xswa.colormap = XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157 xswamask = CWBackPixel | CWBorderPixel | CWColormap;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 // xswamask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWCursor | CWOverrideRedirect | CWSaveUnder | CWX | CWY | CWWidth | CWHeight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
160 mywindow = XCreateWindow(mDisplay, RootWindow(mDisplay,mScreen),
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 hint.x, hint.y, hint.width, hint.height, 4, vinfo->depth,CopyFromParent,vinfo->visual,xswamask,&xswa);
1137
4c7b219e126c patch: some X11 compliance fixed: set ClassHint and better fullscreen mode
arpi_esp
parents: 1109
diff changeset
162
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
163 vo_x11_classhint( mDisplay,mywindow,"gl" );
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
164 vo_hidecursor(mDisplay,mywindow);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
166 wsGLXContext=glXCreateContext( mDisplay,vinfo,NULL,True );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 // XStoreName( wsDisplay,wsMyWin,wsSysName );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 // printf("GLXcontext ok\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170
2057
378aed6b232d Use aspect()
atmos4
parents: 2041
diff changeset
171 if ( flags&0x01 ) vo_x11_decoration( mDisplay,mywindow,0 );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
173 XSelectInput(mDisplay, mywindow, StructureNotifyMask);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 /* Tell other applications about this window */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
177 XSetStandardProperties(mDisplay, mywindow, hello, hello, None, NULL, 0, &hint);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 /* Map window. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
181 XMapWindow(mDisplay, mywindow);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183 /* Wait for map. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 do
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
186 XNextEvent(mDisplay, &xev);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 while (xev.type != MapNotify || xev.xmap.event != mywindow);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
190 XSelectInput(mDisplay, mywindow, NoEventMask);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
192 glXMakeCurrent( mDisplay,mywindow,wsGLXContext );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
193
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
194 XFlush(mDisplay);
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
195 XSync(mDisplay, False);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
197 // mygc = XCreateGC(mDisplay, mywindow, 0L, &xgcv);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
199 // myximage = XGetImage(mDisplay, mywindow, 0, 0,
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200 // width, image_height, AllPlanes, ZPixmap);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 // ImageData = myximage->data;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202 // bpp = myximage->bits_per_pixel;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
204 //XSelectInput(mDisplay, mywindow, StructureNotifyMask); // !!!!
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
205 XSelectInput(mDisplay, mywindow, StructureNotifyMask | KeyPressMask );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 // printf("Window setup ok\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 #if 0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 // If we have blue in the lowest bit then obviously RGB
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211 mode = ((myximage->blue_mask & 0x01) != 0) ? MODE_RGB : MODE_BGR;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 #ifdef WORDS_BIGENDIAN
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213 if (myximage->byte_order != MSBFirst)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215 if (myximage->byte_order != LSBFirst)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 {
1302
2460ebcb6e69 Fixed a typo and wrong varname.
atmos4
parents: 1290
diff changeset
218 printf("[gl] no support for non-native XImage byte order!\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 printf("DEPTH=%d BPP=%d\n",depth,bpp);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 * If depth is 24 then it may either be a 3 or 4 byte per pixel
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 * format. We can't use bpp because then we would lose the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228 * distinction between 15/16bit depth (2 byte formate assumed).
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230 * FIXME - change yuv2rgb_init to take both depth and bpp
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 * parameters
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 texture_width=32;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 while(texture_width<image_width) texture_width*=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 while(texture_width<image_height) texture_width*=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 texture_height=texture_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 if(format==IMGFMT_YV12){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 yuv2rgb_init(8*BYTES_PP, MODE_BGR);
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
241 printf("[gl] YUV init OK!\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 image_bpp=8*BYTES_PP;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243 image_bytes=BYTES_PP;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 image_bpp=format&0xFF;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246 image_bytes=(image_bpp+7)/8;
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 ImageData=malloc(texture_width*texture_height*image_bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 memset(ImageData,128,texture_width*texture_height*image_bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 glDisable(GL_BLEND);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 glDisable(GL_DEPTH_TEST);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 glDepthMask(GL_FALSE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255 glDisable(GL_CULL_FACE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 glEnable(GL_TEXTURE_2D);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258
1290
af0b764f34c5 no segfault if no glx present
alex
parents: 1137
diff changeset
259 printf("[gl] Creating %dx%d texture...\n",texture_width,texture_height);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 #if 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 // glBindTexture(GL_TEXTURE_2D, texture_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 #ifdef TEXTUREFORMAT_32BPP
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture_width, texture_height, 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 glTexImage2D(GL_TEXTURE_2D, 0, BYTES_PP, texture_width, texture_height, 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270 (image_bytes==4)?GL_RGBA:GL_BGR, GL_UNSIGNED_BYTE, ImageData);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273 resize(d_width,d_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 glClearColor( 1.0f,0.0f,1.0f,0.0f );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 glClear( GL_COLOR_BUFFER_BIT );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278 // printf("OpenGL setup OK!\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
280 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
281
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 static const vo_info_t*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 get_info(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 return &vo_info;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 Terminate_Display_Process(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294 getchar(); /* wait for enter to remove window */
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
295 XDestroyWindow(mDisplay, mywindow);
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
296 XCloseDisplay(mDisplay);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297 X_already_started = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
300
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
301 static void check_events(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
303 int e=vo_x11_check_events(mDisplay);
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
304 if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
305 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
306
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
307 static void draw_osd(void)
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
308 {
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1302
diff changeset
309 }
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
310
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
311 static void
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
312 flip_page(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
313 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
314
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315 // glEnable(GL_TEXTURE_2D);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316 // glBindTexture(GL_TEXTURE_2D, texture_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318 glColor3f(1,1,1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 glBegin(GL_QUADS);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320 glTexCoord2f(0,0);glVertex2i(0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
321 glTexCoord2f(0,1);glVertex2i(0,texture_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
322 glTexCoord2f(1,1);glVertex2i(texture_width,texture_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 glTexCoord2f(1,0);glVertex2i(texture_width,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
324 glEnd();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
325
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
326 // glFlush();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327 glFinish();
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
328 glXSwapBuffers( mDisplay,mywindow );
1
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
332 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
333 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
334 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336 int dstride=w*BYTES_PP;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338 // dstride=(dstride+15)&(~15);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 yuv2rgb(ImageData, src[0], src[1], src[2],
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 w,h, dstride, stride[0],stride[1]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343 // emms ();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
344
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345 for(i=0;i<h;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
347 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
348 x, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349 y+i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350 w, // width
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351 1, // height
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 (BYTES_PP==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
354 ImageData+i*dstride ); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
357 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 static inline uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361 draw_frame_x11_yv12(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364 // printf("Converting YUV->RGB...\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365 yuv2rgb(ImageData, src[0], src[1], src[2],
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366 image_width, image_height,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367 image_width*BYTES_PP, image_width, image_width/2 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
368 // printf("Ready!\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
369
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370 // emms ();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
372 for(i=0;i<image_height;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
373 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375 0, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376 i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377 image_width, // width
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
378 1, // height
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
379 (BYTES_PP==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
380 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381 ImageData+i*BYTES_PP*image_width ); // *pixels
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 // Display_Image(ImageData);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389 static inline uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 draw_frame_x11_bgr(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 uint8_t *s=src[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 uint8_t *de=&ImageData[3*image_width];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396 for(i=0;i<image_height;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 uint8_t *d=ImageData;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398 while(d<de){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
399 d[0]=s[2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400 d[1]=s[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401 d[2]=s[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402 s+=3;d+=3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
405 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406 0, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
407 // image_height-1-i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
408 i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
409 image_width, // width
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410 1, // height
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 (image_bytes==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413 ImageData); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 // Display_Image(ImageData);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420 static inline uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 draw_frame_x11_rgb(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424 uint8_t *ImageData=src[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
425
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 for(i=0;i<image_height;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
428 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429 0, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430 // image_height-1-i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
431 i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
432 image_width, // width
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
433 1, // height
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
434 (image_bytes==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
435 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
436 ImageData+i*image_bytes*image_width ); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
437 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
438
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
439 // Display_Image(ImageData);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
440 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
441 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
442
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
443
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
444 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
445 draw_frame(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
446 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
447 if(image_format==IMGFMT_YV12)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
448 return draw_frame_x11_yv12(src);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
449 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
450 if((image_format&IMGFMT_RGB_MASK)==IMGFMT_RGB)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
451 return draw_frame_x11_rgb(src);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
452 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
453 return draw_frame_x11_bgr(src);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
454 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
455
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
456 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
457 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
458 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
459 switch(format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
460 case IMGFMT_YV12:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
461 case IMGFMT_RGB|24:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
462 case IMGFMT_BGR|24:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
463 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
464 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
465 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
466 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
467
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
468
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
469 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
470 uninit(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
471 {
2041
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
472 saver_on(mDisplay); // screen saver back on
ba8a225d1a18 now using x11_common stuff for X11 opening and w/h/bpp query
arpi
parents: 2040
diff changeset
473 XDestroyWindow( mDisplay,mywindow );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
474 }