annotate libvo/vo_gl.c @ 1015:9744b50fe87f

some cleanup, old unused stuff removed
author arpi_esp
date Tue, 05 Jun 2001 01:14:38 +0000
parents f83ec60bce49
children a013b2124f05
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"
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
36
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 static vo_info_t vo_info =
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 "X11 (OpenGL)",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 "gl",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 "Arpad Gereoffy <arpi@esp-team.scene.hu>",
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 ""
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 /* private prototypes */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46 static void Display_Image (unsigned char *ImageData);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48 /* local data */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 static unsigned char *ImageData=NULL;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
51 /* X11 related variables */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 static Display *mydisplay;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 static Window mywindow;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 //static GC mygc;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 //static XImage *myximage;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 //static int depth,mode;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 static XWindowAttributes attribs;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 static int X_already_started = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 static int texture_id=1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 static GLXContext wsGLXContext;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 //XVisualInfo * wsVisualInfo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 int wsGLXAttrib[] = { GLX_RGBA,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 GLX_RED_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 GLX_GREEN_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 GLX_BLUE_SIZE,1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 // GLX_DEPTH_SIZE,16,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 GLX_DOUBLEBUFFER,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 None };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 static uint32_t image_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 static uint32_t image_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 static uint32_t image_format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 static uint32_t image_bpp;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 static uint32_t image_bytes;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 static uint32_t texture_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 static uint32_t texture_height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81
612
77e0094f0cce some warnings killed
szabii
parents: 384
diff changeset
82 static void resize(int x,int y){
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 printf("Resize: %dx%d\n",x,y);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 glViewport( 0, 0, x, y );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 glMatrixMode(GL_PROJECTION);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 glLoadIdentity();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 glOrtho(0, image_width, image_height, 0, -1,1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 glMatrixMode(GL_MODELVIEW);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 glLoadIdentity();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 /* connect to server, create and map window,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 * allocate colors and (shared) memory
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
98 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
99 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
100 int screen;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
101 unsigned int fg, bg;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
102 char *hello = (title == NULL) ? "OpenGL rulez" : title;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
103 char *name = ":0.0";
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
104 XSizeHints hint;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
105 XVisualInfo *vinfo;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
106 XEvent xev;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
107
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
108 XGCValues xgcv;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
109 XSetWindowAttributes xswa;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
110 unsigned long xswamask;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
111
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
112 image_height = height;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
113 image_width = width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
114 image_format = format;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
115
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
116 if (X_already_started) return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
117
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
118 if(getenv("DISPLAY")) name = getenv("DISPLAY");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
119
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
120 mydisplay = XOpenDisplay(name);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
121
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
122 if (mydisplay == NULL)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
123 {
614
f83ec60bce49 fprintf(stderr converted to printf(
szabii
parents: 612
diff changeset
124 printf("Can not open display\n");
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
125 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
126 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
127
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
128 screen = DefaultScreen(mydisplay);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
129
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
138 bg = WhitePixel(mydisplay, screen);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
139 fg = BlackPixel(mydisplay, screen);
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
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
143 XGetWindowAttributes(mydisplay, DefaultRootWindow(mydisplay), &attribs);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
144
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
145 #if 0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
146 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
147 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
148 * depth in X11 terminology land is the number of bits used to
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
149 * actually represent the colour.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
150 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
151 * bpp in X11 land means how many bits in the frame buffer per
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
152 * pixel.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
153 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
154 * ex. 15 bit color is 15 bit depth and 16 bpp. Also 24 bit
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
155 * color is 24 bit depth, but can be 24 bpp or 32 bpp.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
156 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
157
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
158 depth = attribs.depth;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
159
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
160 if (depth != 15 && depth != 16 && depth != 24 && depth != 32)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
161 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
162 /* The root window may be 8bit but there might still be
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
163 * visuals with other bit depths. For example this is the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
164 * case on Sun/Solaris machines.
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
165 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
166 depth = 24;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
167 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
168 //BEGIN HACK
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
169 //mywindow = XCreateSimpleWindow(mydisplay, DefaultRootWindow(mydisplay),
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
170 //hint.x, hint.y, hint.width, hint.height, 4, fg, bg);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
171 //
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
172 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
173
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
174 // XMatchVisualInfo(mydisplay, screen, depth, TrueColor, &vinfo);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
175 vinfo=glXChooseVisual( mydisplay,screen,wsGLXAttrib );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
176
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
177 xswa.background_pixel = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
178 xswa.border_pixel = 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
179 // xswa.colormap = XCreateColormap(mydisplay, RootWindow(mydisplay,screen), vinfo.visual, AllocNone);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
180 xswa.colormap = XCreateColormap(mydisplay, RootWindow(mydisplay,screen), vinfo->visual, AllocNone);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
181 xswamask = CWBackPixel | CWBorderPixel | CWColormap;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
182 // xswamask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWCursor | CWOverrideRedirect | CWSaveUnder | CWX | CWY | CWWidth | CWHeight;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
183
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
184 mywindow = XCreateWindow(mydisplay, RootWindow(mydisplay,screen),
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
185 hint.x, hint.y, hint.width, hint.height, 4, vinfo->depth,CopyFromParent,vinfo->visual,xswamask,&xswa);
384
b0e4e5744899 Autohide X11 cursor
lgb
parents: 31
diff changeset
186 vo_hidecursor(mydisplay,mywindow);
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
187
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
188 wsGLXContext=glXCreateContext( mydisplay,vinfo,NULL,True );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
189 // XStoreName( wsDisplay,wsMyWin,wsSysName );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
190
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
191 // printf("GLXcontext ok\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
192
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
193 if ( fullscreen ) vo_x11_decoration( mydisplay,mywindow,0 );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
194
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
195 XSelectInput(mydisplay, mywindow, StructureNotifyMask);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
196
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
197 /* Tell other applications about this window */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
198
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
199 XSetStandardProperties(mydisplay, mywindow, hello, hello, None, NULL, 0, &hint);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
200
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
201 /* Map window. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
202
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
203 XMapWindow(mydisplay, mywindow);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
204
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
205 /* Wait for map. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
206 do
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
207 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
208 XNextEvent(mydisplay, &xev);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
209 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
210 while (xev.type != MapNotify || xev.xmap.event != mywindow);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
211
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
212 XSelectInput(mydisplay, mywindow, NoEventMask);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
213
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
214 glXMakeCurrent( mydisplay,mywindow,wsGLXContext );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
215
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
216 XFlush(mydisplay);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
217 XSync(mydisplay, False);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
218
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
219 // mygc = XCreateGC(mydisplay, mywindow, 0L, &xgcv);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
220
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
221 // myximage = XGetImage(mydisplay, mywindow, 0, 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
222 // width, image_height, AllPlanes, ZPixmap);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
223 // ImageData = myximage->data;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
224 // bpp = myximage->bits_per_pixel;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
225
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
226 //XSelectInput(mydisplay, mywindow, StructureNotifyMask); // !!!!
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
227 XSelectInput(mydisplay, mywindow, StructureNotifyMask | KeyPressMask );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
228
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
229 // printf("Window setup ok\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
230
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
231 #if 0
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
232 // If we have blue in the lowest bit then obviously RGB
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
233 mode = ((myximage->blue_mask & 0x01) != 0) ? MODE_RGB : MODE_BGR;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
234 #ifdef WORDS_BIGENDIAN
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
235 if (myximage->byte_order != MSBFirst)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
236 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
237 if (myximage->byte_order != LSBFirst)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
238 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
239 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
240 fprintf( stderr, "No support fon non-native XImage byte order!\n" );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
241 return -1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
242 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
243
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
244 printf("DEPTH=%d BPP=%d\n",depth,bpp);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
245 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
246
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
247 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
248 * If depth is 24 then it may either be a 3 or 4 byte per pixel
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
249 * format. We can't use bpp because then we would lose the
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
250 * distinction between 15/16bit depth (2 byte formate assumed).
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
251 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
252 * FIXME - change yuv2rgb_init to take both depth and bpp
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
253 * parameters
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
254 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
255
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
256 texture_width=32;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
257 while(texture_width<image_width) texture_width*=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
258 while(texture_width<image_height) texture_width*=2;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
259 texture_height=texture_width;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
260
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
261 if(format==IMGFMT_YV12){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
262 yuv2rgb_init(8*BYTES_PP, MODE_BGR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
263 printf("YUV init OK!\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
264 image_bpp=8*BYTES_PP;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
265 image_bytes=BYTES_PP;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
266 } else {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
267 image_bpp=format&0xFF;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
268 image_bytes=(image_bpp+7)/8;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
269 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
270
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
271 ImageData=malloc(texture_width*texture_height*image_bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
272 memset(ImageData,128,texture_width*texture_height*image_bytes);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
273
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
274 glDisable(GL_BLEND);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
275 glDisable(GL_DEPTH_TEST);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
276 glDepthMask(GL_FALSE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
277 glDisable(GL_CULL_FACE);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
278
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
279 glEnable(GL_TEXTURE_2D);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
280
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
281 printf("Creating %dx%d texture...\n",texture_width,texture_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
282
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
283 #if 1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
284 // glBindTexture(GL_TEXTURE_2D, texture_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
285 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_LINEAR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
286 glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
287 #ifdef TEXTUREFORMAT_32BPP
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
288 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture_width, texture_height, 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
289 #else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
290 glTexImage2D(GL_TEXTURE_2D, 0, BYTES_PP, texture_width, texture_height, 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
291 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
292 (image_bytes==4)?GL_RGBA:GL_BGR, GL_UNSIGNED_BYTE, ImageData);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
293 #endif
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
294
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
295 resize(d_width,d_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
296
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
297 glClearColor( 1.0f,0.0f,1.0f,0.0f );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
298 glClear( GL_COLOR_BUFFER_BIT );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
299
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
300 // printf("OpenGL setup OK!\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
301
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
302 X_already_started++;
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 const vo_info_t*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
307 get_info(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
308 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
309 return &vo_info;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
310 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
311
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
312 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
313 Terminate_Display_Process(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
314 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
315 getchar(); /* wait for enter to remove window */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
316 XDestroyWindow(mydisplay, mywindow);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
317 XCloseDisplay(mydisplay);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
318 X_already_started = 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
319 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
320
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
321
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
322 static void check_events(void)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
323 {
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
324 int e=vo_x11_check_events(mydisplay);
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
325 if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
326 }
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
327
31
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
328
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
329 static void
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
330 flip_page(void)
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
331 {
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
332
1fc618eba830 added check_events() interface
arpi_esp
parents: 1
diff changeset
333 check_events();
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
334
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
335 // glEnable(GL_TEXTURE_2D);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
336 // glBindTexture(GL_TEXTURE_2D, texture_id);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
337
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
338 glColor3f(1,1,1);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
339 glBegin(GL_QUADS);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
340 glTexCoord2f(0,0);glVertex2i(0,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
341 glTexCoord2f(0,1);glVertex2i(0,texture_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
342 glTexCoord2f(1,1);glVertex2i(texture_width,texture_height);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
343 glTexCoord2f(1,0);glVertex2i(texture_width,0);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
344 glEnd();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
345
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
346 // glFlush();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
347 glFinish();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
348 glXSwapBuffers( mydisplay,mywindow );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
349
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
350 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
351
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
352 //static inline uint32_t draw_slice_x11(uint8_t *src[], uint32_t slice_num)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
353 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
354 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
355 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
356 int dstride=w*BYTES_PP;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
357
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
358 // dstride=(dstride+15)&(~15);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
359
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
360 yuv2rgb(ImageData, src[0], src[1], src[2],
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
361 w,h, dstride, stride[0],stride[1]);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
362
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
363 // emms ();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
364
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
365 for(i=0;i<h;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
366 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
367 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
368 x, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
369 y+i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
370 w, // width
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
371 1, // height
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
372 (BYTES_PP==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
373 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
374 ImageData+i*dstride ); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
375 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
376
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
377 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
378 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
379
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
380 static inline uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
381 draw_frame_x11_yv12(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
382 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
383 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
384 // printf("Converting YUV->RGB...\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
385 yuv2rgb(ImageData, src[0], src[1], src[2],
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
386 image_width, image_height,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
387 image_width*BYTES_PP, image_width, image_width/2 );
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
388 // printf("Ready!\n");
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
389
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
390 // emms ();
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
391
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
392 for(i=0;i<image_height;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
393 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
394 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
395 0, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
396 i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
397 image_width, // width
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
398 1, // height
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
399 (BYTES_PP==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
400 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
401 ImageData+i*BYTES_PP*image_width ); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
402 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
403
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
404 // Display_Image(ImageData);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
405 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
406 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
407
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
408
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
409 static inline uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
410 draw_frame_x11_bgr(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
411 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
412 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
413 uint8_t *s=src[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
414 uint8_t *de=&ImageData[3*image_width];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
415
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
416 for(i=0;i<image_height;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
417 int j;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
418 uint8_t *d=ImageData;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
419 while(d<de){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
420 d[0]=s[2];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
421 d[1]=s[1];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
422 d[2]=s[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
423 s+=3;d+=3;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
424 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
425 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
426 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
427 0, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
428 // image_height-1-i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
429 i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
430 image_width, // width
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
431 1, // height
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
432 (image_bytes==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
433 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
434 ImageData); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
435 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
436
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
437 // Display_Image(ImageData);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
438 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
439 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
440
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
441 static inline uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
442 draw_frame_x11_rgb(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
443 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
444 int i;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
445 uint8_t *ImageData=src[0];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
446
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
447 for(i=0;i<image_height;i++){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
448 glTexSubImage2D( GL_TEXTURE_2D, // target
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
449 0, // level
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
450 0, // x offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
451 // image_height-1-i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
452 i, // y offset
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
453 image_width, // width
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
454 1, // height
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
455 (image_bytes==4)?GL_RGBA:GL_RGB, // format
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
456 GL_UNSIGNED_BYTE, // type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
457 ImageData+i*image_bytes*image_width ); // *pixels
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
458 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
459
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
460 // Display_Image(ImageData);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
461 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
462 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
463
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
464
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
465 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
466 draw_frame(uint8_t *src[])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
467 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
468 if(image_format==IMGFMT_YV12)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
469 return draw_frame_x11_yv12(src);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
470 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
471 if((image_format&IMGFMT_RGB_MASK)==IMGFMT_RGB)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
472 return draw_frame_x11_rgb(src);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
473 else
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
474 return draw_frame_x11_bgr(src);
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
475 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
476
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
477 static uint32_t
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
478 query_format(uint32_t format)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
479 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
480 switch(format){
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
481 case IMGFMT_YV12:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
482 case IMGFMT_RGB|24:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
483 case IMGFMT_BGR|24:
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
484 return 1;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
485 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
486 return 0;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
487 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
488
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
489
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
490 static void
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
491 uninit(void)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
492 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
493 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
494