init.d 745 B

123456789101112131415161718192021222324252627282930313233343536
  1. module three.init;
  2. import derelict.opengl3.gl3;
  3. import derelict.glfw3.glfw3;
  4. //import derelict.freetype.ft;
  5. import three.glfw.window;
  6. import std.stdio;
  7. import std.conv;
  8. import std.typecons;
  9. Unique!(Window) initThree() {
  10. DerelictGL3.load();
  11. DerelictGLFW3.load();
  12. //DerelictFT.load();
  13. //~ if(!freeTypeInit()) throw new Exception("FreeType init failed");
  14. if(!glfwInit()) throw new Exception("GLFW init failed");
  15. Unique!(Window) window = new Window("Fray", 1024, 768);
  16. try {
  17. GLVersion glVersion = DerelictGL3.reload();
  18. writeln("Loaded OpenGL Version", to!string(glVersion));
  19. } catch(Exception e) {
  20. writeln("exception: "~ e.msg);
  21. }
  22. return window.release();
  23. }
  24. void deinitThree() {
  25. glfwTerminate();
  26. //freeTypeDeinit();
  27. }