From 4dfd989c4cd1d110c07645c9ab48a7f45716f802 Mon Sep 17 00:00:00 2001 From: Leon Wabeke Date: Wed, 26 Sep 2018 12:02:31 +0200 Subject: [PATCH] Removed deprecations to get Plots with glvisualize backend running in julia v0.7 --- REQUIRE | 2 +- src/callbacks.jl | 4 ++-- src/screen.jl | 15 ++++++++------- src/types.jl | 4 ++-- test/runtests.jl | 3 ++- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/REQUIRE b/REQUIRE index f1c5d37..df82464 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,4 @@ -julia 0.6 +julia 0.7 Reactive 0.5.2 GLAbstraction 0.5 diff --git a/src/callbacks.jl b/src/callbacks.jl index 4fc8586..56ef2b5 100644 --- a/src/callbacks.jl +++ b/src/callbacks.jl @@ -15,7 +15,7 @@ This is why there is also framebuffer_size. returns `Signal{Vec{2,Int}}` [GLFW Docs](http://www.glfw.org/docs/latest/group__window.html#gaaca1c2715759d03da9834eac19323d4a) """ -function window_size(window, s::Signal{Vec{2,Int}}=Signal(Vec{2,Int}(GLFW.GetWindowSize(window)))) +function window_size(window, s::Signal{Vec{2,Int}}=Signal(Vec{2,Int}(GLFW.GetWindowSize(window)...))) GLFW.SetWindowSizeCallback(window, (window, w::Cint, h::Cint,) -> begin push!(s, Vec{2,Int}(w, h)) end) @@ -26,7 +26,7 @@ Size of window in pixel. returns `Signal{Vec{2,Int}}` [GLFW Docs](http://www.glfw.org/docs/latest/group__window.html#ga311bb32e578aa240b6464af494debffc) """ -function framebuffer_size(window, s::Signal{Vec{2, Int}}=Signal(Vec{2, Int}(GLFW.GetFramebufferSize(window)))) +function framebuffer_size(window, s::Signal{Vec{2, Int}}=Signal(Vec{2, Int}(GLFW.GetFramebufferSize(window)...))) GLFW.SetFramebufferSizeCallback(window, (window, w::Cint, h::Cint) -> begin push!(s, Vec(Int(w), Int(h))) end) diff --git a/src/screen.jl b/src/screen.jl index 1368279..8f104f9 100644 --- a/src/screen.jl +++ b/src/screen.jl @@ -6,7 +6,7 @@ function openglerrorcallback( source::GLenum, typ::GLenum, id::GLuint, severity::GLenum, length::GLsizei, message::Ptr{GLchar}, - userParam::Ptr{Void} + userParam::Ptr{Nothing} ) errormessage = """ ________________________________________________________________ @@ -21,9 +21,9 @@ function openglerrorcallback( nothing end -global const _openglerrorcallback = cfunction( - openglerrorcallback, Void, - (GLenum, GLenum,GLuint, GLenum, GLsizei, Ptr{GLchar}, Ptr{Void}) +global const _openglerrorcallback = @cfunction( + openglerrorcallback, Nothing, + (GLenum, GLenum,GLuint, GLenum, GLsizei, Ptr{GLchar}, Ptr{Nothing}) ) @@ -78,7 +78,7 @@ function scaling_factor(window::Vec{2, Int}, fb::Vec{2, Int}) end function scaling_factor(nw) w, fb = GLFW.GetWindowSize(nw), GLFW.GetFramebufferSize(nw) - scaling_factor(Vec{2, Int}(w), Vec{2, Int}(fb)) + scaling_factor(Vec{2, Int}(w...), Vec{2, Int}(fb...)) end """ @@ -203,7 +203,7 @@ function create_glcontext( GLFW.WindowHint(wh[1], wh[2]) end - @static if is_apple() + @static if Sys.isapple() if debugging warn("OpenGL debug message callback not available on osx") debugging = false @@ -579,12 +579,13 @@ function Base.push!(screen::Screen, robj::RenderObject{Pre}) where Pre index = findfirst(getfield(screen, sym)) do renderlist prerendertype(eltype(renderlist)) == Pre end - if index == 0 + if (index == 0) || (index == nothing) # add new specialised renderlist, if none found setfield!(screen, sym, (getfield(screen, sym)..., RenderObject{Pre}[])) index = length(getfield(screen, sym)) end # only add to renderlist if not already in there + tmp = getfield(screen, sym)[index] in(robj, getfield(screen, sym)[index]) || push!(getfield(screen, sym)[index], robj) nothing end diff --git a/src/types.jl b/src/types.jl index d9e2667..075a4e5 100644 --- a/src/types.jl +++ b/src/types.jl @@ -163,7 +163,7 @@ function MonitorProperties(monitor::Monitor) position = Vec{2, Int}(GLFW.GetMonitorPos(monitor)...) physicalsize = Vec{2, Int}(GLFW.GetMonitorPhysicalSize(monitor)...) videomode = GLFW.GetVideoMode(monitor) - sfactor = is_apple() ? 2.0 : 1.0 + sfactor = Sys.isapple() ? 2.0 : 1.0 dpi = Vec(videomode.width * 25.4, videomode.height * 25.4) * sfactor ./ Vec{2, Float64}(physicalsize) videomode_supported = GLFW.GetVideoModes(monitor) @@ -210,7 +210,7 @@ mutable struct Screen function Screen( name ::Symbol, area ::Signal{SimpleRectangle{Int}}, - parent ::Union{Screen, Void}, + parent ::Union{Screen, Nothing}, children ::Vector{Screen}, inputs ::Dict{Symbol, Any}, renderlist ::Tuple, diff --git a/test/runtests.jl b/test/runtests.jl index ed97268..066f961 100755 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,7 +5,8 @@ function is_ci() end using GLWindow -using Base.Test +using Test +using GLFW if !is_ci() # only do test if not CI... this is for automated testing environments which fail for OpenGL stuff, but I'd like to test if at least including works