提交 b2790d52 编写于 作者: A Alex Goldring

Refactored WebGLRendererDebug into a separate object

Took 30 minutes
上级 3eb5a9d4
......@@ -92,13 +92,9 @@
Default is *true*.
</p>
<h3>[property:Boolean programCheckEnabled]</h3>
<h3>[property:WebGLRendererDebug debug]</h3>
<p>
If [page:.programCheckEnabled programCheckEnabled] is true, defines whether material shader programs are checked
for errors during compilation and linkage process. It may be useful to disable this check in production for performance gain.
It is strongly recommended to keep these checks enabled during development.
If the shader does not compile and link - it will not work and associated material will not render.
Default is *true*.
Contains debug configuration of the renderer
</p>
<h3>[property:Object capabilities]</h3>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<base href="../../../"/>
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css"/>
</head>
<body>
<h1>[name]</h1>
<p class="desc">
The debug configuration container for WebGLRenderer
</p>
<h2>Properties</h2>
<h3>[property:Boolean checkShaderErrors]</h3>
<p>
If [page:.checkShaderErrors checkShaderErrors] is true, defines whether material shader programs are checked
for errors during compilation and linkage process. It may be useful to disable this check in production for performance gain.
It is strongly recommended to keep these checks enabled during development.
If the shader does not compile and link - it will not work and associated material will not render.
Default is *true*.
</p>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>
......@@ -79,13 +79,9 @@
默认是*true*
</p>
<h3>[property:Boolean programCheckEnabled]</h3>
<h3>[property:WebGLRendererDebug debug]</h3>
<p>
如果[page:.programCheckEnabled programCheckEnabled]为true,定义是否检查材质着色器程序
编译和链接过程中的错误。 禁用此检查生产以获得性能增益可能很有用。
强烈建议在开发期间保持启用这些检查。
如果着色器没有编译和链接 - 它将无法工作,并且相关材料将不会呈现。
默认是*true*
包含渲染器的调试配置。
</p>
<h3>[property:Object capabilities]</h3>
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<base href="../../../"/>
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css"/>
</head>
<body>
<h1>[name]</h1>
<p class="desc">
The debug configuration container for WebGLRenderer
</p>
<h2>Properties</h2>
<h3>[property:Boolean checkShaderErrors]</h3>
<p>
如果[page:.checkShaderErrors checkShaderErrors]为true,定义是否检查材质着色器程序
编译和链接过程中的错误。 禁用此检查生产以获得性能增益可能很有用。
强烈建议在开发期间保持启用这些检查。
如果着色器没有编译和链接 - 它将无法工作,并且相关材料将不会呈现。
默认是*true*
</p>
<h2>Source</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html>
......@@ -36,6 +36,7 @@ import { WebGLPrograms } from './webgl/WebGLPrograms.js';
import { WebGLProperties } from './webgl/WebGLProperties.js';
import { WebGLRenderLists } from './webgl/WebGLRenderLists.js';
import { WebGLRenderStates } from './webgl/WebGLRenderStates.js';
import { WebGLRendererDebug } from "./WebGLRendererDebug.js";
import { WebGLShadowMap } from './webgl/WebGLShadowMap.js';
import { WebGLState } from './webgl/WebGLState.js';
import { WebGLTextures } from './webgl/WebGLTextures.js';
......@@ -77,11 +78,7 @@ function WebGLRenderer( parameters ) {
this.domElement = _canvas;
this.context = null;
/**
* Enables error checking and reporting when shader programs are being compiled
* @type {boolean}
*/
this.programCheckEnabled = true;
this.debug = new WebGLRendererDebug();
// clearing
......
/**
* @author Alex Goldring | https://github.com/Usnul
*/
function WebGLRendererDebug() {
/**
* Enables error checking and reporting when shader programs are being compiled
* @type {boolean}
*/
this.checkShaderErrors = true;
}
export { WebGLRendererDebug };
......@@ -583,8 +583,8 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters,
// console.log( '*VERTEX*', vertexGlsl );
// console.log( '*FRAGMENT*', fragmentGlsl );
var glVertexShader = WebGLShader( gl, gl.VERTEX_SHADER, vertexGlsl, renderer.programCheckEnabled );
var glFragmentShader = WebGLShader( gl, gl.FRAGMENT_SHADER, fragmentGlsl, renderer.programCheckEnabled );
var glVertexShader = WebGLShader( gl, gl.VERTEX_SHADER, vertexGlsl, renderer.debug.checkShaderErrors );
var glFragmentShader = WebGLShader( gl, gl.FRAGMENT_SHADER, fragmentGlsl, renderer.debug.checkShaderErrors );
gl.attachShader( program, glVertexShader );
gl.attachShader( program, glFragmentShader );
......@@ -604,8 +604,8 @@ function WebGLProgram( renderer, extensions, code, material, shader, parameters,
gl.linkProgram( program );
if ( renderer.programCheckEnabled ){
// check for link errors
// check for link errors
if ( renderer.debug.checkShaderErrors ) {
var programLog = gl.getProgramInfoLog( program ).trim();
var vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();
......
export class WebGLShader {
constructor(gl: any, type: string, string: string, checkProgram: boolean);
constructor(gl: any, type: string, string: string, debug: boolean);
}
......@@ -16,14 +16,14 @@ function addLineNumbers( string ) {
}
function WebGLShader( gl, type, string, checkProgram ) {
function WebGLShader( gl, type, string, debug ) {
var shader = gl.createShader( type );
gl.shaderSource( shader, string );
gl.compileShader( shader );
if ( checkProgram === true ) {
if ( debug === true ) {
if ( gl.getShaderParameter( shader, gl.COMPILE_STATUS ) === false ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册