mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
add fps calc
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user