Overte C++ Documentation
GLContext.h
1 //
2 //
3 // Created by Bradley Austin Davis on 2018/11/15
4 // Copyright 2013-2018 High Fidelity, Inc.
5 //
6 // Distributed under the Apache License, Version 2.0.
7 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
8 //
9 #pragma once
10 
11 #include <memory>
12 
13 #include <EGL/egl.h>
14 #include <glad/glad.h>
15 
16 namespace ovr {
17 
18 struct GLContext {
19  using Pointer = std::shared_ptr<GLContext>;
20  EGLSurface surface{ EGL_NO_SURFACE };
21  EGLContext context{ EGL_NO_CONTEXT };
22  EGLDisplay display{ EGL_NO_DISPLAY };
23 
24  ~GLContext();
25  static EGLConfig findConfig(EGLDisplay display);
26  bool makeCurrent();
27  void doneCurrent();
28  bool create(EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY), EGLContext shareContext = EGL_NO_CONTEXT, bool noError = false);
29  void destroy();
30  operator bool() const { return context != EGL_NO_CONTEXT; }
31  static void initModule();
32 };
33 
34 }
35 
36 
37 #define CHECK_GL_ERROR() if(false) {}