From 96d592f9586ac63ff051fb7abc3db079f8db68a2 Mon Sep 17 00:00:00 2001 From: ffreyer Date: Mon, 4 Nov 2024 21:36:47 +0100 Subject: [PATCH] fix runtime dispatch with clip planes --- GLMakie/src/GLAbstraction/GLRender.jl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/GLMakie/src/GLAbstraction/GLRender.jl b/GLMakie/src/GLAbstraction/GLRender.jl index 357ce23781b..44bb5b5a59b 100644 --- a/GLMakie/src/GLAbstraction/GLRender.jl +++ b/GLMakie/src/GLAbstraction/GLRender.jl @@ -5,8 +5,7 @@ function render(list::Tuple) return end -function setup_clip_planes(robj) - N = to_value(get(robj.uniforms, :num_clip_planes, 0)) +function setup_clip_planes(N::Integer) for i in 0:min(7, N-1) glEnable(GL_CLIP_DISTANCE0 + UInt32(i)) end @@ -22,13 +21,13 @@ When rendering a specialised list of Renderables, we can do some optimizations function render(list::Vector{RenderObject{Pre}}) where Pre isempty(list) && return nothing first(list).prerenderfunction() - setup_clip_planes(first(list)) vertexarray = first(list).vertexarray program = vertexarray.program glUseProgram(program.id) bind(vertexarray) for renderobject in list renderobject.visible || continue # skip invisible + setup_clip_planes(to_value(get(renderobject.uniforms, :num_clip_planes, 0))) # make sure we only bind new programs and vertexarray when it is actually # different from the previous one if renderobject.vertexarray != vertexarray @@ -70,7 +69,7 @@ a lot of objects. function render(renderobject::RenderObject, vertexarray=renderobject.vertexarray) if renderobject.visible renderobject.prerenderfunction() - setup_clip_planes(renderobject) + setup_clip_planes(to_value(get(renderobject.uniforms, :num_clip_planes, 0))) program = vertexarray.program glUseProgram(program.id) for (key, value) in program.uniformloc