]> git.sesse.net Git - vlc/blob - modules/video_output/opengl.h
LGPL
[vlc] / modules / video_output / opengl.h
1 /*****************************************************************************
2  * opengl.h: OpenGL vout_display helpers
3  *****************************************************************************
4  * Copyright (C) 2004 VLC authors and VideoLAN
5  * Copyright (C) 2009 Laurent Aimar
6  *
7  * Authors: Cyril Deguet <asmax@videolan.org>
8  *          Gildas Bazin <gbazin@videolan.org>
9  *          Eric Petit <titer@m0k.org>
10  *          Cedric Cocquebert <cedric.cocquebert@supelec.fr>
11  *          Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
12  *
13  * This program is free software; you can redistribute it and/or modify it
14  * under the terms of the GNU Lesser General Public License as published by
15  * the Free Software Foundation; either version 2.1 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26  *****************************************************************************/
27
28 #include <vlc_common.h>
29 #include <vlc_picture_pool.h>
30 #include <vlc_opengl.h>
31
32 /* Change USE_OPENGL_ES value to set the OpenGL ES version (1, 2) you want to use
33  * A value of 0 will activate normal OpenGL */
34 #ifndef USE_OPENGL_ES
35 # define USE_OPENGL_ES 0
36 #endif
37 #ifdef __APPLE__
38 # include <TargetConditionals.h>
39 # if !TARGET_OS_IPHONE
40 #  define MACOS_OPENGL
41 #  include <OpenGL/gl.h>
42 # else /* Force ESv1 on iOS */
43 #  define USE_OPENGL_ES 1
44 #  include <OpenGLES/ES1/gl.h>
45 #  include <OpenGLES/ES2/gl.h>
46 #  include <OpenGLES/ES2/glext.h>
47 # endif
48 #else /* !defined (__APPLE__) */
49 # if USE_OPENGL_ES == 2
50 #  include <GLES2/gl2.h>
51 # elif USE_OPENGL_ES == 1
52 #  include <GLES/gl.h>
53 # else
54 #  ifdef WIN32
55 #   include <GL/glew.h>
56 #   undef glClientActiveTexture
57 #   undef glActiveTexture
58     PFNGLACTIVETEXTUREPROC glActiveTexture;
59     PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture;
60 #  endif
61 #  include <GL/gl.h>
62 # endif
63 #endif
64
65 static inline bool HasExtension(const char *apis, const char *api)
66 {
67     size_t apilen = strlen(api);
68     while (apis) {
69         while (*apis == ' ')
70             apis++;
71         if (!strncmp(apis, api, apilen) && memchr(" ", apis[apilen], 2))
72             return true;
73         apis = strchr(apis, ' ');
74     }
75     return false;
76 }
77
78 typedef struct vout_display_opengl_t vout_display_opengl_t;
79
80 vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
81                                                const vlc_fourcc_t **subpicture_chromas,
82                                                vlc_gl_t *gl);
83 void vout_display_opengl_Delete(vout_display_opengl_t *vgl);
84
85 picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned);
86
87 int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
88                                 picture_t *picture, subpicture_t *subpicture);
89 int vout_display_opengl_Display(vout_display_opengl_t *vgl,
90                                 const video_format_t *source);