1 /* 2 __ 3 / _| 4 __ _ _ _ _ __ ___ _ __ __ _ | |_ ___ ___ ___ 5 / _` | | | | '__/ _ \| '__/ _` | | _/ _ \/ __/ __| 6 | (_| | |_| | | | (_) | | | (_| | | || (_) \__ \__ \ 7 \__,_|\__,_|_| \___/|_| \__,_| |_| \___/|___/___/ 8 9 Copyright (C) 2018-2019 Aurora Free Open Source Software. 10 11 This file is part of the Aurora Free Open Source Software. This 12 organization promote free and open source software that you can 13 redistribute and/or modify under the terms of the GNU Lesser General 14 Public License Version 3 as published by the Free Software Foundation or 15 (at your option) any later version approved by the Aurora Free Open Source 16 Software Organization. The license is available in the package root path 17 as 'LICENSE' file. Please review the following information to ensure the 18 GNU Lesser General Public License version 3 requirements will be met: 19 https://www.gnu.org/licenses/lgpl.html . 20 21 Alternatively, this file may be used under the terms of the GNU General 22 Public License version 3 or later as published by the Free Software 23 Foundation. Please review the following information to ensure the GNU 24 General Public License requirements will be met: 25 http://www.gnu.org/licenses/gpl-3.0.html. 26 27 NOTE: All products, services or anything associated to trademarks and 28 service marks used or referenced on this file are the property of their 29 respective companies/owners or its subsidiaries. Other names and brands 30 may be claimed as the property of others. 31 32 For more info about intellectual property visit: aurorafoss.org or 33 directly send an email to: contact (at) aurorafoss.org . 34 */ 35 36 module aurorafw.graphics.api.context; 37 38 import aurorafw.graphics.api.opengl.context : GLContext; 39 import aurorafw.graphics.api.vulkan.context : VKContext; 40 import aurorafw.gui.window; 41 42 abstract class Context { 43 enum RenderAPI { 44 OpenGL, 45 Direct3D, 46 Vulkan 47 } 48 49 enum RenderAPIVersion : uint { 50 Unknown = 0, 51 GL_2_0, 52 GL_2_1, 53 GL_3_0, 54 GL_3_1, 55 GL_3_2, 56 GL_3_3, 57 GL_3_3_CORE 58 } 59 60 static void create(WindowProperties wp, string name) 61 { 62 switch(getRenderAPI()) 63 { 64 case RenderAPI.OpenGL: _instance = new GLContext(wp); break; 65 case RenderAPI.Vulkan: _instance = new VKContext(name); break; 66 default: assert(0); 67 } 68 } 69 70 static void init(Window win) 71 { 72 _instance._init(win); 73 } 74 75 static void destroy() 76 { 77 _instance._destroy(); 78 } 79 80 pragma(inline) static RenderAPI getRenderAPI() 81 { 82 return _rapi; 83 } 84 85 pragma(inline) static RenderAPIVersion getAPIVersion() 86 { 87 return _version; 88 } 89 90 pragma(inline) static void setRenderAPI(RenderAPI api) 91 { 92 _rapi = api; 93 } 94 95 protected: 96 void _init(Window ); 97 void _destroy(); 98 99 static Context _instance; 100 static RenderAPI _rapi = RenderAPI.OpenGL; 101 static RenderAPIVersion _version; 102 }