MWE:
plot(rand(10), rand(10))
plot!(rand(10), rand(10), color = :red)
plot(rand(10), rand(10))
plot!(rand(10), rand(10), color = :red)
If one runs these 4 lines of code, a single makie window will be opened. The result of the first 2 lines of code are erased from the display, and replaced with the new ones. It is indeed possible to change displays, but the way I see it, there is no way to display all 4 of the above lines of code at the same time, i.e. having 2 displays open in parallel.
I think this is necessary.
that's absolutely not a bug and they're not discarded - the display just displays the most recent scene...
so this works:
scene = plot(rand(10), rand(10))
plot!(rand(10), rand(10), color = :red)
scene2 = plot(rand(10), rand(10))
plot!(rand(10), rand(10), color = :red)
display(scene)
display(scene2)
Alright, but still: the way I see it, having multiple _displays_ open in parallel is a necessity. I am editing the issue to reflect this.
I like the current behaviour, but it's useful of course to have the possibility of opening additional displays if you need them.
I would really like multiple windows in GLMakie.
I gave it a shot here:
https://github.com/goretkin/GLMakie.jl/tree/multiwin
import GLMakie
import GLMakie.ModernGL
import GLMakie.GLFW
import GLMakie: AbstractPlotting
objects = []
function report()
@show map(object->isopen(object.scene), objects)
end
function doit()
scene = Scene(; backgroundcolor = :green)
po = GLMakie.Node(rand(50))
AbstractPlotting.plot!(scene, po)
display(scene)
object = (scene=scene, po = po)
push!(objects, object)
nothing
end
empty!(objects)
GLMakie.destroy_all!()
GLMakie.window_behavior[] = :new
doit()
sleep(0.5)
doit()
The first time this runs, there are two plot windows. The first one shows the line plot, and the second one is blank (well, actually, it shows an animated solid color, just to verify the render loop is running).
That's already not right, since each plot window should show a line plot. Re-running the code in the same session destroys the two windows and produces two new ones with the solid color animation.
I tried to hunt down what was happening, but I don't follow every step. I can tell you that https://github.com/goretkin/GLMakie.jl/blob/2deb3dd8396842fdda80e27f9eb117e68b319623/src/GLAbstraction/GLRender.jl#L110 gets called with each of the two contexts.
@SimonDanisch mentioned on slack that there were some segfaults on previous attempts with multiwindow support. I think it would be worthwhile to try to get to that state, so that there's a chance someone (maybe even me) can debug it.
I think shader (re)compilation is broken on your branch.
I tried to mess with postprocessing/copy.frag to see what the stencil buffer is doing. I forgot a vec3 and got an error. On master you can fix the shader and reopen the scene to recompile it. On your branch I get a program 1 not linked. (It's also weird that this is program 1 - it was program 17 that failed before)
To reproduce:
Go into assets(shader/postprocessing/copy.frag and change fragment_color.rgb = color.rgb; to fragment_color.rgb = color.r;. On both branches it'll complain error C7011: implicit cast from "float" to "vec3" for any plot you make (probably also just Scene). Now reverse the change and rerun whatever plot you made.
Which is happening because GLAbstraction.empty_shader_cache!() is not being called anymore
With that back in the first window always shows a plot. The second does only if I change something in GLMakie's code and Revise does its thing.
Also, if I open two windows, then close the first one and open another, the second renders.
Idk why this is happening, but maybe it helps with figuring things out. Maybe it's related to switching contexts (maybe the @async in renderloop is messing things up?), or maybe the caching of shaders is an issue?
Seems like shader programs need to be per context. https://stackoverflow.com/questions/13574140/sharing-a-glprogram-among-multiple-opengl-es-contexts
Most helpful comment
I like the current behaviour, but it's useful of course to have the possibility of opening additional displays if you need them.