Diligent Engine API Reference
Graphics
GraphicsEngineOpenGL
include
pch.h
1
/* Copyright 2015-2018 Egor Yusov
2
*
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at
6
*
7
* http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
10
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
11
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF ANY PROPRIETARY RIGHTS.
12
*
13
* In no event and under no legal theory, whether in tort (including negligence),
14
* contract, or otherwise, unless required by applicable law (such as deliberate
15
* and grossly negligent acts) or agreed to in writing, shall any Contributor be
16
* liable for any damages, including any direct, indirect, special, incidental,
17
* or consequential damages of any character arising as a result of this License or
18
* out of the use or inability to use the software (including but not limited to damages
19
* for loss of goodwill, work stoppage, computer failure or malfunction, or any and
20
* all other commercial damages or losses), even if such Contributor has been advised
21
* of the possibility of such damages.
22
*/
23
24
// stdafx.h : include file for standard system include files,
25
// or project specific include files that are used frequently, but
26
// are changed infrequently
27
//
28
29
#pragma once
30
31
#include <vector>
32
33
#include <map>
34
#include <unordered_map>
35
#include <unordered_set>
36
#include <algorithm>
37
38
#if defined(PLATFORM_WIN32)
39
40
# ifndef GLEW_STATIC
41
# define GLEW_STATIC // Must be defined to use static version of glew
42
# endif
43
# include "GL/glew.h"
44
// Glew includes <windows.h>
45
# define NOMINMAX
46
# include "GL/wglew.h"
47
# include <GL/GL.h>
48
49
#elif defined(PLATFORM_LINUX)
50
51
# ifndef GLEW_STATIC
52
# define GLEW_STATIC // Must be defined to use static version of glew
53
# endif
54
# ifndef GLEW_NO_GLU
55
# define GLEW_NO_GLU
56
# endif
57
58
# include "GL/glew.h"
59
# include <GL/glx.h>
60
61
// Undefine beautiful defines from GL/glx.h -> X11/Xlib.h
62
# ifdef Bool
63
# undef Bool
64
# endif
65
# ifdef True
66
# undef True
67
# endif
68
# ifdef False
69
# undef False
70
# endif
71
# ifdef Status
72
# undef Status
73
# endif
74
# ifdef Success
75
# undef Success
76
# endif
77
78
# elif defined(PLATFORM_ANDROID)
79
80
# ifndef USE_GL3_STUB
81
# define USE_GL3_STUB 0
82
# endif
83
# if USE_GL3_STUB
84
# include "gl3stub.h"
85
# include <GLES2/gl2platform.h>
86
# else
87
# include <GLES3/gl3.h>
88
# include <GLES3/gl3ext.h>
89
# endif
90
91
#else
92
# error Unsupported platform
93
#endif
94
95
#include "Errors.h"
96
97
#ifdef PLATFORM_ANDROID
98
// GLStubs must be included after GLFeatures!
99
#include "GLStubs.h"
100
#endif
101
102
#include "PlatformDefinitions.h"
103
#include "RefCntAutoPtr.h"
104
#include "DebugUtilities.h"
105
#include "GLObjectWrapper.h"
106
#include "ValidatedCast.h"
107
#include "RenderDevice.h"
108
#include "BaseInterfacesGL.h"
109
110
#define CHECK_GL_ERROR(...)\
111
{ \
112
auto err = glGetError(); \
113
if( err != GL_NO_ERROR ) \
114
{ \
115
LogError<false>(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__, "\nGL Error Code: ", err); \
116
UNEXPECTED("Error"); \
117
} \
118
}
119
120
#define CHECK_GL_ERROR_AND_THROW(...)\
121
{ \
122
auto err = glGetError(); \
123
if( err != GL_NO_ERROR ) \
124
LogError<true>(__FUNCTION__, __FILE__, __LINE__, __VA_ARGS__, "\nGL Error Code: ", err); \
125
}