From 89f9869fc790cd2134ef85b37075da0464d359b6 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Sun, 8 Dec 2019 01:39:54 +0100 Subject: [PATCH 1/3] use clear directly --- src/rendering.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rendering.jl b/src/rendering.jl index a1b5ff7..74eabe3 100644 --- a/src/rendering.jl +++ b/src/rendering.jl @@ -44,7 +44,7 @@ function setup!(screen) glViewport(rt...) bits = GL_STENCIL_BUFFER_BIT glClearStencil(id) - if scene.clear[] + if scene.clear c = to_color(scene.backgroundcolor[]) glScissor(rt...) glClearColor(red(c), green(c), blue(c), alpha(c)) @@ -135,7 +135,7 @@ function GLAbstraction.render(screen::Screen, fxaa::Bool) found || continue a = pixelarea(scene)[] glViewport(minimum(a)..., widths(a)...) - if scene.clear[] + if scene.clear glStencilFunc(GL_EQUAL, screenid, 0xff) else # if we don't clear, that means we have a screen that is overlaid From d181f15ad63d366f32e558b291faac28e3671e16 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Mon, 9 Dec 2019 13:52:55 +0100 Subject: [PATCH 2/3] get ready for taggin --- Project.toml | 45 ++++++------ src/GLMakie.jl | 5 +- src/GLVisualize/GLVisualize.jl | 12 ---- src/GLVisualize/visualize/image_like.jl | 91 ------------------------- 4 files changed, 23 insertions(+), 130 deletions(-) diff --git a/Project.toml b/Project.toml index 4e1e9ef..176d131 100644 --- a/Project.toml +++ b/Project.toml @@ -4,40 +4,37 @@ version = "0.0.8" [deps] AbstractPlotting = "537997a7-5e4e-5d89-9595-2241ea00577e" -AxisArrays = "39de3d68-74b9-583c-8d2d-e117c070f3a9" -ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" -ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4" Colors = "5ae59095-9a9b-59fe-a467-6f913c188581" +ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" +MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118" FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93" -FreeType = "b38be410-82b0-50bf-ab77-7b57e271db43" -FreeTypeAbstraction = "663a7486-cb36-511b-a19d-713bb74d65c9" -GLFW = "f7f18e0c-5ee9-5ccd-a5bf-e8befd85ed98" GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb" -ImageAxes = "2803e5a7-5153-5ecf-9a86-9b4c37f5f5ac" -ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534" -ImageFiltering = "6a3955dd-da59-5b1f-98d4-e7296123deb5" -ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" -ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795" -IndirectArrays = "9b13fd28-a010-5f03-acff-a1bbcff69959" -IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953" -IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e" +Observables = "510215fc-4207-5dde-b226-833fc4488ee2" +StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" + +GLFW = "f7f18e0c-5ee9-5ccd-a5bf-e8befd85ed98" +ModernGL = "66fc600b-dfda-50eb-8b99-91cfa97b1301" + LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" -MeshIO = "7269a6da-0436-5bbc-96c2-40638cbb6118" -ModernGL = "66fc600b-dfda-50eb-8b99-91cfa97b1301" -Observables = "510215fc-4207-5dde-b226-833fc4488ee2" Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7" Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b" -StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [compat] -julia = "≥ 1.0" -AbstractPlotting = ">=0.9.9" -FreeTypeAbstraction = ">=0.3.0" -GLFW = ">=2.3.0" -GeometryTypes = ">=0.7.2" -StaticArrays = ">=0.6.6" +julia = "1" +AbstractPlotting = "^0.9.11" +Colors = "0.9" +ColorTypes = "0.8" +FileIO = "^1.1" +MeshIO = "^0.3" +FixedPointNumbers = "0.6" +GeometryTypes = "^0.7.2" +Observables = "0.2.0" +StaticArrays = "0.6.6,0.7,0.8,0.9,0.10,0.11,0.12" + +GLFW = "^3" +ModernGL = "^1" [extras] Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" diff --git a/src/GLMakie.jl b/src/GLMakie.jl index d0b7cb5..caec934 100644 --- a/src/GLMakie.jl +++ b/src/GLMakie.jl @@ -1,14 +1,13 @@ module GLMakie using ModernGL, FixedPointNumbers, Colors, GeometryTypes, StaticArrays -using AbstractPlotting, FreeType, FreeTypeAbstraction, FileIO, IntervalSets -using ImageCore +using AbstractPlotting, FileIO using AbstractPlotting: @key_str, Key, broadcast_foreach, to_ndim, NativeFont using AbstractPlotting: Scene, Lines, Text, Image, Heatmap, Scatter using AbstractPlotting: convert_attribute, @extractvalue, LineSegments using AbstractPlotting: @get_attribute, to_value, to_colormap, extrema_nan -using IntervalSets: ClosedInterval, (..) +using AbstractPlotting: ClosedInterval, (..) using Base: RefValue import Base: push!, isopen, show diff --git a/src/GLVisualize/GLVisualize.jl b/src/GLVisualize/GLVisualize.jl index a4ea9a4..aa1e882 100644 --- a/src/GLVisualize/GLVisualize.jl +++ b/src/GLVisualize/GLVisualize.jl @@ -11,25 +11,13 @@ using Colors using AbstractPlotting using FixedPointNumbers using FileIO -using FreeType -import IterTools using Markdown -using FreeTypeAbstraction -using ImageCore -import ColorVectorSpace using Observables -import ImageCore -import AxisArrays, ImageAxes - import Base: merge, convert, show using Base.Iterators: Repeated, repeated using LinearAlgebra -using IndirectArrays -const HasAxesArray{T, N} = AxisArrays.AxisArray{T, N} -const AxisMatrix{T} = HasAxesArray{T, 2} - import AbstractPlotting: to_font, glyph_uv_width!, glyph_scale! import ..GLMakie: get_texture! diff --git a/src/GLVisualize/visualize/image_like.jl b/src/GLVisualize/visualize/image_like.jl index 6cd0739..6a706f5 100644 --- a/src/GLVisualize/visualize/image_like.jl +++ b/src/GLVisualize/visualize/image_like.jl @@ -86,97 +86,6 @@ function _default(main::MatTypes{T}, s::style"distancefield", data::Dict) where _default((rect, Point2f0[0]), s, data) end - -export play -""" - play(img, timedim, t) - -Slice a 3D array along axis `timedim` at time `t`. -This can be used to treat a 3D array like a video and create an image stream from it. -""" -function play(array::Array{T, 3}, timedim::Integer, t::Integer) where T - index = ntuple(dim-> dim == timedim ? t : Colon(), Val(3)) - array[index...] -end - -""" - play(buffer, video_stream, t) - -Plays a video stream from VideoIO.jl. You need to supply the image `buffer`, -which will be reused for better performance. -""" -function play(buffer::Array{T, 2}, video_stream, t) where T - eof(video_stream) && seekstart(video_stream) - w, h = size(buffer) - buffer = reinterpret(UInt8, buffer, (3, w,h)) - read!(video_stream, buffer) # looses type and shape - return reinterpret(T, buffer, (w,h)) -end - - -unwrap(img::AxisArrays.AxisArray) = unwrap(img.data) -unwrap(img::AbstractArray) = img - -GLAbstraction.gl_convert(::Type{T}, img::AbstractArray) where {T} = _gl_convert(T, unwrap(img)) -_gl_convert(::Type{T}, img::Array) where {T} = gl_convert(T, img) - -""" - play(img) - -Turns an Image into a video stream -""" -function play(img::HasAxesArray{T, 3}) where T - ax = ImageAxes.timeaxis(img) - if ImageAxes.timeaxis(img) != nothing - return const_lift(play, unwrap(img), ImageAxes.timedim(img), loop(1:length(ax))) - end - error("Image has no time axis: axes(img) = $(axes(img))") -end - -""" -Takes a 3D image and decides if it is a volume or an animated Image. -""" -function _default(img::HasAxesArray{T, 3}, s::Style, data::Dict) where T - # We could do this as a @traitfn, except that those don't - # currently mix well with non-trait specialization. - if ImageAxes.timeaxis(img) != nothing - data[:spatialorder] = "yx" - td = ImageAxes.timedim(img) - video_signal = const_lift(play, unwrap(img), td, loop(1:size(img, timedim))) - return _default(video_signal, s, data) - else - ps = ImageAxes.pixelspacing(img) - spacing = Vec3f0(map(x-> x / maximum(ps), ps)) - pdims = Vec3f0(map(length, indices(img))) - dims = pdims .* spacing - dims = dims/maximum(dims) - data[:dimensions] = dims - _default(unwrap(img), s, data) - end -end -function _default(img::TOrSignal{T}, s::Style, data::Dict) where T <: AxisMatrix - @gen_defaults! data begin - ranges = const_lift(img) do img - ps = ImageAxes.pixelspacing(img) - spacing = Vec2f0(map(x-> x / maximum(ps), ps)) - pdims = Vec2f0(map(length, indices(img))) - dims = pdims .* spacing - dims = dims / maximum(dims) - (0:dims[1], 0:dims[2]) - end - end - _default(const_lift(unwrap, img), s, data) -end - -""" -Displays 3D array as movie with 3rd dimension as time dimension -""" -function _default(img::AbstractArray{T, 3}, s::Style, data::Dict) where T - video_signal = const_lift(play, unwrap(img), 3, loop(1:size(img, 3))) - return _default(video_signal, s, data) -end - - """ Takes a shader as a parametric function. The shader should contain a function stubb like this: From 4f51026a22f1e8760dfebed87a1867ea97274586 Mon Sep 17 00:00:00 2001 From: SimonDanisch Date: Mon, 9 Dec 2019 13:53:29 +0100 Subject: [PATCH 3/3] get ready for taggin --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 176d131..0e9ec55 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "GLMakie" uuid = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" -version = "0.0.8" +version = "0.0.9" [deps] AbstractPlotting = "537997a7-5e4e-5d89-9595-2241ea00577e"