MeshLib Documentation
Loading...
Searching...
No Matches
MRGladGlfw.h
Go to the documentation of this file.
1#pragma once
2
3#ifdef __EMSCRIPTEN__
4#include <GLES3/gl3.h>
5#else
6#include <glad/glad.h>
7#endif
8#include <GLFW/glfw3.h>
9#ifdef _WIN32
10#undef APIENTRY
11#endif
12
13#ifndef __EMSCRIPTEN__
14#define MR_GLSL_VERSION_LINE R"(#version 150)"
15#else
16#define MR_GLSL_VERSION_LINE R"(#version 300 es)"
17#endif
18
19namespace MR {
20
21// Load OpenGL and its extensions
22inline int loadGL()
23{
24#ifndef __EMSCRIPTEN__
25#pragma warning(push)
26#pragma warning(disable: 4191) //'type cast': unsafe conversion from 'GLFWglproc (__cdecl *)(const char *)' to 'GLADloadproc'
27 // thread_local here - because we have two windows in two different threads (main window and splash)
28 // so we need to be sure that each thread loaded gl (it can be called from GUI threads only)
29 //
30 // function is inline to be sure that each dll/so has its own instance of `loadRes`
31 static thread_local auto loadRes = gladLoadGLLoader( ( GLADloadproc )glfwGetProcAddress );
32 return loadRes;
33#pragma warning(pop)
34#else
35return 1;
36#endif
37}
38
39} //namespace MR
Definition MRCameraOrientationPlugin.h:8
int loadGL()
Definition MRGladGlfw.h:22