Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/Graphics/GraphicsEngineOpenGL/include/GLContextAndroid.h Source File

Diligent Engine API Reference

GLContextAndroid.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 #pragma once
25
26 #include <EGL/egl.h>
27 #include <android/native_window.h>
28
29 namespace Diligent
30 {
31 struct ContextInitInfo
32 {
33 SwapChainDesc SwapChainAttribs;
34 void *pNativeWndHandle = nullptr;
35 };
36
37 class GLContext
38 {
39 public:
40 typedef EGLContext NativeGLContextType;
41
42 GLContext( const ContextInitInfo &Info, DeviceCaps &DeviceCaps );
43 ~GLContext();
44
45 bool Init( ANativeWindow* window );
46
47 void SwapBuffers();
48
49 bool Invalidate();
50
51 void Suspend();
52 EGLint Resume( ANativeWindow* window );
53
54 const SwapChainDesc& GetSwapChainDesc()const{ return SwapChainAttribs_; }
55
56 NativeGLContextType GetCurrentNativeGLContext();
57
58 private:
59 //EGL configurations
60 ANativeWindow* window_ = nullptr;
61 EGLDisplay display_ = EGL_NO_DISPLAY;
62 EGLSurface surface_ = EGL_NO_SURFACE;
63 EGLContext context_ = EGL_NO_CONTEXT;
64 EGLConfig config_;
65
66 //Screen parameters
67 int32_t color_size_ = 0;
68 int32_t depth_size_ = 0;
69 int32_t major_version_ = 0;
70 int32_t minor_version_ = 0;
71
72 //Flags
73 bool gles_initialized_ = false;
74 bool egl_context_initialized_ = false;
75 bool context_valid_ = false;
76
77 SwapChainDesc SwapChainAttribs_;
78
79 void InitGLES();
80 void Terminate();
81 bool InitEGLSurface();
82 bool InitEGLContext();
83 void AttachToCurrentEGLContext();
84 void FillDeviceCaps( DeviceCaps &DeviceCaps );
85 };
86 }
Diligent
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34