fix gl error

This commit is contained in:
jerrywwl
2019-01-02 18:46:33 +08:00
parent 94b7a588b3
commit 962ae81ab7
4 changed files with 28 additions and 17 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
import { GFXWindow, GFXWindowInfo } from "../gfx/window";
import { GFXDevice } from "../gfx/device";
import { RenderView, RenderViewInfo, RenderViewPriority } from "../pipeline/render-view";
import { RenderView, RenderViewInfo } from "../pipeline/render-view";
import { RenderPipeline } from "../pipeline/render-pipeline";
import { ForwardPipeline } from "../pipeline/forward/forward-pipeline";
import { RenderScene, RenderSceneInfo } from "../renderer/scene/render-scene";
@@ -50,7 +50,7 @@ export class Root {
for (let i = 0; i < this._views.length; ++i) {
let view = this._views[i];
if(view.isEnable() && view.isAttached) {
if (view.isEnable() && view.isAttached) {
(<RenderPipeline>this._pipeline).render(view);
}
}
@@ -89,7 +89,7 @@ export class Root {
public createScene(info: RenderSceneInfo): RenderScene | null {
let scene = new RenderScene;
if(scene.initialize(info)) {
if (scene.initialize(info)) {
this._scenes.push(scene);
return scene;
} else {
+10 -10
View File
@@ -697,25 +697,25 @@ export function GFXGetTypeSize(type: GFXType): number {
export function GFXGetAttributeBinding(name: string) : number {
if (name === GFX_ATTRIBUTE_POSITION) {
return 20;
return 6;
} else if (name === GFX_ATTRIBUTE_COLOR) {
return 21;
return 7;
} else if (name === GFX_ATTRIBUTE_COLOR1) {
return 22;
return 8;
} else if (name === GFX_ATTRIBUTE_NORMAL) {
return 23;
return 9;
} else if (name === GFX_ATTRIBUTE_TANGENT) {
return 24;
return 10;
} else if (name === GFX_ATTRIBUTE_BINORMAL) {
return 25;
return 11;
} else if (name === GFX_ATTRIBUTE_TEXCOORD) {
return 26;
return 12;
} else if (name === GFX_ATTRIBUTE_TEXCOORD1) {
return 27;
return 13;
} else if (name === GFX_ATTRIBUTE_JOINTS) {
return 28;
return 14;
} else if (name === GFX_ATTRIBUTE_WEIGHTS) {
return 29;
return 15;
} else {
return -1;
}
+11 -4
View File
@@ -31,7 +31,7 @@ import { WebGLGFXFramebuffer } from './webgl-framebuffer';
import { WebGLGFXInputAssembler } from './webgl-input-assembler';
import { GFXWindow, GFXWindowInfo } from '../window';
import { WebGLGFXWindow } from './webgl-window';
import { GFXBindingType, GFXFilter, GFXAddress, GFXTextureType, GFXTextureFlagBit, GFXTextureViewType, GFXBufferUsageBit } from '../gfx-define';
import { GFXBindingType, GFXFilter, GFXAddress, GFXTextureType, GFXTextureFlagBit, GFXTextureViewType, GFXBufferUsageBit, GFXQueueType } from '../gfx-define';
import { WebGLGFXBindingLayout } from './webgl-binding-layout';
const WebGLPrimitives: GLenum[] = [
@@ -145,6 +145,8 @@ export class WebGLGFXDevice extends GFXDevice {
this._OES_element_index_uint = this._webGLRC.getExtension("OES_element_index_uint");
this._ANGLE_instanced_arrays = this._webGLRC.getExtension("ANGLE_instanced_arrays");
this._queue = this.createQueue({ type: GFXQueueType.GRAPHICS });
// create primary window
this._mainWindow = this.createWindow({
title: this._webGLRC.canvas.title,
@@ -171,6 +173,11 @@ export class WebGLGFXDevice extends GFXDevice {
this._cmdAllocator = null;
}
if (this._queue) {
this._queue.destroy();
this._queue = null;
}
this._webGLRC = null;
}
@@ -476,8 +483,8 @@ export class WebGLGFXDevice extends GFXDevice {
public emitCmdCreateGPURenderPass(info: GFXRenderPassInfo): WebGLGPURenderPass {
let gpuRenderPass: WebGLGPURenderPass = {
objType: WebGLGPUObjectType.RENDER_PASS,
colorAttachments: info.colorAttachment? info.colorAttachment : [],
depthStencilAttachment: info.depthStencilAttachment? info.depthStencilAttachment : null,
colorAttachments: info.colorAttachment ? info.colorAttachment : [],
depthStencilAttachment: info.depthStencilAttachment ? info.depthStencilAttachment : null,
}
return gpuRenderPass;
@@ -585,7 +592,7 @@ export class WebGLGFXDevice extends GFXDevice {
gpuStages[i] = {
type: stage.type,
source: stage.source,
macros: stage.macros? stage.macros : [],
macros: stage.macros ? stage.macros : [],
glShader: 0,
};
}
+4
View File
@@ -151,6 +151,10 @@ export class RenderScene {
return this._cameras;
}
public get mainCamera(): Camera | null {
return this._mainCamera;
}
public get lights(): Light[] {
return this._lights;
}