Skip to content
Snippets Groups Projects
Commit f7238c9a authored by Alexander Rose's avatar Alexander Rose
Browse files

better handling of render program changes

parent a2fc6295
No related branches found
No related tags found
No related merge requests found
......@@ -137,7 +137,6 @@ export interface WebGLContext {
currentProgramId: number
currentMaterialId: number
currentRenderVariant: string
bufferCount: number
framebufferCount: number
......@@ -266,7 +265,6 @@ export function createContext(gl: GLRenderingContext): WebGLContext {
currentProgramId: -1,
currentMaterialId: -1,
currentRenderVariant: '',
bufferCount: 0,
framebufferCount: 0,
......
......@@ -130,6 +130,7 @@ export function createRenderItem(ctx: WebGLContext, drawMode: DrawMode, shaderCo
const valueChanges = createValueChanges()
let destroyed = false
let currentProgramId = -1
return {
id,
......@@ -140,13 +141,12 @@ export function createRenderItem(ctx: WebGLContext, drawMode: DrawMode, shaderCo
const program = programs[variant].value
const vertexArray = vertexArrays[variant]
program.setUniforms(uniformValueEntries)
if (ctx.currentRenderVariant !== variant) {
ctx.currentMaterialId = -1
ctx.currentRenderVariant = variant
}
if (materialId === -1 || materialId !== ctx.currentMaterialId) {
// console.log('materialId changed or -1', materialId)
if (program.id !== currentProgramId ||
materialId === -1 || materialId !== ctx.currentMaterialId
) {
// console.log('program.id changed or materialId changed/-1', materialId)
program.setUniforms(materialUniformValueEntries)
currentProgramId = program.id
ctx.currentMaterialId = materialId
}
program.bindTextures(textures)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment