demux: mp4: only have unsigned pts offsets
[vlc.git] / include / vlc_opengl.h
bloba99c6ced6467b41814360d9d2a319575fa59138d
1 /*****************************************************************************
2 * vlc_opengl.h: VLC GL API
3 *****************************************************************************
4 * Copyright (C) 2009 Laurent Aimar
5 * Copyright (C) 2011 RĂ©mi Denis-Courmont
7 * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program 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
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef VLC_GL_H
25 #define VLC_GL_H 1
27 /**
28 * \file
29 * This file defines GL structures and functions.
32 struct vout_window_t;
33 struct vout_window_cfg_t;
34 struct vout_display_cfg;
36 /**
37 * A VLC GL context (and its underlying surface)
39 typedef struct vlc_gl_t vlc_gl_t;
41 enum vlc_gl_api_type {
42 VLC_OPENGL,
43 VLC_OPENGL_ES2,
46 struct vlc_gl_t
48 struct vlc_object_t obj;
50 struct vout_window_t *surface;
51 module_t *module;
52 void *sys;
54 int (*make_current)(vlc_gl_t *);
55 void (*release_current)(vlc_gl_t *);
56 void (*resize)(vlc_gl_t *, unsigned, unsigned);
57 void (*swap)(vlc_gl_t *);
58 void*(*get_proc_address)(vlc_gl_t *, const char *);
59 void (*destroy)(vlc_gl_t *);
61 enum {
62 VLC_GL_EXT_DEFAULT,
63 VLC_GL_EXT_EGL,
64 VLC_GL_EXT_WGL,
65 } ext;
67 union {
68 /* if ext == VLC_GL_EXT_EGL */
69 struct {
70 /* call eglQueryString() with current display */
71 const char *(*queryString)(vlc_gl_t *, int32_t name);
72 /* call eglCreateImageKHR() with current display and context, can
73 * be NULL */
74 void *(*createImageKHR)(vlc_gl_t *, unsigned target, void *buffer,
75 const int32_t *attrib_list);
76 /* call eglDestroyImageKHR() with current display, can be NULL */
77 bool (*destroyImageKHR)(vlc_gl_t *, void *image);
78 } egl;
79 /* if ext == VLC_GL_EXT_WGL */
80 struct
82 const char *(*getExtensionsString)(vlc_gl_t *);
83 } wgl;
86 /* Defined by the core for libvlc_opengl API loading. */
87 enum vlc_gl_api_type api_type;
90 /**
91 * Creates an OpenGL context (and its underlying surface).
93 * @note In most cases, you should vlc_gl_MakeCurrent() afterward.
95 * @param cfg initial configuration (including window to use as OpenGL surface)
96 * @param flags OpenGL context type
97 * @param name module name (or NULL for auto)
98 * @return a new context, or NULL on failure
100 VLC_API vlc_gl_t *vlc_gl_Create(const struct vout_display_cfg *cfg,
101 unsigned flags, const char *name) VLC_USED;
102 VLC_API void vlc_gl_Release(vlc_gl_t *);
103 VLC_API void vlc_gl_Hold(vlc_gl_t *);
105 static inline int vlc_gl_MakeCurrent(vlc_gl_t *gl)
107 return gl->make_current(gl);
110 static inline void vlc_gl_ReleaseCurrent(vlc_gl_t *gl)
112 gl->release_current(gl);
115 static inline void vlc_gl_Resize(vlc_gl_t *gl, unsigned w, unsigned h)
117 if (gl->resize != NULL)
118 gl->resize(gl, w, h);
121 static inline void vlc_gl_Swap(vlc_gl_t *gl)
123 gl->swap(gl);
126 static inline void *vlc_gl_GetProcAddress(vlc_gl_t *gl, const char *name)
128 return gl->get_proc_address(gl, name);
131 VLC_API vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *,
132 const struct vout_window_cfg_t *,
133 struct vout_window_t **) VLC_USED;
134 VLC_API bool vlc_gl_surface_CheckSize(vlc_gl_t *, unsigned *w, unsigned *h);
135 VLC_API void vlc_gl_surface_Destroy(vlc_gl_t *);
137 static inline bool vlc_gl_StrHasToken(const char *apis, const char *api)
139 size_t apilen = strlen(api);
140 while (apis) {
141 while (*apis == ' ')
142 apis++;
143 if (!strncmp(apis, api, apilen) && memchr(" ", apis[apilen], 2))
144 return true;
145 apis = strchr(apis, ' ');
147 return false;
150 #endif /* VLC_GL_H */