1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
/*
* utils_glx.h - GLX utilities
*
* libva-driver-vdpau (C) 2009-2011 Splitted-Desktop Systems
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef UTILS_GLX_H
#define UTILS_GLX_H
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/glx.h>
#include <GL/glxext.h>
#include <vdpau/vdpau.h>
/* GL_NV_vdpau_interop */
#if GL_GLEXT_VERSION < 64
typedef GLintptr GLvdpauSurfaceNV;
typedef void (*PFNGLVDPAUINITNVPROC)(const GLvoid *vdpDevice, const GLvoid *getProcAddress);
typedef void (*PFNGLVDPAUFININVPROC)(void);
typedef GLvdpauSurfaceNV (*PFNGLVDPAUREGISTERVIDEOSURFACENVPROC)(const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
typedef GLvdpauSurfaceNV (*PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC)(const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames);
typedef GLboolean (*PFNGLVDPAUISSURFACENVPROC)(GLvdpauSurfaceNV surface);
typedef void (*PFNGLVDPAUUNREGISTERSURFACENVPROC)(GLvdpauSurfaceNV surface);
typedef void (*PFNGLVDPAUGETSURFACEIVNVPROC)(GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
typedef void (*PFNGLVDPAUSURFACEACCESSNVPROC)(GLvdpauSurfaceNV surface, GLenum access);
typedef void (*PFNGLVDPAUMAPSURFACESNVPROC)(GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces);
typedef void (*PFNGLVDPAUUNMAPSURFACESNVPROC)(GLsizei numSurface, const GLvdpauSurfaceNV *surfaces);
#endif
/* GLX_EXT_texture_from_pixmap */
#if GLX_GLXEXT_VERSION < 18
typedef void (*PFNGLXBINDTEXIMAGEEXTPROC)(Display *, GLXDrawable, int, const int *);
typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC)(Display *, GLXDrawable, int);
#endif
#ifndef GL_FRAMEBUFFER_BINDING
#define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_EXT
#endif
#ifndef GL_FRAGMENT_PROGRAM
#define GL_FRAGMENT_PROGRAM GL_FRAGMENT_PROGRAM_ARB
#endif
#ifndef GL_PROGRAM_FORMAT_ASCII
#define GL_PROGRAM_FORMAT_ASCII GL_PROGRAM_FORMAT_ASCII_ARB
#endif
#ifndef GL_PROGRAM_ERROR_POSITION
#define GL_PROGRAM_ERROR_POSITION GL_PROGRAM_ERROR_POSITION_ARB
#endif
#ifndef GL_PROGRAM_ERROR_STRING
#define GL_PROGRAM_ERROR_STRING GL_PROGRAM_ERROR_STRING_ARB
#endif
#ifndef GL_PROGRAM_UNDER_NATIVE_LIMITS
#define GL_PROGRAM_UNDER_NATIVE_LIMITS GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB
#endif
const char *
gl_get_error_string(GLenum error)
attribute_hidden;
void
gl_purge_errors(void)
attribute_hidden;
int
gl_check_error(void)
attribute_hidden;
int
gl_get_current_color(float color[4])
attribute_hidden;
int
gl_get_param(GLenum param, unsigned int *pval)
attribute_hidden;
int
gl_get_texture_param(GLenum target, GLenum param, unsigned int *pval)
attribute_hidden;
void
gl_set_bgcolor(uint32_t color)
attribute_hidden;
void
gl_set_texture_scaling(GLenum target, GLenum scale)
attribute_hidden;
void
gl_resize(unsigned int width, unsigned int height)
attribute_hidden;
typedef struct _GLContextState GLContextState;
struct _GLContextState {
Display *display;
Window window;
XVisualInfo *visual;
GLXContext context;
};
GLContextState *
gl_create_context(Display *dpy, int screen, GLContextState *parent)
attribute_hidden;
void
gl_destroy_context(GLContextState *cs)
attribute_hidden;
void
gl_init_context(GLContextState *cs)
attribute_hidden;
void
gl_get_current_context(GLContextState *cs)
attribute_hidden;
int
gl_set_current_context(GLContextState *new_cs, GLContextState *old_cs)
attribute_hidden;
void
gl_swap_buffers(GLContextState *cs)
attribute_hidden;
GLuint
gl_create_texture(GLenum target, GLenum format, unsigned int width, unsigned int height)
attribute_hidden;
typedef struct _GLVTable GLVTable;
struct _GLVTable {
PFNGLXBINDTEXIMAGEEXTPROC glx_bind_tex_image;
PFNGLXRELEASETEXIMAGEEXTPROC glx_release_tex_image;
PFNGLGENFRAMEBUFFERSEXTPROC gl_gen_framebuffers;
PFNGLDELETEFRAMEBUFFERSEXTPROC gl_delete_framebuffers;
PFNGLBINDFRAMEBUFFEREXTPROC gl_bind_framebuffer;
PFNGLGENRENDERBUFFERSEXTPROC gl_gen_renderbuffers;
PFNGLDELETERENDERBUFFERSEXTPROC gl_delete_renderbuffers;
PFNGLBINDRENDERBUFFEREXTPROC gl_bind_renderbuffer;
PFNGLRENDERBUFFERSTORAGEEXTPROC gl_renderbuffer_storage;
PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC gl_framebuffer_renderbuffer;
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC gl_framebuffer_texture_2d;
PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC gl_check_framebuffer_status;
PFNGLGENPROGRAMSARBPROC gl_gen_programs;
PFNGLDELETEPROGRAMSARBPROC gl_delete_programs;
PFNGLBINDPROGRAMARBPROC gl_bind_program;
PFNGLPROGRAMSTRINGARBPROC gl_program_string;
PFNGLGETPROGRAMIVARBPROC gl_get_program_iv;
PFNGLPROGRAMLOCALPARAMETER4FVARBPROC gl_program_local_parameter_4fv;
PFNGLACTIVETEXTUREPROC gl_active_texture;
PFNGLMULTITEXCOORD2FPROC gl_multi_tex_coord_2f;
PFNGLVDPAUINITNVPROC gl_vdpau_init;
PFNGLVDPAUFININVPROC gl_vdpau_fini;
PFNGLVDPAUREGISTERVIDEOSURFACENVPROC gl_vdpau_register_video_surface;
PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC gl_vdpau_register_output_surface;
PFNGLVDPAUISSURFACENVPROC gl_vdpau_is_surface;
PFNGLVDPAUUNREGISTERSURFACENVPROC gl_vdpau_unregister_surface;
PFNGLVDPAUGETSURFACEIVNVPROC gl_vdpau_get_surface_iv;
PFNGLVDPAUSURFACEACCESSNVPROC gl_vdpau_surface_access;
PFNGLVDPAUMAPSURFACESNVPROC gl_vdpau_map_surfaces;
PFNGLVDPAUUNMAPSURFACESNVPROC gl_vdpau_unmap_surfaces;
unsigned int has_texture_non_power_of_two : 1;
unsigned int has_texture_rectangle : 1;
unsigned int has_texture_from_pixmap : 1;
unsigned int has_framebuffer_object : 1;
unsigned int has_fragment_program : 1;
unsigned int has_multitexture : 1;
unsigned int has_vdpau_interop : 1;
};
GLVTable *
gl_get_vtable(void)
attribute_hidden;
typedef struct _GLPixmapObject GLPixmapObject;
struct _GLPixmapObject {
Display *dpy;
GLenum target;
GLuint texture;
unsigned int width;
unsigned int height;
Pixmap pixmap;
GLXPixmap glx_pixmap;
unsigned int is_bound : 1;
};
GLPixmapObject *
gl_create_pixmap_object(
Display *dpy,
GLenum target,
unsigned int width,
unsigned int height
) attribute_hidden;
void
gl_destroy_pixmap_object(GLPixmapObject *pixo)
attribute_hidden;
int
gl_bind_pixmap_object(GLPixmapObject *pixo)
attribute_hidden;
int
gl_unbind_pixmap_object(GLPixmapObject *pixo)
attribute_hidden;
typedef struct _GLFramebufferObject GLFramebufferObject;
struct _GLFramebufferObject {
unsigned int width;
unsigned int height;
GLuint fbo;
GLuint old_fbo;
unsigned int is_bound : 1;
};
GLFramebufferObject *
gl_create_framebuffer_object(
GLenum target,
GLuint texture,
unsigned int width,
unsigned int height
) attribute_hidden;
void
gl_destroy_framebuffer_object(GLFramebufferObject *fbo)
attribute_hidden;
int
gl_bind_framebuffer_object(GLFramebufferObject *fbo)
attribute_hidden;
int
gl_unbind_framebuffer_object(GLFramebufferObject *fbo)
attribute_hidden;
int
gl_vdpau_init(VdpDevice device, VdpGetProcAddress get_proc_address)
attribute_hidden;
void
gl_vdpau_exit(void)
attribute_hidden;
typedef struct _GLVdpSurface GLVdpSurface;
struct _GLVdpSurface {
GLvdpauSurfaceNV surface;
GLenum target;
unsigned int num_textures;
GLuint textures[4];
unsigned int is_bound : 1;
};
GLVdpSurface *
gl_vdpau_create_video_surface(GLenum target, VdpVideoSurface surface)
attribute_hidden;
GLVdpSurface *
gl_vdpau_create_output_surface(GLenum target, VdpOutputSurface surface)
attribute_hidden;
void
gl_vdpau_destroy_surface(GLVdpSurface *s)
attribute_hidden;
int
gl_vdpau_bind_surface(GLVdpSurface *s)
attribute_hidden;
int
gl_vdpau_unbind_surface(GLVdpSurface *s)
attribute_hidden;
#endif /* UTILS_GLX_H */
|