summaryrefslogtreecommitdiffstats
path: root/xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h
diff options
context:
space:
mode:
Diffstat (limited to 'xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h')
-rw-r--r--xbmc/addons/kodi-dev-kit/include/kodi/gui/gl/GL.h112
1 files changed, 112 insertions, 0 deletions
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 @@
1/*
2 * Copyright (C) 2005-2019 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#pragma once
10
11#ifdef __cplusplus
12
13//==============================================================================
14/// @defgroup cpp_kodi_gui_helpers_gl OpenGL helpers
15/// @ingroup cpp_kodi_gui_helpers
16/// @brief **Auxiliary functions for Open GL**\n
17/// This group includes help for definitions, functions, and classes for
18/// OpenGL.
19///
20/// To use OpenGL for your system, add the @ref GL.h "#include <kodi/gui/gl/GL.h>".
21///
22/// The @ref HAS_GL is declared if Open GL is required and @ref HAS_GLES if Open GL
23/// Embedded Systems (ES) is required, with ES the version is additionally given
24/// in the definition, this can be "2" or "3".
25///
26///
27///-----------------------------------------------------------------------------
28///
29/// Following @ref GL_TYPE_STRING define can be used, for example, to manage
30/// different folders for GL and GLES and make the selection easier.
31/// This are on OpenGL <b>"GL"</b> and on Open GL|ES <b>"GLES"</b>.
32///
33/// **Example:**
34/// ~~~~~~~~~~~~~~~~~{.cpp}
35/// kodi::GetAddonPath("resources/shaders/" GL_TYPE_STRING "/frag.glsl");
36/// ~~~~~~~~~~~~~~~~~
37///
38///
39///----------------------------------------------------------------------------
40///
41/// In addition, @ref BUFFER_OFFSET is declared in it which can be used to give an
42/// offset on the array to GL.
43///
44/// **Example:**
45/// ~~~~~~~~~~~~~~~~~{.cpp}
46/// const struct PackedVertex {
47/// float position[3]; // Position x, y, z
48/// float color[4]; // Color r, g, b, a
49/// } vertices[3] = {
50/// { { -0.5f, -0.5f, 0.0f }, { 1.0f, 0.0f, 0.0f, 1.0f } },
51/// { { 0.5f, -0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f, 1.0f } },
52/// { { 0.0f, 0.5f, 0.0f }, { 0.0f, 0.0f, 1.0f, 1.0f } }
53/// };
54///
55/// glVertexAttribPointer(m_aPosition, 3, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, position)));
56/// glEnableVertexAttribArray(m_aPosition);
57///
58/// glVertexAttribPointer(m_aColor, 4, GL_FLOAT, GL_FALSE, sizeof(PackedVertex), BUFFER_OFFSET(offsetof(PackedVertex, color)));
59/// glEnableVertexAttribArray(m_aColor);
60/// ~~~~~~~~~~~~~~~~~
61
62#if HAS_GL
63#define GL_TYPE_STRING "GL"
64// always define GL_GLEXT_PROTOTYPES before include gl headers
65#if !defined(GL_GLEXT_PROTOTYPES)
66#define GL_GLEXT_PROTOTYPES
67#endif
68#if defined(TARGET_LINUX)
69#include <GL/gl.h>
70#include <GL/glext.h>
71#elif defined(TARGET_FREEBSD)
72#include <GL/gl.h>
73#elif defined(TARGET_DARWIN)
74#include <OpenGL/gl3.h>
75#include <OpenGL/gl3ext.h>
76#elif defined(WIN32)
77#error Use of GL under Windows is not possible
78#endif
79#elif HAS_GLES >= 2
80#define GL_TYPE_STRING "GLES"
81#if defined(WIN32)
82#if defined(HAS_ANGLE)
83#include <angle_gl.h>
84#else
85#error Use of GLES only be available under Windows by the use of angle
86#endif
87#elif defined(TARGET_DARWIN)
88#if HAS_GLES == 3
89#include <OpenGLES/ES3/gl.h>
90#include <OpenGLES/ES3/glext.h>
91#else
92#include <OpenGLES/ES2/gl.h>
93#include <OpenGLES/ES2/glext.h>
94#endif
95#else
96#if HAS_GLES == 3
97#include <GLES3/gl3.h>
98#include <GLES3/gl3ext.h>
99#else
100#include <GLES2/gl2.h>
101#include <GLES2/gl2ext.h>
102#endif
103#endif
104#endif
105
106#ifndef BUFFER_OFFSET
107/// @ingroup cpp_kodi_gui_helpers_gl
108/// @brief To give a offset number as pointer value.
109#define BUFFER_OFFSET(i) ((char*)nullptr + (i))
110#endif
111
112#endif /* __cplusplus */