Skip to content

Commit

Permalink
Add back build time check for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
musm committed Apr 30, 2021
1 parent 5bef72b commit 37cc8d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
debug_level = lowercase(get(ENV, "MODERNGL_DEBUGGING", "false")) == "true"
open(joinpath(@__DIR__, "deps.jl"), "w") do io
println(io, "const enable_opengl_debugging = $debug_level")
end
6 changes: 0 additions & 6 deletions src/ModernGL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,8 @@ macro GenEnums(list)
esc(Expr(:block, enumtype, tmp..., Expr(:export, :($(enumName)))))
end

const enable_opengl_debugging = Ref(false)

include("glTypes.jl")
include("functionloading.jl")
include("glConstants.jl")

function __init__()
enable_opengl_debugging[] = lowercase(get(ENV, "MODERNGL_DEBUGGING", "false")) == "true"
end

end # module
10 changes: 9 additions & 1 deletion src/functionloading.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
const depsfile = joinpath("..", "deps", "deps.jl")

if isfile(depsfile)
include(depsfile)
else
const enable_opengl_debugging = get(ENV, "MODERNGL_DEBUGGING", "false") == "true"
end

gl_represent(x::GLenum) = GLENUM(x).name
gl_represent(x) = repr(x)

function debug_opengl_expr(func_name, args)
if enable_opengl_debugging[] && func_name != :glGetError
if enable_opengl_debugging && func_name != :glGetError
quote
err = glGetError()
if err != GL_NO_ERROR
Expand Down

0 comments on commit 37cc8d2

Please sign in to comment.