From 6c30e83de15d24a74ee5b43cb86d2f4d48e561c5 Mon Sep 17 00:00:00 2001 From: jules Date: Sun, 17 Aug 2014 12:24:38 +0100 Subject: [PATCH] Added openGL macro JUCE_GLSL_VERSION --- modules/juce_opengl/juce_opengl.h | 19 ++++++++++++++++++- .../juce_opengl/opengl/juce_OpenGLHelpers.cpp | 6 +++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/modules/juce_opengl/juce_opengl.h b/modules/juce_opengl/juce_opengl.h index 8a01f5d330..5e1735d314 100644 --- a/modules/juce_opengl/juce_opengl.h +++ b/modules/juce_opengl/juce_opengl.h @@ -63,7 +63,6 @@ #endif #elif JUCE_MAC #if defined (MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7) - #define JUCE_OPENGL3 1 #include #include #else @@ -74,6 +73,24 @@ #include #endif +#if GL_VERSION_3_2 || GL_ES_VERSION_3_0 + #define JUCE_OPENGL3 1 +#endif + +//============================================================================= +/** This macro is a helper for use in GLSL shader code which needs to compile on both OpenGL 2.1 and OpenGL 3.0. + It's mandatory in OpenGL 3.0 to specify the GLSL version. +*/ +#if JUCE_OPENGL3 + #if JUCE_OPENGL_ES + #define JUCE_GLSL_VERSION "#version 300 es" + #else + #define JUCE_GLSL_VERSION "#version 150" + #endif +#else + #define JUCE_GLSL_VERSION "" +#endif + //============================================================================= #if JUCE_OPENGL_ES || defined (DOXYGEN) /** This macro is a helper for use in GLSL shader code which needs to compile on both GLES and desktop GL. diff --git a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp index 869f77e9ac..4988318085 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp @@ -81,8 +81,8 @@ String OpenGLHelpers::translateVertexShaderToV3 (const String& code) { #if JUCE_OPENGL3 if (OpenGLShaderProgram::getLanguageVersion() > 1.2) - return "#version 150\n" + code.replace ("attribute", "in") - .replace ("varying", "out"); + return JUCE_GLSL_VERSION "\n" + code.replace ("attribute", "in") + .replace ("varying", "out"); #endif return code; @@ -92,7 +92,7 @@ String OpenGLHelpers::translateFragmentShaderToV3 (const String& code) { #if JUCE_OPENGL3 if (OpenGLShaderProgram::getLanguageVersion() > 1.2) - return "#version 150\n" + return JUCE_GLSL_VERSION "\n" "out vec4 fragColor;\n" + code.replace ("varying", "in") .replace ("texture2D", "texture")