2 * gstvaapiutils_glx.h - GLX utilties
4 * Copyright (C) 2010-2011 Splitted-Desktop Systems
5 * Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6 * Copyright (C) 2012 Intel Corporation
7 * Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA
25 #ifndef GST_VAAPI_UTILS_GLX_H
26 #define GST_VAAPI_UTILS_GLX_H
29 #include "libgstvaapi_priv_check.h"
33 #include <GL/glxext.h>
36 #if GLX_GLXEXT_VERSION < 18
37 typedef void (*PFNGLXBINDTEXIMAGEEXTPROC) (Display *, GLXDrawable, int,
39 typedef void (*PFNGLXRELEASETEXIMAGEEXTPROC) (Display *, GLXDrawable, int);
42 #if GLX_GLXEXT_VERSION < 27
43 /* XXX: this is not exactly that version but this is the only means to
44 make sure we have the correct <GL/glx.h> with those signatures */
45 typedef GLXPixmap (*PFNGLXCREATEPIXMAPPROC) (Display *, GLXFBConfig, Pixmap,
47 typedef void (*PFNGLXDESTROYPIXMAPPROC) (Display *, GLXPixmap);
50 #ifndef GL_FRAMEBUFFER_BINDING
51 #define GL_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING_EXT
56 gl_get_error_string (GLenum error);
60 gl_purge_errors (void);
64 gl_check_error (void);
68 gl_get_param (GLenum param, guint * pval);
72 gl_get_texture_param (GLenum target, GLenum param, guint * pval);
76 gl_set_bgcolor (guint32 color);
80 gl_resize (guint width, guint height);
82 typedef struct _GLContextState GLContextState;
83 struct _GLContextState
89 guint swapped_buffers:1;
94 gl_create_context (Display * dpy, int screen, GLContextState * parent);
98 gl_destroy_context (GLContextState * cs);
102 gl_get_current_context (GLContextState * cs);
106 gl_set_current_context (GLContextState * new_cs, GLContextState * old_cs);
110 gl_swap_buffers (GLContextState * cs);
112 typedef struct _GLTextureState GLTextureState;
113 struct _GLTextureState
123 gl_bind_texture (GLTextureState * ts, GLenum target, GLuint texture);
127 gl_unbind_texture (GLTextureState * ts);
131 gl_create_texture (GLenum target, GLenum format, guint width, guint height);
133 typedef struct _GLVTable GLVTable;
136 PFNGLXCREATEPIXMAPPROC glx_create_pixmap;
137 PFNGLXDESTROYPIXMAPPROC glx_destroy_pixmap;
138 PFNGLXBINDTEXIMAGEEXTPROC glx_bind_tex_image;
139 PFNGLXRELEASETEXIMAGEEXTPROC glx_release_tex_image;
140 PFNGLGENFRAMEBUFFERSEXTPROC gl_gen_framebuffers;
141 PFNGLDELETEFRAMEBUFFERSEXTPROC gl_delete_framebuffers;
142 PFNGLBINDFRAMEBUFFEREXTPROC gl_bind_framebuffer;
143 PFNGLGENRENDERBUFFERSEXTPROC gl_gen_renderbuffers;
144 PFNGLDELETERENDERBUFFERSEXTPROC gl_delete_renderbuffers;
145 PFNGLBINDRENDERBUFFEREXTPROC gl_bind_renderbuffer;
146 PFNGLRENDERBUFFERSTORAGEEXTPROC gl_renderbuffer_storage;
147 PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC gl_framebuffer_renderbuffer;
148 PFNGLFRAMEBUFFERTEXTURE2DEXTPROC gl_framebuffer_texture_2d;
149 PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC gl_check_framebuffer_status;
150 guint has_texture_from_pixmap:1;
151 guint has_framebuffer_object:1;
156 gl_get_vtable (void);
158 typedef struct _GLPixmapObject GLPixmapObject;
159 struct _GLPixmapObject
164 GLTextureState old_texture;
168 GLXPixmap glx_pixmap;
174 gl_create_pixmap_object (Display * dpy, guint width, guint height);
178 gl_destroy_pixmap_object (GLPixmapObject * pixo);
182 gl_bind_pixmap_object (GLPixmapObject * pixo);
186 gl_unbind_pixmap_object (GLPixmapObject * pixo);
188 typedef struct _GLFramebufferObject GLFramebufferObject;
189 struct _GLFramebufferObject
199 GLFramebufferObject *
200 gl_create_framebuffer_object (GLenum target,
201 GLuint texture, guint width, guint height);
205 gl_destroy_framebuffer_object (GLFramebufferObject * fbo);
209 gl_bind_framebuffer_object (GLFramebufferObject * fbo);
213 gl_unbind_framebuffer_object (GLFramebufferObject * fbo);
215 #endif /* GST_VAAPI_UTILS_GLX_H */