Skip to content
This repository was archived by the owner on Apr 28, 2021. It is now read-only.

Commit 2f422f3

Browse files
authored
glwindow changes + depwarns (#194)
* accompany new changes from GLWindow * Fix deprecations * include new glwindow
1 parent d7f584d commit 2f422f3

29 files changed

+182
-190
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ julia 0.6
33
StaticArrays 0.6.0
44
GeometryTypes 0.4.1
55

6-
GLWindow 0.6 # 0.6 for fullscreen
6+
GLWindow 0.7 # 0.7 for reactive_run_till_now
77
GLAbstraction 0.5
88
ModernGL 0.1.0
99

examples/ExampleRunner.jl

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function flatten_paths(path::String, paths = String[])
4343
paths
4444
end
4545

46-
type RunnerConfig
46+
mutable struct RunnerConfig
4747
resolution
4848
make_docs
4949
files
@@ -368,7 +368,7 @@ end
368368
to_toggle(v0, b) = !v0
369369

370370

371-
import GLWindow: poll_reactive, poll_glfw, sleep_pessimistic
371+
import GLWindow: reactive_run_till_now, poll_glfw, sleep_pessimistic
372372

373373

374374
function inner_test(path, config, window, break_loop, runthrough, increase)
@@ -377,21 +377,18 @@ function inner_test(path, config, window, break_loop, runthrough, increase)
377377
display_msg(test_module, config)
378378
timings = Float64[]
379379
frames = 0;
380-
@eval poll_glfw()
381-
@eval poll_reactive()
382-
@eval poll_reactive()
383-
yield()
380+
poll_glfw()
381+
reactive_run_till_now()
384382
while !break_loop[] && isopen(config.rootscreen)
385-
tic()
383+
t = time()
386384
poll_glfw()
387385
if Base.n_avail(Reactive._messages) > 0
388-
poll_reactive()
389-
poll_reactive() # two times for secondary signals
386+
reactive_run_till_now() # two times for secondary signals
390387
render_frame(config.rootscreen)
391388
swapbuffers(config.rootscreen)
392389
end
393390
frames += 1
394-
t = toq()
391+
t = time() - t
395392
if length(timings) < 1000 && frames > 2
396393
push!(timings, t)
397394
end
@@ -453,7 +450,6 @@ function make_tests(config)
453450
end
454451

455452
failed = fill(false, length(config.files))
456-
Reactive.stop() # stop Reactive! We be pollin' ourselves!
457453
io = nothing
458454
while i <= length(config.files) && isopen(config.rootscreen)
459455
path = config.files[i]

examples/interactive/mario_game.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You can move mario around with the arrow keys
99
"""
1010
const record_interactive = true
1111

12-
type Mario{T}
12+
mutable struct Mario{T}
1313
x ::T
1414
y ::T
1515
vx ::T

examples/introduction/video_recording.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ for i=1:10 # record 10 frames
3232
# if you call @async renderloop(window) you can replace this part with yield
3333
GLWindow.render_frame(window)
3434
GLWindow.swapbuffers(window)
35-
GLWindow.poll_reactive()
35+
GLWindow.reactive_run_till_now()
3636

3737
# add the frame from the current window
3838
GLVisualize.add_frame!(io, window, buffer)

examples/parallel/simulation3d.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ function p_empty!()
4444
end
4545

4646

47-
function solve_particles!{N, T}(
47+
function solve_particles!(
4848
positions::AbstractVector{Point{N, T}}, s, dt::T = T(0.01)
49-
)
49+
) where {N, T}
5050
P = Point{N, T}
5151
# since Points are immutable, and we don't have comprehensions yet, there is
5252
# a map(index _> ..., ::Point) which we can use
@@ -70,7 +70,7 @@ end
7070
Generic implementation of initialising `N` dimensional points on an `N` dimensional
7171
Sphere.
7272
"""
73-
function startpositions{T}(N, radius::T, n)
73+
function startpositions(N, radius::T, n) where T
7474
sphere = HyperSphere(Point{N, T}(0), T(radius))
7575
n = N == 3 ? floor(Int, sqrt(n)) : n # n must be n^2 for 3D Sphere
7676
decompose(Point{N, T}, sphere, n)

examples/sprites/distancefield.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dfield = map(timesignal) do t
3131
Float32[xy_data(x,y,tpi) + 0.5f0 for x=1:n2, y=1:n2]
3232
end
3333
Base.rand(m::MersenneTwister, ::Type{N0f8}) = N0f8(rand(m, UInt8))
34-
Base.rand{T <: Colorant}(m::MersenneTwister, ::Type{T}) = T(ntuple(x->rand(m, eltype(T)), Val{length(T)})...)
34+
Base.rand(m::MersenneTwister, ::Type{T}) where {T <: Colorant} = T(ntuple(x->rand(m, eltype(T)), Val{length(T)})...)
3535

3636
distfield = visualize((DISTANCEFIELD, positions),
3737
stroke_width=4f0,

src/GLVisualize.jl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ import GLAbstraction: N0f8
2424
export N0f8 # reexport for examples/tests
2525
using Base.Iterators: filter
2626
import Base: merge, convert, show
27-
if VERSION >= v"0.6.0-dev.1015"
28-
using Base.Iterators: Repeated, repeated
29-
else
30-
using Base.Repeated
31-
end
27+
using Base.Iterators: Repeated, repeated
3228

3329
import AxisArrays, ImageAxes, Images
3430
const HasAxesArray{T, N} = Union{AxisArrays.AxisArray{T, N}, Images.ImageMetadata.ImageMetaAxis{T, N}}

src/StructsOfArrays.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ module StructsOfArrays
22

33
export StructOfArrays, ScalarRepeat
44

5-
immutable StructOfArrays{T,N,U<:Tuple} <: AbstractArray{T,N}
5+
struct StructOfArrays{T,N,U<:Tuple} <: AbstractArray{T,N}
66
arrays::U
77
end
88

99

10-
type ScalarRepeat{T}
10+
mutable struct ScalarRepeat{T}
1111
scalar::T
1212
end
1313
Base.ndims(::ScalarRepeat) = 1
1414
Base.getindex(s::ScalarRepeat, i...) = s.scalar
1515
#should setindex! really be allowed? It will set the index for the whole row...
16-
Base.setindex!{T}(s::ScalarRepeat{T}, value, i...) = (s.scalar = T(value))
16+
Base.setindex!(s::ScalarRepeat{T}, value, i...) where {T} = (s.scalar = T(value))
1717
Base.eltype{T}(::ScalarRepeat{T}) = T
1818

1919
Base.start(::ScalarRepeat) = 1
@@ -85,7 +85,7 @@ Base.convert{T,S,N}(::Type{StructOfArrays{T}}, A::AbstractArray{S,N}) =
8585
Base.convert{T,N}(::Type{StructOfArrays}, A::AbstractArray{T,N}) =
8686
convert(StructOfArrays{T,N}, A)
8787

88-
function Base.size{T, N, U}(A::StructOfArrays{T, N, U})
88+
function Base.size(A::StructOfArrays{T, N, U}) where {T, N, U}
8989
for elem in A.arrays
9090
if isa(elem, AbstractArray)
9191
return size(elem)
@@ -104,7 +104,7 @@ end
104104
)
105105
end
106106

107-
function _getindex{T}(x::T, i)
107+
function _getindex(x::T, i) where T
108108
is_tuple_struct(T) ? x[i] : getfield(x, i)
109109
end
110110
@generated function Base.setindex!{T}(A::StructOfArrays{T}, x, i::Integer...)

src/boundingbox.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
AbsoluteRectangle{N,T}(mini::Vec{N,T}, maxi::Vec{N,T}) = HyperRectangle{N,T}(mini, maxi-mini)
1+
AbsoluteRectangle(mini::Vec{N,T}, maxi::Vec{N,T}) where {N,T} = HyperRectangle{N,T}(mini, maxi-mini)
22

3-
(::Type{AABB})(a) = AABB{Float32}(a)
4-
function (B::Type{AABB{T}}){T}(a::Pyramid)
3+
AABB(a) = AABB{Float32}(a)
4+
function (B::Type{AABB{T}})(a::Pyramid) where T
55
w,h = a.width/T(2), a.length
66
m = Vec{3,T}(a.middle)
77
B(m-Vec{3,T}(w,w,0), m+Vec{3,T}(w, w, h))
88
end
9-
(B::Type{AABB{T}}){T}(a::Cube) = B(origin(a), widths(a))
10-
(B::Type{AABB{T}}){T}(a::AbstractMesh) = B(vertices(a))
11-
(B::Type{AABB{T}}){T}(a::NativeMesh) = B(gpu_data(a.data[:vertices]))
9+
(B::Type{AABB{T}})(a::Cube) where {T} = B(origin(a), widths(a))
10+
(B::Type{AABB{T}})(a::AbstractMesh) where {T} = B(vertices(a))
11+
(B::Type{AABB{T}})(a::NativeMesh) where {T} = B(gpu_data(a.data[:vertices]))
1212

1313

14-
function (B::Type{AABB{T}}){T}(
14+
function (B::Type{AABB{T}})(
1515
positions, scale, rotation,
1616
primitive::AABB{T}
17-
)
17+
) where T
1818

1919
ti = TransformationIterator(positions, scale, rotation)
2020
B(ti, primitive)
2121
end
22-
function (B::Type{AABB{T}}){T}(instances::Instances)
22+
function (B::Type{AABB{T}})(instances::Instances) where T
2323
ti = TransformationIterator(instances)
2424
B(ti, B(instances.primitive))
2525
end
@@ -38,9 +38,9 @@ function transform(translation, scale, rotation, points)
3838
AABB{Float32}(_min, _max-_min)
3939
end
4040

41-
function (B::Type{AABB{T}}){T}(
41+
function (B::Type{AABB{T}})(
4242
ti::TransformationIterator, primitive::AABB{T}
43-
)
43+
) where T
4444
state = start(ti)
4545
if done(ti, state)
4646
return primitive

src/camera.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ function cubeside_const_lift(_, id, mousehover)
1212
Vec3f0(1)
1313
end
1414
import Base: +
15-
Base.clamp{T}(x::T) = clamp(x, T(0),T(1))
16-
+{T}(a::RGBA{T}, b::Number) = RGBA{T}(clamp(comp1(a)+b), clamp(comp2(a)+b), clamp(comp3(a)+b), clamp(alpha(a)+b))
15+
Base.clamp(x::T) where {T} = clamp(x, T(0),T(1))
16+
+(a::RGBA{T}, b::Number) where {T} = RGBA{T}(clamp(comp1(a)+b), clamp(comp2(a)+b), clamp(comp3(a)+b), clamp(alpha(a)+b))
1717

1818
function cubeside_color(id, mousehover, startcolors, colortex)
1919
index = mousehover[2]
@@ -39,7 +39,7 @@ function colored_cube()
3939
cube_steering = merge(map(GLNormalMesh, quads))
4040
end
4141

42-
Base.middle{T}(r::SimpleRectangle{T}) = Point{2, T}(r.x+(r.w/T(2)), r.y+(r.mousehover/T(2)))
42+
Base.middle(r::SimpleRectangle{T}) where {T} = Point{2, T}(r.x+(r.w/T(2)), r.y+(r.mousehover/T(2)))
4343

4444

4545
function get_rotation(m)

0 commit comments

Comments
 (0)