VLC  4.0.0-dev
vlc_opengl.h
Go to the documentation of this file.
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 struct vout_display_cfg;
35 
36 /**
37  * A VLC GL context (and its underlying surface)
38  */
39 typedef struct vlc_gl_t vlc_gl_t;
40 
41 struct vlc_gl_t
42 {
43  struct vlc_object_t obj;
44 
45  struct vout_window_t *surface;
47  void *sys;
48 
49  int (*makeCurrent)(vlc_gl_t *);
51  void (*resize)(vlc_gl_t *, unsigned, unsigned);
52  void (*swap)(vlc_gl_t *);
53  void*(*getProcAddress)(vlc_gl_t *, const char *);
54  void (*destroy)(vlc_gl_t *);
55 
56  enum {
60  } ext;
61 
62  union {
63  /* if ext == VLC_GL_EXT_EGL */
64  struct {
65  /* call eglQueryString() with current display */
66  const char *(*queryString)(vlc_gl_t *, int32_t name);
67  /* call eglCreateImageKHR() with current display and context, can
68  * be NULL */
69  void *(*createImageKHR)(vlc_gl_t *, unsigned target, void *buffer,
70  const int32_t *attrib_list);
71  /* call eglDestroyImageKHR() with current display, can be NULL */
72  bool (*destroyImageKHR)(vlc_gl_t *, void *image);
73  } egl;
74  /* if ext == VLC_GL_EXT_WGL */
75  struct
76  {
77  const char *(*getExtensionsString)(vlc_gl_t *);
78  } wgl;
79  };
80 };
81 
82 enum {
83  VLC_OPENGL,
85 };
86 
87 /**
88  * Creates an OpenGL context (and its underlying surface).
89  *
90  * @note In most cases, you should vlc_gl_MakeCurrent() afterward.
91  *
92  * @param cfg initial configuration (including window to use as OpenGL surface)
93  * @param flags OpenGL context type
94  * @param name module name (or NULL for auto)
95  * @return a new context, or NULL on failure
96  */
98  unsigned flags, const char *name) VLC_USED;
101 
102 static inline int vlc_gl_MakeCurrent(vlc_gl_t *gl)
103 {
104  return gl->makeCurrent(gl);
105 }
106 
107 static inline void vlc_gl_ReleaseCurrent(vlc_gl_t *gl)
108 {
109  gl->releaseCurrent(gl);
110 }
111 
112 static inline void vlc_gl_Resize(vlc_gl_t *gl, unsigned w, unsigned h)
113 {
114  if (gl->resize != NULL)
115  gl->resize(gl, w, h);
116 }
117 
118 static inline void vlc_gl_Swap(vlc_gl_t *gl)
119 {
120  gl->swap(gl);
121 }
122 
123 static inline void *vlc_gl_GetProcAddress(vlc_gl_t *gl, const char *name)
124 {
125  return gl->getProcAddress(gl, name);
126 }
127 
129  const struct vout_window_cfg_t *,
130  struct vout_window_t **) VLC_USED;
131 VLC_API bool vlc_gl_surface_CheckSize(vlc_gl_t *, unsigned *w, unsigned *h);
133 
134 static inline bool vlc_gl_StrHasToken(const char *apis, const char *api)
135 {
136  size_t apilen = strlen(api);
137  while (apis) {
138  while (*apis == ' ')
139  apis++;
140  if (!strncmp(apis, api, apilen) && memchr(" ", apis[apilen], 2))
141  return true;
142  apis = strchr(apis, ' ');
143  }
144  return false;
145 }
146 
147 #endif /* VLC_GL_H */
void(* releaseCurrent)(vlc_gl_t *)
Definition: vlc_opengl.h:51
struct vlc_gl_t::@261::@264 wgl
vlc_gl_t * vlc_gl_surface_Create(vlc_object_t *, const struct vout_window_cfg_t *, struct vout_window_t **)
static void * vlc_gl_GetProcAddress(vlc_gl_t *gl, const char *name)
Definition: vlc_opengl.h:124
void * sys
Definition: vlc_opengl.h:48
struct vout_window_t * surface
Definition: vlc_opengl.h:46
void vlc_gl_surface_Destroy(vlc_gl_t *)
Definition: opengl.c:224
static void vlc_gl_Swap(vlc_gl_t *gl)
Definition: vlc_opengl.h:119
void(* swap)(vlc_gl_t *)
Definition: vlc_opengl.h:53
bool vlc_gl_surface_CheckSize(vlc_gl_t *, unsigned *w, unsigned *h)
Internal module descriptor.
Definition: modules.h:75
Definition: vlc_opengl.h:84
static int vlc_gl_MakeCurrent(vlc_gl_t *gl)
Definition: vlc_opengl.h:103
static bool vlc_gl_StrHasToken(const char *apis, const char *api)
Definition: vlc_opengl.h:135
module_t * module
Definition: vlc_opengl.h:47
enum vlc_gl_t::@260 ext
vlc_gl_t * vlc_gl_Create(const struct vout_display_cfg *cfg, unsigned flags, const char *name)
Creates an OpenGL context (and its underlying surface).
const char name[16]
Definition: httpd.c:1269
bool(* destroyImageKHR)(vlc_gl_t *, void *image)
Definition: vlc_opengl.h:73
static void vlc_gl_Resize(vlc_gl_t *gl, unsigned w, unsigned h)
Definition: vlc_opengl.h:113
void vlc_gl_Release(vlc_gl_t *)
Definition: opengl.c:100
Window (desired) configuration.
Definition: vlc_vout_window.h:147
#define VLC_API
Definition: fourcc_gen.c:31
Definition: vlc_opengl.h:60
int(* makeCurrent)(vlc_gl_t *)
Definition: vlc_opengl.h:50
Definition: vlc_opengl.h:85
void(* resize)(vlc_gl_t *, unsigned, unsigned)
Definition: vlc_opengl.h:52
Definition: vlc_opengl.h:42
Definition: vlc_opengl.h:59
void(* destroy)(vlc_gl_t *)
Definition: vlc_opengl.h:55
User configuration for a video output display (vout_display_t)
Definition: vlc_vout_display.h:94
void vlc_gl_Hold(vlc_gl_t *)
Definition: opengl.c:94
void *(* getProcAddress)(vlc_gl_t *, const char *)
Definition: vlc_opengl.h:54
Window object.
Definition: vlc_vout_window.h:336
VLC object common members.
Definition: vlc_objects.h:43
Definition: vlc_opengl.h:58
struct vlc_gl_t::@261::@263 egl
#define VLC_USED
Definition: fourcc_gen.c:32
static void vlc_gl_ReleaseCurrent(vlc_gl_t *gl)
Definition: vlc_opengl.h:108