瀏覽代碼

correctly implement antiAliasing in JS/Stage3D

Nicolas Cannasse 8 年之前
父節點
當前提交
1401c61b6d
共有 3 個文件被更改,包括 7 次插入5 次删除
  1. 3 2
      h3d/Engine.hx
  2. 2 2
      h3d/impl/GlDriver.hx
  3. 2 1
      h3d/impl/Stage3dDriver.hx

+ 3 - 2
h3d/Engine.hx

@@ -54,10 +54,11 @@ class Engine {
 		lastTime = haxe.Timer.stamp();
 		stage.addResizeEvent(onStageResize);
 		#if (js || cpp || hxsdl)
-		driver = new h3d.impl.GlDriver();
+		driver = new h3d.impl.GlDriver(antiAlias);
 		#elseif flash
-		driver = new h3d.impl.Stage3dDriver();
+		driver = new h3d.impl.Stage3dDriver(antiAlias);
 		#else
+		#if sys Sys.println #else trace #end("No output driver available.");
 		driver = new h3d.impl.LogDriver(new h3d.impl.NullDriver());
 		driver.logEnable = true;
 		#end

+ 2 - 2
h3d/impl/GlDriver.hx

@@ -122,11 +122,11 @@ class GlDriver extends Driver {
 	var shaderVersion : Null<Int>;
 	var firstShader = true;
 
-	public function new() {
+	public function new(antiAlias=0) {
 		#if js
 		canvas = @:privateAccess hxd.Stage.getCanvas();
 		if( canvas == null ) throw "Canvas #webgl not found";
-		gl = canvas.getContextWebGL({alpha:false});
+		gl = canvas.getContextWebGL({alpha:false,antialias:antiAlias>0});
 		if( gl == null ) throw "Could not acquire GL context";
 		// debug if webgl_debug.js is included
 		untyped if( __js__('typeof')(WebGLDebugUtils) != "undefined" ) gl = untyped WebGLDebugUtils.makeDebugContext(gl);

+ 2 - 1
h3d/impl/Stage3dDriver.hx

@@ -86,12 +86,13 @@ class Stage3dDriver extends Driver {
 	@:allow(h3d.impl.VertexWrapper)
 	var empty : flash.utils.ByteArray;
 
-	public function new() {
+	public function new(antiAlias=0) {
 		var v = flash.system.Capabilities.version.split(" ")[1].split(",");
 		flashVersion = Std.parseFloat(v[0] + "." + v[1]);
 		empty = new flash.utils.ByteArray();
 		s3d = flash.Lib.current.stage.stage3Ds[0];
 		programs = new Map();
+		this.antiAlias = antiAlias;
 		curTextures = [];
 		curSamplerBits = [];
 		curMultiBuffer = [];