From 2c8a92cacb1770fa670a01fa2552870abbeee3c3 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Fri, 11 Dec 2020 12:27:07 +0100 Subject: [PATCH] Some shader compilers did not seemingly like #if XXX blocks if XXX was not defined. Changed to #ifdef XXX. --- resources/shaders/gouraud.fs | 4 ++-- src/slic3r/GUI/GLShader.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/shaders/gouraud.fs b/resources/shaders/gouraud.fs index bfb5e1cac..40182a14b 100644 --- a/resources/shaders/gouraud.fs +++ b/resources/shaders/gouraud.fs @@ -16,7 +16,7 @@ struct SlopeDetection uniform vec4 uniform_color; uniform SlopeDetection slope; -#if ENABLE_ENVIRONMENT_MAP +#ifdef ENABLE_ENVIRONMENT_MAP uniform sampler2D environment_tex; uniform bool use_environment_tex; #endif // ENABLE_ENVIRONMENT_MAP @@ -44,7 +44,7 @@ void main() vec3 color = slope.actived ? slope_color() : uniform_color.rgb; // if the fragment is outside the print volume -> use darker color color = (any(lessThan(delta_box_min, ZERO)) || any(greaterThan(delta_box_max, ZERO))) ? mix(color, ZERO, 0.3333) : color; -#if ENABLE_ENVIRONMENT_MAP +#ifdef ENABLE_ENVIRONMENT_MAP if (use_environment_tex) gl_FragColor = vec4(0.45 * texture2D(environment_tex, normalize(eye_normal).xy * 0.5 + 0.5).xyz + 0.8 * color * intensity.x, uniform_color.a); else diff --git a/src/slic3r/GUI/GLShader.cpp b/src/slic3r/GUI/GLShader.cpp index b87983bd0..0473e5344 100644 --- a/src/slic3r/GUI/GLShader.cpp +++ b/src/slic3r/GUI/GLShader.cpp @@ -61,7 +61,7 @@ bool GLShaderProgram::init_from_files(const std::string& name, const ShaderFilen for (std::string_view def : defines) // Our shaders are stored with "\r\n", thus replicate the same here for consistency. Likely "\n" would suffice, // but we don't know all the OpenGL shader compilers around. - defines_program += format("#define %s 1\r\n", def); + defines_program += format("#define %s\r\n", def); ShaderSources sources = {}; for (size_t i = 0; i < static_cast(EShaderType::Count); ++i) {