]> git.sesse.net Git - vlc/blob - include/vlc_opengl.h
vlc_gl_t: abstract OpenGL provider
[vlc] / include / vlc_opengl.h
1 /*****************************************************************************
2  * vlc_gl.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
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 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 General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, 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
34 /**
35  * A VLC GL context (and its underlying surface)
36  */
37 typedef struct vlc_gl vlc_gl_t;
38
39 struct vlc_gl
40 {
41     VLC_COMMON_MEMBERS
42
43     struct vout_window_t *surface;
44     module_t *module;
45     void *sys;
46
47     int  (*makeCurrent)(vlc_gl_t *);
48     void (*swap)(vlc_gl_t *);
49     int  (*lock)(vlc_gl_t *);
50     void (*unlock)(vlc_gl_t *);
51 };
52
53 enum {
54     VLC_OPENGL,
55     VLC_OPENGL_ES,
56     VLC_OPENGL_ES2,
57 };
58
59 VLC_EXPORT( vlc_gl_t *, vlc_gl_Create, (struct vout_window_t *, unsigned, const char *) ) LIBVLC_USED;
60 VLC_EXPORT( void, vlc_gl_Destroy, (vlc_gl_t *) );
61
62 static inline int vlc_gl_MakeCurrent(vlc_gl_t *gl)
63 {
64     return gl->makeCurrent(gl);
65 }
66
67 static inline int vlc_gl_Lock(vlc_gl_t *gl)
68 {
69     return (gl->lock != NULL) ? gl->lock(gl) : VLC_SUCCESS;
70 }
71
72 static inline void vlc_gl_Unlock(vlc_gl_t *gl)
73 {
74     if (gl->unlock != NULL)
75         gl->unlock(gl);
76 }
77
78 static inline void vlc_gl_Swap(vlc_gl_t *gl)
79 {
80     gl->swap(gl);
81 }
82
83 #endif /* VLC_GL_H */