Forráskód Böngészése

Add new wireframe behavior when WEBGL_polygon_mode is available.
It might cause compilation issue if someone use haxe 5.0.0-alpha-1 without the latest version (the one with the extension) because checking a version was our best solution to static check if the extension is there.

borisrp 6 hónapja
szülő
commit
fdfe156969
1 módosított fájl, 17 hozzáadás és 2 törlés
  1. 17 2
      h3d/impl/GlDriver.hx

+ 17 - 2
h3d/impl/GlDriver.hx

@@ -824,8 +824,23 @@ class GlDriver extends Driver {
 			gl.polygonMode(GL.FRONT_AND_BACK, GL.FILL);
 		}
 		#else
-		// Not entirely accurate wireframe, but the best possible on WebGL.
-		drawMode = wireframe ? GL.LINE_STRIP : GL.TRIANGLES;
+
+		var fallback = true;
+		#if (haxe >= version("5.0.0-alpha.1"))
+		var extension:js.html.webgl.extension.WEBGLPolygonMode =  cast gl.getExtension("WEBGL_polygon_mode");
+		if(extension != null) {
+			if(wireframe) {
+				extension.polygonModeWEBGL(GL.FRONT_AND_BACK, js.html.webgl.extension.WEBGLPolygonMode.LINE_WEBGL);
+			} else {
+				extension.polygonModeWEBGL(GL.FRONT_AND_BACK, js.html.webgl.extension.WEBGLPolygonMode.FILL_WEBGL);
+			}
+			fallback = false;
+		}
+		#end
+
+		if(fallback) {
+			drawMode = wireframe ? GL.LINE_STRIP : GL.TRIANGLES;
+		}
 		#end
 
 		if( diff & Pass.culling_mask != 0 ) {