From be933ef2241d79558f91796cc5b3a161f72ebf9c Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 19 Oct 2020 00:52:24 +0200 Subject: sync with upstream --- xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h | 112 ++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h') diff --git a/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h new file mode 100644 index 0000000..16d43e3 --- /dev/null +++ b/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2005-2019 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#ifdef __cplusplus + +//============================================================================== +/// @defgroup cpp_kodi_gui_helpers_gl OpenGL helpers +/// @ingroup cpp_kodi_gui_helpers +/// @brief **Auxiliary functions for Open GL**\n +/// This group includes help for definitions, functions, and classes for +/// OpenGL. +/// +/// To use OpenGL for your system, add the @ref GL.h "#include ". +/// +/// The @ref HAS_GL is declared if Open GL is required and @ref HAS_GLES if Open GL +/// Embedded Systems (ES) is required, with ES the version is additionally given +/// in the definition, this can be "2" or "3". +/// +/// +///----------------------------------------------------------------------------- +/// +/// Following @ref GL_TYPE_STRING define can be used, for example, to manage +/// different folders for GL and GLES and make the selection easier. +/// This are on OpenGL "GL" and on Open GL|ES "GLES". +/// +/// **Example:** +/// ~~~~~~~~~~~~~~~~~{.cpp} +/// kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/frag.glsl"); +/// ~~~~~~~~~~~~~~~~~ +/// +/// +///---------------------------------------------------------------------------- +/// +/// In addition, @ref BUFFER_OFFSET is declared in it which can be used to give an +/// offset on the array to GL. +/// +/// **Example:** +/// ~~~~~~~~~~~~~~~~~{.cpp} +/// const struct PackedVertex { +/// float position[3]; // Position x, y, z +/// float color[4]; // Color r, g, b, a +/// } vertices[3] = { +/// { { -0.5f, -0.5f, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } }, +/// { { 0.5f, -0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } }, +/// { { 0.0f, 0.5f, 0.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } } +/// }; +/// +/// glVertexAttribPointer(m_aPosition, 3, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, position))); +/// glEnableVertexAttribArray(m_aPosition); +/// +/// glVertexAttribPointer(m_aColor, 4, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, color))); +/// glEnableVertexAttribArray(m_aColor); +/// ~~~~~~~~~~~~~~~~~ + +#if HAS_GL +#define GL_TYPE_STRING "GL" +// always define GL_GLEXT_PROTOTYPES before include gl headers +#if !defined(GL_GLEXT_PROTOTYPES) +#define GL_GLEXT_PROTOTYPES +#endif +#if defined(TARGET_LINUX) +#include +#include +#elif defined(TARGET_FREEBSD) +#include +#elif defined(TARGET_DARWIN) +#include +#include +#elif defined(WIN32) +#error Use of GL under Windows is not possible +#endif +#elif HAS_GLES >= 2 +#define GL_TYPE_STRING "GLES" +#if defined(WIN32) +#if defined(HAS_ANGLE) +#include +#else +#error Use of GLES only be available under Windows by the use of angle +#endif +#elif defined(TARGET_DARWIN) +#if HAS_GLES == 3 +#include +#include +#else +#include +#include +#endif +#else +#if HAS_GLES == 3 +#include +#include +#else +#include +#include +#endif +#endif +#endif + +#ifndef BUFFER_OFFSET +/// @ingroup cpp_kodi_gui_helpers_gl +/// @brief To give a offset number as pointer value. +#define BUFFER_OFFSET(i) ((char*)nullptr + (i)) +#endif + +#endif /* __cplusplus */ -- cgit v1.2.3