Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ugrade to 0.7 #43

Merged
merged 5 commits into from
Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ os:
- linux
dist: trusty
julia:
- 0.6
- 0.7
- nightly
notifications:
email: false
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
julia 0.6
julia 0.7-alpha
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"

Expand Down
30 changes: 16 additions & 14 deletions src/ModernGL.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
__precompile__(true)
module ModernGL

using Libdl

function glXGetProcAddress(glFuncName)
ccall((:glXGetProcAddress, "libGL.so.1"), Ptr{Void}, (Ptr{UInt8},), glFuncName)
ccall((:glXGetProcAddress, "libGL.so.1"), Ptr{Cvoid}, (Ptr{UInt8},), glFuncName)
end
function NSGetProcAddress(glFuncName)
tmp = "_"*glFuncName
if ccall(:NSIsSymbolNameDefined, Cint, (Ptr{UInt8},), tmp) == 0
return convert(Ptr{Void}, 0)
return convert(Ptr{Cvoid}, 0)
else
symbol = ccall(:NSLookupAndBindSymbol, Ptr{Void}, (Ptr{UInt8},), tmp)
return ccall(:NSAddressOfSymbol, Ptr{Void}, (Ptr{Void},), symbol)
symbol = ccall(:NSLookupAndBindSymbol, Ptr{Cvoid}, (Ptr{UInt8},), tmp)
return ccall(:NSAddressOfSymbol, Ptr{Cvoid}, (Ptr{Cvoid},), symbol)
end
end

function wglGetProcAddress(glFuncName)
ccall((:wglGetProcAddress, "opengl32"), Ptr{Void}, (Ptr{UInt8},), glFuncName)
ccall((:wglGetProcAddress, "opengl32"), Ptr{Cvoid}, (Ptr{UInt8},), glFuncName)
end

if is_apple()
if Sys.isapple()
getprocaddress(glFuncName) = NSGetProcAddress(glFuncName)
elseif is_unix()
elseif Sys.isunix()
getprocaddress(glFuncName) = glXGetProcAddress(glFuncName)
end
if is_windows()
if Sys.iswindows()
getprocaddress(glFuncName) = wglGetProcAddress(glFuncName)
end

Expand All @@ -49,11 +51,11 @@ end
isavailable(name::Symbol) =
isavailable(ModernGL.getprocaddress(ascii(string(name))))

isavailable(ptr::Ptr{Void}) = !(
isavailable(ptr::Ptr{Cvoid}) = !(
ptr == C_NULL ||
ptr == convert(Ptr{Void}, 1) ||
ptr == convert(Ptr{Void}, 2) ||
ptr == convert(Ptr{Void}, 3)
ptr == convert(Ptr{Cvoid}, 1) ||
ptr == convert(Ptr{Cvoid}, 2) ||
ptr == convert(Ptr{Cvoid}, 3)
)

abstract type Enum end
Expand All @@ -65,7 +67,7 @@ macro GenEnums(list)
enumType = typeof(eval(tmp[4].args[1].args[2]))
enumdict1 = Dict{enumType, Symbol}()
for elem in tmp
if elem.head == :const
if Meta.isexpr(elem, :const)
enumdict1[eval(elem.args[1].args[2])] = elem.args[1].args[1]
end
end
Expand All @@ -76,7 +78,7 @@ macro GenEnums(list)
name::Symbol
end
$(dictname) = $enumdict1
function $(enumName){T}(number::T)
function $(enumName)(number::T) where T
if !haskey($(dictname), number)
error("$number is not a GLenum")
end
Expand Down
16 changes: 8 additions & 8 deletions src/functionloading.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mutable struct GLFunc
p::Ptr{Void}
p::Ptr{Cvoid}
end
# based on getCFun macro
macro glfunc(opengl_func)
Expand All @@ -16,7 +16,7 @@ macro glfunc(opengl_func)
func_name_str = string(func_name)
ptr_expr = :(getprocaddress_e($func_name_str))

if is_windows() # windows has some function pointers statically available and some not, this is how we deal with it:
if Sys.iswindows() # windows has some function pointers statically available and some not, this is how we deal with it:
ptr = Libdl.dlsym_e(gl_lib, func_name)
if (ptr != C_NULL)
ptr_expr = :(($func_name_sym, "opengl32"))
Expand All @@ -31,21 +31,21 @@ macro glfunc(opengl_func)
end
ptr_sym = gensym("$(func_name)_func_pointer")
ret = quote
const $ptr_sym = GLFunc(C_NULL)
$ptr_sym = GLFunc(C_NULL)
function $func_name($(arg_names...))
if $ptr_sym.p::Ptr{Void} == C_NULL
$ptr_sym.p::Ptr{Void} = $ptr_expr
if $ptr_sym.p::Ptr{Cvoid} == C_NULL
$ptr_sym.p::Ptr{Cvoid} = $ptr_expr
end
ccall($ptr_sym.p::Ptr{Void}, $return_type, ($(input_types...),), $(arg_names...))
ccall($ptr_sym.p::Ptr{Cvoid}, $return_type, ($(input_types...),), $(arg_names...))
end
$(Expr(:export, func_name))
end
return esc(ret)
end
if is_windows()
if Sys.iswindows()
const gl_lib = Libdl.dlopen("opengl32")
end
include("glFunctions.jl")
if is_windows()
if Sys.iswindows()
Libdl.dlclose(gl_lib)
end
Loading