-
Notifications
You must be signed in to change notification settings - Fork 34
Using GLVisualize with an different OpenGL context #94
Comments
This is not supported yet, but should be easy to integrate! What you need to do is to create construct a Screen, that works with the QML OpenGL context. You'll need to create a dictionary with at least these Signals (optional ones in brackets): framebuffer_size => Reactive.Signal{FixedSizeArrays.Vec{2,Int64}}
scroll => Reactive.Signal{FixedSizeArrays.Vec{2,Float64}}
hasfocus => Reactive.Signal{Bool}
keyboard_buttons => Reactive.Signal{Tuple{Int64,Int64,Int64,Int64}}
mouseinside => Reactive.Signal{Bool}
window_size => Reactive.Signal{FixedSizeArrays.Vec{2,Int64}}
(dropped_files => Reactive.Signal{Array{UTF8String,1}})
(unicode_input => Reactive.Signal{Array{Char,1}})
(cursor_position => Reactive.Signal{FixedSizeArrays.Vec{2,Float64}})
window_area => Reactive.Signal{GeometryTypes.SimpleRectangle{Int64}}
mouseposition => Reactive.Signal{FixedSizeArrays.Vec{2,Float64}}
window_open => Reactive.Signal{Bool}
(mouse2id => Reactive.Signal{GLWindow.SelectionID{Int64}}) # quite important though, but needs custom framebuffers so far
mouse_buttons => Reactive.Signal{Tuple{Int64,Int64,Int64}}
entered_window => Reactive.Signal{Bool}
window_position => Reactive.Signal{FixedSizeArrays.Vec{2,Int64}} Most of these come from: https://github.com/JuliaGL/GLWindow.jl/blob/master/src/callbacks.jl And then one needs to add an option to glscreen to pass through the QML context: |
OK, thanks, I'll look at how to implement these. Does the system support multiple views? I'm thinking of a use case like an X-Y-Z-perspective 3D editor. |
You can do this straightforward with multiple screens inside one gl context... Context switching is not supported yet, though... |
Here you have two cameras and two screens: |
I have started looking into this, getting the callbacks seems straightforward, but constructing the screen requires a |
Good to hear :) |
Allright, I have a first working example based on your Unfortunately, the 3D cat (commented in the example) comes up blank. One thing I am suspicious of is that I had to comment out these lines to get the lines2D to show: I think in my case these are set up by Qt, but I need to make GLVisualize aware of the correct buffers to use, somehow. In case you have time to look at this, all GLVisualize-related Julia code is here: The functions are called from C++ here: Note that if you want to test it you need to checkout CxxWrap, since I rely on unreleased features. edit: Forgot to mention that I adapted function set_root_screen(screen)
global ROOT_SCREEN = screen
end |
Very cool! :) |
The cat is spinning now. Turns out that it was just me accidentally passing a Float64 to the Float32 rotation matrix signal. This seems to have failed silently, unless I overlooked the error somewhere. Also, it seems |
Oh that's a stupid silent error... Sorry about that! I'd recommend checking out the master branches: Pkg.checkout("GLVisualize")
Pkg.checkout("GLAbstraction")
Pkg.checkout("GeometryTypes")
Pkg.checkout("GLWindow")
Pkg.checkout("Reactive")
Pkg.checkout("FixedSizeArrays") |
Simon: can I make you collaborator on MetaPkg so you keep that up to date? On Friday, September 30, 2016, Simon [email protected] wrote:
|
I updated to latest master, but I'm confused as to how the rotation matrix is updated. It seems not to work without the The same thing happens if I use a signal for the rotation as in the original example. Is there a way to update the rotation matrix directly? |
I guess your event loop is yield free then? context = visualize(...) # context is a tree structure nowadays. This was introduced to handle composed visualizations more uniformly
renderobject = context.children[1] # first child is usually the renderobject
renderoject.uniforms[:model] = Mat4f0(....)
render(window) |
Right, that works! The event loop is indeed yield-free, since it is actually the Qt event loop. I have now a direct example: And one with signals and yield: I find the direct version significantly more responsive to changes in the slider, especially when clicking somewhere on the slider, since this results in a single update that sometimes doesn't go through even with the yield. |
Interesting! Yeah there are still a lot of things to optimize with the event handling! And I'm not a 100% set on signals yet... But they're quite nice for a couple of reasons. If you have other models which work nicely for you, feel free to propose them :) |
From @barche
The text was updated successfully, but these errors were encountered: