Commit 97a961bd authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

vlc_gl_t: abstract OpenGL provider

This API is abstracted away from the video output. In a way, this goes
back to the previous opengl provider API, except that:
 - it is really independent of the video output,
 - it supports GL ES explicitly.
parent c84ce9cb
/*****************************************************************************
* vlc_gl.h: VLC GL API
*****************************************************************************
* Copyright (C) 2009 Laurent Aimar
* Copyright (C) 2011 Rémi Denis-Courmont
*
* Authors: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU 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.
*****************************************************************************/
#ifndef VLC_GL_H
#define VLC_GL_H 1
/**
* \file
* This file defines GL structures and functions.
*/
struct vout_window_t;
/**
* A VLC GL context (and its underlying surface)
*/
typedef struct vlc_gl vlc_gl_t;
struct vlc_gl
{
VLC_COMMON_MEMBERS
struct vout_window_t *surface;
module_t *module;
void *sys;
int (*makeCurrent)(vlc_gl_t *);
void (*swap)(vlc_gl_t *);
int (*lock)(vlc_gl_t *);
void (*unlock)(vlc_gl_t *);
};
enum {
VLC_OPENGL,
VLC_OPENGL_ES,
VLC_OPENGL_ES2,
};
VLC_EXPORT( vlc_gl_t *, vlc_gl_Create, (struct vout_window_t *, unsigned, const char *) ) LIBVLC_USED;
VLC_EXPORT( void, vlc_gl_Destroy, (vlc_gl_t *) );
static inline int vlc_gl_MakeCurrent(vlc_gl_t *gl)
{
return gl->makeCurrent(gl);
}
static inline int vlc_gl_Lock(vlc_gl_t *gl)
{
return (gl->lock != NULL) ? gl->lock(gl) : VLC_SUCCESS;
}
static inline void vlc_gl_Unlock(vlc_gl_t *gl)
{
if (gl->unlock != NULL)
gl->unlock(gl);
}
static inline void vlc_gl_Swap(vlc_gl_t *gl)
{
gl->swap(gl);
}
#endif /* VLC_GL_H */
......@@ -71,6 +71,7 @@ pluginsinclude_HEADERS = \
../include/vlc_fourcc.h \
../include/vlc_fs.h \
../include/vlc_gcrypt.h \
../include/vlc_opengl.h \
../include/vlc_http.h \
../include/vlc_httpd.h \
../include/vlc_image.h \
......@@ -393,6 +394,7 @@ SOURCES_libvlc_common = \
video_output/video_widgets.c \
video_output/vout_subpictures.c \
video_output/window.c \
video_output/opengl.c \
video_output/vout_intf.c \
video_output/vout_internal.h \
video_output/vout_control.h \
......
......@@ -627,6 +627,8 @@ vlc_epg_Delete
vlc_epg_AddEvent
vlc_epg_SetCurrent
vlc_epg_Merge
vlc_gl_Create
vlc_gl_Destroy
vlm_Control
vlm_Delete
vlm_ExecuteCommand
......
/*****************************************************************************
* opengl.c: VLC GL API
*****************************************************************************
* Copyright (C) 2011 Rémi Denis-Courmont
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU 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.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <vlc_common.h>
#include <vlc_opengl.h>
#include "libvlc.h"
#include <vlc_modules.h>
#undef vlc_gl_Create
/**
* Creates an OpenGL context (and its underlying surface).
*
* @note In most cases, you should vlc_gl_MakeCurrent() afterward.
*
* @param wnd window to use as OpenGL surface
* @param flags OpenGL context type
* @param name module name (or NULL for auto)
* @return a new context, or NULL on failure
*/
vlc_gl_t *vlc_gl_Create(struct vout_window_t *wnd, unsigned flags,
const char *name)
{
vlc_object_t *parent = (vlc_object_t *)wnd;
vlc_gl_t *gl;
const char *type;
switch (flags /*& VLC_OPENGL_API_MASK*/)
{
case VLC_OPENGL:
type = "opengl";
break;
case VLC_OPENGL_ES:
type = "opengl es";
break;
case VLC_OPENGL_ES2:
type = "opengl es2";
break;
default:
return NULL;
}
gl = vlc_custom_create(parent, sizeof (*gl), VLC_OBJECT_GENERIC, "gl");
if (unlikely(gl == NULL))
return NULL;
vlc_object_attach(gl, parent);
gl->surface = wnd;
gl->module = module_need(gl, type, name, true);
if (gl->module == NULL)
{
vlc_object_release(gl);
return NULL;
}
return gl;
}
void vlc_gl_Destroy(vlc_gl_t *gl)
{
module_unneed(gl, gl->module);
vlc_object_release(gl);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment