Skip to content

Commit

Permalink
add pollevents in colorbuffer & tweak render_tick priority
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer committed Sep 26, 2023
1 parent 0db721c commit f73ec38
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion GLMakie/src/drawing_primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function handle_lights(attr::Dict, screen::Screen, lights::Vector{Makie.Abstract
attr[:light_colors] = Observable(sizehint!(RGBf[], MAX_LIGHTS))
attr[:light_parameters] = Observable(sizehint!(Float32[], MAX_PARAMS))

on(screen.render_tick, priority = -1000) do _
on(screen.render_tick, priority = typemin(Int)) do _
# @info "$(length(lights)) lights."
n_lights = 0
n_params = 0
Expand Down
8 changes: 4 additions & 4 deletions GLMakie/src/events.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function (x::WindowAreaUpdater)(::Nothing)
x.dpi[] = minimum(props.dpi)
x.area[] = Recti(minimum(rect), w, h)
end
return
return Consume(false)
end

function Makie.window_area(scene::Scene, screen::Screen)
Expand All @@ -74,7 +74,7 @@ function Makie.window_area(scene::Scene, screen::Screen)
updater = WindowAreaUpdater(
to_native(screen), scene.events.window_dpi, scene.events.window_area
)
on(updater, screen.render_tick)
on(updater, screen.render_tick, priority = typemax(Int))

return
end
Expand Down Expand Up @@ -210,7 +210,7 @@ function (p::MousePositionUpdater)(::Nothing)
@print_error p.mouseposition[] = pos
# notify!(e.mouseposition)
end
return
return Consume(false)
end

"""
Expand All @@ -224,7 +224,7 @@ function Makie.mouse_position(scene::Scene, screen::Screen)
updater = MousePositionUpdater(
to_native(screen), scene.events.mouseposition, scene.events.hasfocus
)
on(updater, screen.render_tick)
on(updater, screen.render_tick, priority = typemax(Int))
return
end
function Makie.disconnect!(screen::Screen, ::typeof(mouse_position))
Expand Down
7 changes: 4 additions & 3 deletions GLMakie/src/screen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ mutable struct Screen{GLWindow} <: MakieScreen
cache::Dict{UInt64, RenderObject}
cache2plot::Dict{UInt32, AbstractPlot}
framecache::Matrix{RGB{N0f8}}
render_tick::Observable{Nothing}
render_tick::Observable{Nothing} # listeners must not Consume(true)
window_open::Observable{Bool}

root_scene::Union{Scene, Nothing}
Expand Down Expand Up @@ -417,8 +417,9 @@ end

function pollevents(screen::Screen)
ShaderAbstractions.switch_context!(screen.glscreen)
notify(screen.render_tick)
GLFW.PollEvents()
notify(screen.render_tick)
return
end

Base.wait(x::Screen) = !isnothing(x.rendertask) && wait(x.rendertask)
Expand Down Expand Up @@ -686,7 +687,7 @@ function Makie.colorbuffer(screen::Screen, format::Makie.ImageStorageFormat = Ma
ctex = screen.framebuffer.buffers[:color]
# polling may change window size, when its bigger than monitor!
# we still need to poll though, to get all the newest events!
# GLFW.PollEvents()
pollevents(screen)
# keep current buffer size to allows larger-than-window renders
render_frame(screen, resize_buffers=false) # let it render
if screen.config.visible
Expand Down

0 comments on commit f73ec38

Please sign in to comment.