Skip to content

Commit

Permalink
fix runtime dispatch with clip planes
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer committed Nov 4, 2024
1 parent e118e41 commit 96d592f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions GLMakie/src/GLAbstraction/GLRender.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 96d592f

Please sign in to comment.