ソースを参照

* added app.d

* added package.d in all packages
Zoadian 12 年 前
コミット
317400ac02
4 ファイル変更93 行追加0 行削除
  1. 48 0
      source/app.d
  2. 3 0
      source/three/gfx/package.d
  3. 35 0
      source/three/init.d
  4. 7 0
      source/three/package.d

+ 48 - 0
source/app.d

@@ -0,0 +1,48 @@
+import std.stdio;
+
+import three;
+import std.typecons;
+
+class Tester {
+	Window _window;
+	bool _keepRunning = true;
+	
+	this() {
+		this._window = initThree();
+		this._window.onKey.connect!"_onKey"(this);
+		this._window.onClose.connect!"_onClose"(this);
+	}
+	
+	~this() {
+		_window.destroy();
+		deinitThree();
+	}
+	
+	void run() {
+		while(this._keepRunning) {
+			updateWindows();
+		}
+	}
+	
+	void stop() {
+		this._keepRunning = false;
+	}
+	
+	void _onKey(Window window, Key key, ScanCode scanCode, KeyAction action, KeyMod keyMod) {
+		if(window is _window && action == KeyAction.Pressed) {
+			if(key == Key.Escape) {
+				this.stop();
+			}
+		}
+	}
+
+	void _onClose(Window window) {
+		this.stop();
+	}
+}
+
+
+void main() {
+	Unique!(Tester) tester = new Tester();	
+	tester.run();
+}

+ 3 - 0
source/three/gfx/package.d

@@ -0,0 +1,3 @@
+module three.gfx;
+
+public import three.gfx.color;

+ 35 - 0
source/three/init.d

@@ -0,0 +1,35 @@
+module three.init;
+
+import derelict.opengl3.gl3;
+import derelict.glfw3.glfw3;
+//import derelict.freetype.ft;
+
+import three.glfw.window;
+
+import std.stdio;
+import std.conv;
+
+Window initThree() {
+	DerelictGL3.load();
+	DerelictGLFW3.load();
+	//DerelictFT.load();
+	
+	//~ if(!freeTypeInit()) throw new Exception("FreeType init failed");
+	if(!glfwInit()) throw new Exception("GLFW init failed");
+	
+	auto window = new Window("Fray", 1024, 768);
+	
+	try {
+		GLVersion glVersion = DerelictGL3.reload();
+		writeln("Loaded OpenGL Version", to!string(glVersion));
+	} catch(Exception e) {
+		writeln("exception: "~ e.msg);
+	}
+
+	return window;
+}
+
+void deinitThree() {
+	glfwTerminate();	 
+	//freeTypeDeinit();
+}

+ 7 - 0
source/three/package.d

@@ -0,0 +1,7 @@
+module three;
+
+public import three.gfx;
+public import three.gl;
+public import three.glfw;
+public import three.primitives;
+public import three.init;