add fps calc

This commit is contained in:
jerrywwl
2019-04-02 18:16:16 +08:00
parent ec24cebf06
commit fc645bd8dc
2 changed files with 19 additions and 1 deletions
+18
View File
@@ -56,6 +56,14 @@ export class Root {
return this._frameTime;
}
public get frameCount (): number {
return this._frameCount;
}
public get fps (): number {
return this._fps;
}
public _createSceneFun;
public _createViewFun;
@@ -68,6 +76,9 @@ export class Root {
private _scenes: RenderScene[] = [];
private _views: RenderView[] = [];
private _frameTime: number = 0;
private _fpsTime: number = 0;
private _frameCount: number = 0;
private _fps: number = 0;
constructor (device: GFXDevice) {
this._device = device;
@@ -152,6 +163,13 @@ export class Root {
public frameMove (deltaTime: number) {
this._frameTime = deltaTime;
++this._frameCount;
this._fpsTime += this._frameTime;
if (this._fpsTime > 1.0) {
this._fps = this._frameCount;
this._frameCount = 0;
this._fpsTime = 0.0;
}
for (const view of this._views) {
if (view.isEnable && view.window === this._mainWindow) {
+1 -1
View File
@@ -1441,7 +1441,7 @@ export function WebGLCmdFuncExecuteCmds (device: WebGLGFXDevice, cmdPackage: Web
switch (curGPURenderPass.depthStencilAttachment.stencilLoadOp) {
case GFXLoadOp.LOAD: break; // GL default behaviour
case GFXLoadOp.CLEAR: {
if (cmd0.clearFlag & GFXClearFlag.DEPTH) {
if (cmd0.clearFlag & GFXClearFlag.STENCIL) {
if (!cache.dss.stencilWriteMaskFront) {
gl.stencilMaskSeparate(WebGLRenderingContext.FRONT, 0xFFFFFFFF);
}