Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
better debug shader
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Jul 9, 2019
1 parent 8497bc9 commit ea40e05
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -5,4 +5,4 @@
/Manifest.toml
/docs/build/
/docs/site/
/debug/*
/debug/
6 changes: 2 additions & 4 deletions src/imagelike.jl
Expand Up @@ -25,8 +25,7 @@ function draw_mesh(jsctx, jsscene, mscene::Scene, mesh, name, plot; uniforms...)
VertexArray(mesh);
uniforms...
)
write(joinpath(@__DIR__, "..", "debug", "$(name).vert"), program.vertex_source)
write(joinpath(@__DIR__, "..", "debug", "$(name).frag"), program.fragment_source)
debug_shader(name, program)
three_geom = wgl_convert(mscene, jsctx, program)
update_model!(three_geom, plot)
three_geom.name = name
Expand Down Expand Up @@ -166,8 +165,7 @@ function draw_js(jsctx, jsscene, mscene::Scene, plot::Volume)
light_position = Vec3f0(20)
)

write(joinpath(@__DIR__, "..", "debug", "volume.vert"), program.vertex_source)
write(joinpath(@__DIR__, "..", "debug", "volume.frag"), program.fragment_source)
debug_shader("volume", program)

three_geom = wgl_convert(mscene, jsctx, program)
three_geom.matrixAutoUpdate = false
Expand Down
3 changes: 1 addition & 2 deletions src/lines.jl
Expand Up @@ -54,8 +54,7 @@ function draw_js(jsctx, jsscene, mscene::Scene, plot::LineSegments)
program = create_shader(mscene, plot)
mesh = wgl_convert(mscene, jsctx, program)
update_model!(mesh, plot)
write(joinpath(@__DIR__, "..", "debug", "linesegments.vert"), program.program.vertex_source)
write(joinpath(@__DIR__, "..", "debug", "linesegments.frag"), program.program.fragment_source)
debug_shader("linesegments", program.program)
mesh.name = "LineSegments"
jsscene.add(mesh)
end
Expand Down
4 changes: 1 addition & 3 deletions src/meshes.jl
Expand Up @@ -96,9 +96,7 @@ end
function draw_js(jsctx, jsscene, scene::Scene, plot::Mesh)
program = create_shader(scene, plot)
mesh = wgl_convert(scene, jsctx, program)

write(joinpath(@__DIR__, "..", "debug", "mesh.vert"), program.vertex_source)
write(joinpath(@__DIR__, "..", "debug", "mesh.frag"), program.fragment_source)
debug_shader("mesh", program)
mesh.name = "Mesh"
update_model!(mesh, plot)
jsscene.add(mesh)
Expand Down
7 changes: 2 additions & 5 deletions src/particles.jl
Expand Up @@ -204,8 +204,7 @@ function draw_js(jsctx, jsscene, scene::Scene, plot::MeshScatter)
end
function draw_js(jsctx, jsscene, scene::Scene, plot::AbstractPlotting.Text)
program = create_shader(scene, plot)
write(joinpath(@__DIR__, "..", "debug", "text.vert"), program.program.vertex_source)
write(joinpath(@__DIR__, "..", "debug", "text.frag"), program.program.fragment_source)
debug_shader("text", program.program)
mesh = wgl_convert(scene, jsctx, program)
mesh.name = "Text"
update_model!(mesh, plot)
Expand All @@ -215,9 +214,7 @@ function draw_js(jsctx, jsscene, scene::Scene, plot::Scatter)
program = create_shader(scene, plot)
mesh = wgl_convert(scene, jsctx, program)

write(joinpath(@__DIR__, "..", "debug", "scatter.vert"), program.program.vertex_source)
write(joinpath(@__DIR__, "..", "debug", "scatter.frag"), program.program.fragment_source)

debug_shader("scatter", program.program)
mesh.name = "Scatter"
update_model!(mesh, plot)
jsscene.add(mesh)
Expand Down
6 changes: 6 additions & 0 deletions src/webgl.jl
Expand Up @@ -291,6 +291,12 @@ function wgl_convert(scene, jsctx, program::Program)
end


function debug_shader(name, program)
dir = joinpath(@__DIR__, "..", "debug")
isdir(dir) || mkdir(dir)
write(joinpath(dir "$(name).frag"), program.fragment_source)
end

function update_model!(geom, plot)
geom.matrixAutoUpdate = false
geom.matrix.set(plot.model[]'...)
Expand Down

0 comments on commit ea40e05

Please sign in to comment.