Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/rlgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@
#define RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS 4 // Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())
#endif

#ifndef RLGL_ENABLE_GLES_DEFAULT_HIGHP_PRECISION
// Enable high precision floats in the default GLES shaders.
// Useful on some mobile GPUs/drivers where mediump causes visible 2D shape artifacts.
// Define RLGL_ENABLE_GLES_DEFAULT_HIGHP_PRECISION as 1 before including rlgl.h
// or pass it from the build system, e.g. -DRLGL_ENABLE_GLES_DEFAULT_HIGHP_PRECISION=1.
#define RLGL_ENABLE_GLES_DEFAULT_HIGHP_PRECISION 0
#endif

// Internal Matrix stack
#ifndef RL_MAX_MATRIX_STACK_SIZE
#define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of Matrix stack
Expand Down Expand Up @@ -5011,15 +5019,23 @@ static void rlLoadShaderDefault(void)

#if defined(GRAPHICS_API_OPENGL_ES3)
"#version 300 es \n"
#if RLGL_ENABLE_GLES_DEFAULT_HIGHP_PRECISION
"precision highp float; \n" // Use high precision on GLES to reduce device-specific vertex/edge artifacts
#else
"precision mediump float; \n" // Precision required for OpenGL ES3 (WebGL 2) (on some browsers)
#endif
"in vec3 vertexPosition; \n"
"in vec2 vertexTexCoord; \n"
"in vec4 vertexColor; \n"
"out vec2 fragTexCoord; \n"
"out vec4 fragColor; \n"
#elif defined(GRAPHICS_API_OPENGL_ES2)
"#version 100 \n"
#if RLGL_ENABLE_GLES_DEFAULT_HIGHP_PRECISION
"precision highp float; \n" // Use high precision on GLES to reduce device-specific vertex/edge artifacts
#else
"precision mediump float; \n" // Precision required for OpenGL ES2 (WebGL) (on some browsers)
#endif
"attribute vec3 vertexPosition; \n"
"attribute vec2 vertexTexCoord; \n"
"attribute vec4 vertexColor; \n"
Expand Down Expand Up @@ -5064,7 +5080,11 @@ static void rlLoadShaderDefault(void)

#if defined(GRAPHICS_API_OPENGL_ES3)
"#version 300 es \n"
#if RLGL_ENABLE_GLES_DEFAULT_HIGHP_PRECISION
"precision highp float; \n" // Use high precision on GLES to reduce device-specific fragment artifacts
#else
"precision mediump float; \n" // Precision required for OpenGL ES3 (WebGL 2)
#endif
"in vec2 fragTexCoord; \n"
"in vec4 fragColor; \n"
"out vec4 finalColor; \n"
Expand All @@ -5077,7 +5097,11 @@ static void rlLoadShaderDefault(void)
"} \n";
#elif defined(GRAPHICS_API_OPENGL_ES2)
"#version 100 \n"
#if RLGL_ENABLE_GLES_DEFAULT_HIGHP_PRECISION
"precision highp float; \n" // Use high precision on GLES to reduce device-specific fragment artifacts
#else
"precision mediump float; \n" // Precision required for OpenGL ES2 (WebGL)
#endif
"varying vec2 fragTexCoord; \n"
"varying vec4 fragColor; \n"
"uniform sampler2D texture0; \n"
Expand Down
Loading