Browse Source

Added openGL macro JUCE_GLSL_VERSION

tags/2021-05-28
jules 11 years ago
parent
commit
6c30e83de1
2 changed files with 21 additions and 4 deletions
  1. +18
    -1
      modules/juce_opengl/juce_opengl.h
  2. +3
    -3
      modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp

+ 18
- 1
modules/juce_opengl/juce_opengl.h View File

@@ -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 <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#else
@@ -74,6 +73,24 @@
#include <GLES2/gl2.h>
#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.


+ 3
- 3
modules/juce_opengl/opengl/juce_OpenGLHelpers.cpp View File

@@ -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")


Loading…
Cancel
Save