]> git.sesse.net Git - vlc/blob - include/vlc_opengl.h
gl: add resize callback
[vlc] / include / vlc_opengl.h
1 /*****************************************************************************
2  * vlc_opengl.h: VLC GL API
3  *****************************************************************************
4  * Copyright (C) 2009 Laurent Aimar
5  * Copyright (C) 2011 RĂ©mi Denis-Courmont
6  *
7  * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #ifndef VLC_GL_H
25 #define VLC_GL_H 1
26
27 /**
28  * \file
29  * This file defines GL structures and functions.
30  */
31
32 struct vout_window_t;
33 struct vout_window_cfg_t;
34
35 /**
36  * A VLC GL context (and its underlying surface)
37  */
38 typedef struct vlc_gl_t vlc_gl_t;
39
40 struct vlc_gl_t
41 {
42     VLC_COMMON_MEMBERS
43
44     struct vout_window_t *surface;
45     module_t *module;
46     void *sys;
47
48     int  (*makeCurrent)(vlc_gl_t *);
49     void (*releaseCurrent)(vlc_gl_t *);
50     void (*resize)(vlc_gl_t *, unsigned, unsigned);
51     void (*swap)(vlc_gl_t *);
52     int  (*lock)(vlc_gl_t *);
53     void (*unlock)(vlc_gl_t *);
54     void*(*getProcAddress)(vlc_gl_t *, const char *);
55 };
56
57 enum {
58     VLC_OPENGL,
59     VLC_OPENGL_ES,
60     VLC_OPENGL_ES2,
61 };
62
63 VLC_API vlc_gl_t *vlc_gl_Create(struct vout_window_t *, unsigned, const char *) VLC_USED;
64 VLC_API void vlc_gl_Destroy(vlc_gl_t *);
65
66 static inline int vlc_gl_MakeCurrent(vlc_gl_t *gl)
67 {
68     return gl->makeCurrent(gl);
69 }
70
71 static inline void vlc_gl_ReleaseCurrent(vlc_gl_t *gl)
72 {
73     gl->releaseCurrent(gl);
74 }
75
76 static inline int vlc_gl_Lock(vlc_gl_t *gl)
77 {
78     return (gl->lock != NULL) ? gl->lock(gl) : VLC_SUCCESS;
79 }
80
81 static inline void vlc_gl_Unlock(vlc_gl_t *gl)
82 {
83     if (gl->unlock != NULL)
84         gl->unlock(gl);
85 }
86
87 static inline void vlc_gl_Resize(vlc_gl_t *gl, unsigned w, unsigned h)
88 {
89     if (gl->resize != NULL)
90         gl->resize(gl, w, h);
91 }
92
93 static inline void vlc_gl_Swap(vlc_gl_t *gl)
94 {
95     gl->swap(gl);
96 }
97
98 static inline void *vlc_gl_GetProcAddress(vlc_gl_t *gl, const char *name)
99 {
100     return (gl->getProcAddress != NULL) ? gl->getProcAddress(gl, name) : NULL;
101 }
102
103 VLC_API vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *,
104                                         const struct vout_window_cfg_t *,
105                                         struct vout_window_t **) VLC_USED;
106 VLC_API bool vlc_gl_surface_CheckSize(vlc_gl_t *, unsigned *w, unsigned *h);
107 VLC_API void vlc_gl_surface_Destroy(vlc_gl_t *);
108
109 #endif /* VLC_GL_H */