1 module evael.Init; 2 3 import std.experimental.logger; 4 5 import evael.graphics.GL; 6 7 import derelict.freeimage.freeimage; 8 import derelict.freetype.ft; 9 import derelict.glfw3.glfw3; 10 import derelict.util.exception; 11 import derelict.nanovg.nanovg; 12 import derelict.openal.al; 13 import derelict.sndfile.sndfile; 14 15 /** 16 * Initializes external libs. 17 */ 18 void loadExternalLibraries() 19 { 20 debug info("Initializing derelict..."); 21 22 DerelictGL3.load(); 23 DerelictGLFW3.load(); 24 DerelictFI.missingSymbolCallback = &handleDerelictsProblems; 25 DerelictFI.load(); 26 DerelictFT.missingSymbolCallback = &handleDerelictsProblems; 27 DerelictFT.load(); 28 DerelictAL.load(); 29 DerelictSndFile.load(); 30 31 if (!glfwInit()) 32 { 33 error("Error when calling glfwInit()."); 34 assert(0, "Error when calling glfwInit()"); 35 } 36 } 37 38 void unloadExternalLibraries() 39 { 40 debug info("Unloading derelict..."); 41 42 DerelictGLFW3.unload(); 43 DerelictGL3.unload(); 44 DerelictFT.unload(); 45 DerelictFI.unload(); 46 DerelictNANOVG.unload(); 47 DerelictSndFile.unload(); 48 DerelictAL.unload(); 49 50 glfwTerminate(); 51 } 52 53 ShouldThrow handleDerelictsProblems(string symbolName) 54 { 55 debug warningf("Failed to load %s, ignoring this.", symbolName); 56 return ShouldThrow.No; 57 }