init.d 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. module three.init;
  2. import derelict.opengl3.gl3;
  3. import derelict.glfw3.glfw3;
  4. import derelict.anttweakbar.anttweakbar;
  5. import derelict.freeimage.freeimage;
  6. import derelict.freetype.ft;
  7. import derelict.assimp3.assimp;
  8. import three.glfw.window;
  9. import std.stdio;
  10. import std.conv;
  11. import std.typecons;
  12. private static FT_Library _s_freeTypeLibrary;
  13. Unique!(Window) initThree() {
  14. "Starting Three.d".writeln();
  15. "Loading OpenGL".writeln();
  16. DerelictGL3.load();
  17. "Loading GLFW".writeln();
  18. DerelictGLFW3.load();
  19. "Loading FreeImage".writeln();
  20. DerelictFI.load();
  21. // "Loading FreeType".writeln();
  22. // DerelictFT.load();
  23. "Loading Assimp".writeln();
  24. DerelictASSIMP3.load();
  25. "Loading AntTweakBar".writeln();
  26. DerelictAntTweakBar.load();
  27. "Initialising GLFW".writeln();
  28. if(!glfwInit()) throw new Exception("Initialising GLFW failed");
  29. "Creating Window".writeln();
  30. Unique!(Window) window = new Window("Fray", 1600, 900);
  31. "ReLoading OpenGL".writeln();
  32. try {
  33. GLVersion glVersion = DerelictGL3.reload();
  34. writeln("Loaded OpenGL Version", to!string(glVersion));
  35. } catch(Exception e) {
  36. writeln("exception: "~ e.msg);
  37. }
  38. // "Initialising FreeType".writeln();
  39. // if(!FT_Init_FreeType(&_s_freeTypeLibrary)) throw new Exception("Initialising FreeType failed");
  40. "Initialising AntTweakBar".writeln();
  41. if(TwInit(TW_OPENGL_CORE, null) == 0) throw new Exception("Initialising AntTweakBar failed");
  42. return window.release();
  43. }
  44. void deinitThree() {
  45. "Terminating AntTweakBar".writeln();
  46. TwTerminate();
  47. // "Terminating FreeType".writeln();
  48. // FT_Done_FreeType(_s_freeTypeLibrary);
  49. "Terminating GLFW".writeln();
  50. glfwTerminate();
  51. }