YourGameLib
Loading...
Searching...
No Matches
gl_include.h
Go to the documentation of this file.
1/*
2Copyright (c) 2019-2024 Alexander Scholz
3
4This software is provided 'as-is', without any express or implied
5warranty. In no event will the authors be held liable for any damages
6arising from the use of this software.
7
8Permission is granted to anyone to use this software for any purpose,
9including commercial applications, and to alter it and redistribute it
10freely, subject to the following restrictions:
11
121. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
162. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
183. This notice may not be removed or altered from any source distribution.
19*/
20
21/*
22usage:
23make sure _exactly_ one of these macros is defined
24 YOURGAME_GL_INCLUDE_GLES1
25 YOURGAME_GL_INCLUDE_GLES2
26 YOURGAME_GL_INCLUDE_GLES3
27 YOURGAME_GL_INCLUDE_GLES31
28 YOURGAME_GL_INCLUDE_GLES32
29 YOURGAME_GL_INCLUDE_GLEW
30 YOURGAME_GL_INCLUDE_GL3W
31 YOURGAME_GL_INCLUDE_GLAD
32
33wherever gl is required:
34 #include "gl_include.h"
35
36do not include any other gl headers before or after gl_include.h
37*/
38#ifndef YOURGAME_GL_INCLUDE_H
39#define YOURGAME_GL_INCLUDE_H
40
41#if defined(GL_TRUE) // assuming GL_TRUE is (only) defined in some gl header
42#error gl header is already included
43#elif defined(YOURGAME_GL_INCLUDE_GLES1)
44#include <GLES/gl.h>
45#elif defined(YOURGAME_GL_INCLUDE_GLES2)
46#include <GLES2/gl2.h>
47#elif defined(YOURGAME_GL_INCLUDE_GLES3)
48#include <GLES3/gl3.h>
49#elif defined(YOURGAME_GL_INCLUDE_GLES31)
50#include <GLES3/gl31.h>
51#elif defined(YOURGAME_GL_INCLUDE_GLES32)
52#include <GLES3/gl32.h>
53#elif defined(YOURGAME_GL_INCLUDE_GLEW)
54#include <GL/glew.h>
55#elif defined(YOURGAME_GL_INCLUDE_GL3W)
56#include <GL/gl3w.h>
57#elif defined(YOURGAME_GL_INCLUDE_GLAD)
58#include <glad/glad.h>
59#else
60#error no gl header included
61#endif
62
63/*
64to get a glsl version string defined:
65make sure _exactly_ one of these macros is defined
66 YOURGAME_GL_API_GL
67 YOURGAME_GL_API_GLES
68
69and the used gl (es) version with both
70 YOURGAME_GL_MAJOR and
71 YOURGAME_GL_MINOR
72*/
73#if defined(YOURGAME_GL_API_GL)
74#if (YOURGAME_GL_MAJOR == 2) && (YOURGAME_GL_MINOR == 0)
75#define YOURGAME_GLSL_VERSION_STRING "#version 110"
76#elif (YOURGAME_GL_MAJOR == 2) && (YOURGAME_GL_MINOR == 1)
77#define YOURGAME_GLSL_VERSION_STRING "#version 120"
78#elif (YOURGAME_GL_MAJOR == 3) && (YOURGAME_GL_MINOR == 0)
79#define YOURGAME_GLSL_VERSION_STRING "#version 130"
80#elif (YOURGAME_GL_MAJOR == 3) && (YOURGAME_GL_MINOR == 1)
81#define YOURGAME_GLSL_VERSION_STRING "#version 140"
82#elif (YOURGAME_GL_MAJOR == 3) && (YOURGAME_GL_MINOR == 2)
83#define YOURGAME_GLSL_VERSION_STRING "#version 150"
84#elif (YOURGAME_GL_MAJOR == 3) && (YOURGAME_GL_MINOR == 3)
85#define YOURGAME_GLSL_VERSION_STRING "#version 330"
86#elif (YOURGAME_GL_MAJOR == 4) && (YOURGAME_GL_MINOR == 0)
87#define YOURGAME_GLSL_VERSION_STRING "#version 400"
88#elif (YOURGAME_GL_MAJOR == 4) && (YOURGAME_GL_MINOR == 1)
89#define YOURGAME_GLSL_VERSION_STRING "#version 410"
90#elif (YOURGAME_GL_MAJOR == 4) && (YOURGAME_GL_MINOR == 2)
91#define YOURGAME_GLSL_VERSION_STRING "#version 420"
92#elif (YOURGAME_GL_MAJOR == 4) && (YOURGAME_GL_MINOR == 3)
93#define YOURGAME_GLSL_VERSION_STRING "#version 430"
94#elif (YOURGAME_GL_MAJOR == 4) && (YOURGAME_GL_MINOR == 4)
95#define YOURGAME_GLSL_VERSION_STRING "#version 440"
96#elif (YOURGAME_GL_MAJOR == 4) && (YOURGAME_GL_MINOR == 5)
97#define YOURGAME_GLSL_VERSION_STRING "#version 450"
98#elif (YOURGAME_GL_MAJOR == 4) && (YOURGAME_GL_MINOR == 6)
99#define YOURGAME_GLSL_VERSION_STRING "#version 460"
100#endif
101#elif defined(YOURGAME_GL_API_GLES)
102#if (YOURGAME_GL_MAJOR == 2) && (YOURGAME_GL_MINOR == 0)
103#define YOURGAME_GLSL_VERSION_STRING "#version 100"
104#elif (YOURGAME_GL_MAJOR == 3) && (YOURGAME_GL_MINOR == 0)
105#define YOURGAME_GLSL_VERSION_STRING "#version 300 es"
106#endif
107#endif
108
109#endif