From 37cc8d21ac7340c07617e83565d83515d46f1141 Mon Sep 17 00:00:00 2001 From: Mustafa Mohamad Date: Fri, 30 Apr 2021 19:20:12 -0400 Subject: [PATCH] Add back build time check for debugging --- deps/build.jl | 4 ++++ src/ModernGL.jl | 6 ------ src/functionloading.jl | 10 +++++++++- 3 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 deps/build.jl diff --git a/deps/build.jl b/deps/build.jl new file mode 100644 index 0000000..f922a21 --- /dev/null +++ b/deps/build.jl @@ -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 diff --git a/src/ModernGL.jl b/src/ModernGL.jl index 8113c1f..1f77b59 100644 --- a/src/ModernGL.jl +++ b/src/ModernGL.jl @@ -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 diff --git a/src/functionloading.jl b/src/functionloading.jl index 504453d..ad57801 100644 --- a/src/functionloading.jl +++ b/src/functionloading.jl @@ -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