From a9126c9ec1eb111217b7d16968b512349269377f Mon Sep 17 00:00:00 2001 From: ffreyer Date: Mon, 18 Sep 2023 18:34:27 +0200 Subject: [PATCH] fix struct uniforms --- GLMakie/src/GLAbstraction/GLTypes.jl | 4 +++- GLMakie/src/GLAbstraction/GLUniforms.jl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/GLMakie/src/GLAbstraction/GLTypes.jl b/GLMakie/src/GLAbstraction/GLTypes.jl index 0ff76b5f381..ce44d527b2b 100644 --- a/GLMakie/src/GLAbstraction/GLTypes.jl +++ b/GLMakie/src/GLAbstraction/GLTypes.jl @@ -423,8 +423,10 @@ function RenderObject( else k in (:indices, :visible, :ssao, :label, :cycle) && continue # structs are treated differently, since they have to be composed into their fields + # NOTE that merge!(data, ...) will break the iteration, so struct uniforms must + # be added after this iteration if isa_gl_struct(v) - merge!(data, gl_convert_struct(v, k)) + merge!(passthrough, gl_convert_struct(v, k)) elseif applicable(gl_convert, v) # if can't be converted to an OpenGL datatype, try data[k] = gl_convert(v) diff --git a/GLMakie/src/GLAbstraction/GLUniforms.jl b/GLMakie/src/GLAbstraction/GLUniforms.jl index 17f83cc7ec8..aebbbd9d330 100644 --- a/GLMakie/src/GLAbstraction/GLUniforms.jl +++ b/GLMakie/src/GLAbstraction/GLUniforms.jl @@ -213,7 +213,7 @@ function isa_gl_struct(x::T) where T end function gl_convert_struct(x::T, uniform_name::Symbol) where T if isa_gl_struct(x) - return Dict{Symbol, Any}(map(fieldnames(x)) do name + return Dict{Symbol, Any}(map(fieldnames(T)) do name (Symbol("$uniform_name.$name") => gl_convert(getfield(x, name))) end) else