opengl.h 3.69 KB
Newer Older
1 2 3
/*****************************************************************************
 * opengl.h: OpenGL vout_display helpers
 *****************************************************************************
4
 * Copyright (C) 2004-2013 VLC authors and VideoLAN
5 6
 * Copyright (C) 2009 Laurent Aimar
 *
7 8 9 10 11 12
 * Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
 *          Rémi Denis-Courmont
 *          Jean-Baptiste Kempf <jb@videolan.org>
 *          Ilkka Ollakka <ileoo@videolan.org>
 *          Felix Paul Kühne <fkuehne at videolan dot org>
 *          Rafaël Carré <funman@videolanorg>
13
 *
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
14 15 16
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
17 18 19 20
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
21 22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
23
 *
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
24 25 26
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
27 28
 *****************************************************************************/

29 30 31
#ifndef VLC_OPENGL_H
#define VLC_OPENGL_H

32 33
#include <vlc_common.h>
#include <vlc_picture_pool.h>
34
#include <vlc_opengl.h>
35

36 37
/* Change USE_OPENGL_ES value to set the OpenGL ES version (1, 2) you want to use
 * A value of 0 will activate normal OpenGL */
38
#ifdef __APPLE__
39 40
# include <TargetConditionals.h>
# if !TARGET_OS_IPHONE
41
#  define USE_OPENGL_ES 0
42 43
#  define MACOS_OPENGL
#  include <OpenGL/gl.h>
44 45
# else /* Force ESv2 on iOS */
#  define USE_OPENGL_ES 2
46 47 48
#  include <OpenGLES/ES1/gl.h>
#  include <OpenGLES/ES2/gl.h>
#  include <OpenGLES/ES2/glext.h>
49
# endif
50
#else /* !defined (__APPLE__) */
51 52 53
# ifndef USE_OPENGL_ES
#  define USE_OPENGL_ES 0
# endif
54 55 56 57 58
# if USE_OPENGL_ES == 2
#  include <GLES2/gl2.h>
# elif USE_OPENGL_ES == 1
#  include <GLES/gl.h>
# else
59
#  ifdef _WIN32
60
#   include <GL/glew.h>
Rafaël Carré's avatar
Rafaël Carré committed
61 62 63 64
#   undef glClientActiveTexture
#   undef glActiveTexture
    PFNGLACTIVETEXTUREPROC glActiveTexture;
    PFNGLCLIENTACTIVETEXTUREPROC glClientActiveTexture;
65
#  endif
66 67
#  include <GL/gl.h>
# endif
68 69
#endif

70 71 72 73 74
static const vlc_fourcc_t gl_subpicture_chromas[] = {
    VLC_CODEC_RGBA,
    0
};

75 76 77 78 79 80 81 82 83 84 85 86 87
static inline bool HasExtension(const char *apis, const char *api)
{
    size_t apilen = strlen(api);
    while (apis) {
        while (*apis == ' ')
            apis++;
        if (!strncmp(apis, api, apilen) && memchr(" ", apis[apilen], 2))
            return true;
        apis = strchr(apis, ' ');
    }
    return false;
}

88 89
void orientationTransformMatrix(GLfloat matrix[static 16], video_orientation_t orientation);

90
typedef struct vout_display_opengl_t vout_display_opengl_t;
91

92 93
vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
                                               const vlc_fourcc_t **subpicture_chromas,
94 95
                                               vlc_gl_t *gl,
                                               const vlc_viewpoint_t *viewpoint);
96
void vout_display_opengl_Delete(vout_display_opengl_t *vgl);
97

98
picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl, unsigned);
99

100 101
int vout_display_opengl_SetViewpoint(vout_display_opengl_t *vgl, const vlc_viewpoint_t*);

102
int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
103
                                picture_t *picture, subpicture_t *subpicture);
104 105
int vout_display_opengl_Display(vout_display_opengl_t *vgl,
                                const video_format_t *source);
106 107

#endif