Procházet zdrojové kódy

* use Unique and get rid of .destroy

Zoadian před 12 roky
rodič
revize
57bf14fc98
2 změnil soubory, kde provedl 7 přidání a 6 odebrání
  1. 3 3
      source/app.d
  2. 4 3
      source/three/init.d

+ 3 - 3
source/app.d

@@ -4,7 +4,7 @@ import three;
 import std.typecons;
 
 class Tester {
-	Window _window;
+	Unique!(Window) _window;
 	bool _keepRunning = true;
 	
 	this() {
@@ -14,7 +14,7 @@ class Tester {
 	}
 	
 	~this() {
-		_window.destroy();
+		//_window.destroy();
 		deinitThree();
 	}
 	
@@ -29,7 +29,7 @@ class Tester {
 	}
 	
 	void _onKey(Window window, Key key, ScanCode scanCode, KeyAction action, KeyMod keyMod) {
-		if(window is _window && action == KeyAction.Pressed) {
+		if(window is this._window.opDot() && action == KeyAction.Pressed) {
 			if(key == Key.Escape) {
 				this.stop();
 			}

+ 4 - 3
source/three/init.d

@@ -8,8 +8,9 @@ import three.glfw.window;
 
 import std.stdio;
 import std.conv;
+import std.typecons;
 
-Window initThree() {
+Unique!(Window) initThree() {
 	DerelictGL3.load();
 	DerelictGLFW3.load();
 	//DerelictFT.load();
@@ -17,7 +18,7 @@ Window initThree() {
 	//~ if(!freeTypeInit()) throw new Exception("FreeType init failed");
 	if(!glfwInit()) throw new Exception("GLFW init failed");
 	
-	auto window = new Window("Fray", 1024, 768);
+	Unique!(Window) window = new Window("Fray", 1024, 768);
 	
 	try {
 		GLVersion glVersion = DerelictGL3.reload();
@@ -26,7 +27,7 @@ Window initThree() {
 		writeln("exception: "~ e.msg);
 	}
 
-	return window;
+	return window.release();
 }
 
 void deinitThree() {