-
Notifications
You must be signed in to change notification settings - Fork 1
/
imapp_opengl_loader.h
84 lines (76 loc) · 2.94 KB
/
imapp_opengl_loader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// imapp: OpenGL Loader
#pragma once
#include "imapp.h" // IMAPP_API
#if defined(IMAPP_SYSTEM_EMSCRIPTEN)
// OpenGL ES 2
#if defined(IMAPP_PLATFORM_SDL2)
#include <SDL_opengles2.h>
#elif defined(IMAPP_PLATFORM_GLFW)
// GLFW for emscripten
#endif
#elif defined(IMAPP_RENDERER_OPENGL3)
// About Desktop OpenGL function loaders:
// Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers.
// Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad).
// You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own.
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
#include <GL/gl3w.h> // Initialize with gl3wInit()
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
#include <GL/glew.h> // Initialize with glewInit()
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
#include <glad/glad.h> // Initialize with gladLoadGL()
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING2)
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
#include <glbinding/Binding.h> // Initialize with glbinding::Binding::initialize()
#include <glbinding/gl/gl.h>
using namespace gl;
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLBINDING3)
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
#include <glbinding/glbinding.h>// Initialize with glbinding::initialize()
#include <glbinding/gl/gl.h>
using namespace gl;
#else
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
#endif
#elif defined(IMAPP_RENDERER_OPENGL2)
// OpenGL 2 header from platform headers
#if defined(IMAPP_PLATFORM_SDL2)
#include <SDL_opengl.h>
#elif defined(IMAPP_PLATFORM_GLFW)
#ifdef __APPLE__
#define GL_SILENCE_DEPRECATION
#endif
#include <GLFW/glfw3.h>
#endif
#endif
// Decide GL+GLSL versions
#ifndef IMAPP_GLSL_VERSION
#ifdef __EMSCRIPTEN__
// For the browser using Emscripten, we are going to use WebGL1 with GL ES2. See the Makefile. for requirement details.
// It is very likely the generated file won't work in many browsers. Firefox is the only sure bet, but I have successfully
// run this code on Chrome for Android for example.
#define IMAPP_GLSL_VERSION "#version 100"
//#define IMAPP_GLSL_VERSION "#version 300 es"
#define IMAPP_GL_CONTEXT_MAJOR_VERSION 2
#define IMAPP_GL_CONTEXT_MINOR_VERSION 0
#elif defined(IMAPP_RENDERER_OPENGL2)
// GL 2.*
#define IMAPP_GLSL_VERSION "#version 100" // not use
#define IMAPP_GL_CONTEXT_MAJOR_VERSION 2
#define IMAPP_GL_CONTEXT_MINOR_VERSION 2
#elif __APPLE__
// GL 3.2 + GLSL 150
#define IMAPP_GLSL_VERSION "#version 150"
#define IMAPP_GL_CONTEXT_MAJOR_VERSION 3
#define IMAPP_GL_CONTEXT_MINOR_VERSION 2
#else
// GL 3.0 + GLSL 130
#define IMAPP_GLSL_VERSION "#version 130"
#define IMAPP_GL_CONTEXT_MAJOR_VERSION 3
#define IMAPP_GL_CONTEXT_MINOR_VERSION 0
#endif
#endif
namespace ImApp
{
IMAPP_API bool InitOpenGLLoader();
}