Improved textures wrap support

This commit is contained in:
Ray 2018-12-03 12:00:05 +01:00
parent f552d43547
commit 8b75a1a990
3 changed files with 16 additions and 16 deletions

View File

@ -731,7 +731,8 @@ typedef enum {
typedef enum {
WRAP_REPEAT = 0, // Repeats texture in tiled mode
WRAP_CLAMP, // Clamps texture to edge pixel in tiled mode
WRAP_MIRROR // Mirrors the texture in tiled mode
WRAP_MIRROR_REPEAT, // Mirrors and repeats the texture in tiled mode
WRAP_MIRROR_CLAMP // Mirrors and clamps to border the texture in tiled mode
} TextureWrapMode;
// Font type, defines generation method

View File

@ -130,7 +130,8 @@
#define RL_WRAP_REPEAT 0x2901 // GL_REPEAT
#define RL_WRAP_CLAMP 0x812F // GL_CLAMP_TO_EDGE
#define RL_WRAP_CLAMP_MIRROR 0x8742 // GL_MIRROR_CLAMP_EXT
#define RL_WRAP_MIRROR_REPEAT 0x8370 // GL_MIRRORED_REPEAT
#define RL_WRAP_MIRROR_CLAMP 0x8742 // GL_MIRROR_CLAMP_EXT
// Matrix modes (equivalent to OpenGL)
#define RL_MODELVIEW 0x1700 // GL_MODELVIEW
@ -303,13 +304,6 @@ typedef unsigned char byte;
FILTER_ANISOTROPIC_16X, // Anisotropic filtering 16x
} TextureFilterMode;
// Texture parameters: wrap mode
typedef enum {
WRAP_REPEAT = 0,
WRAP_CLAMP,
WRAP_MIRROR
} TextureWrapMode;
// Color blending modes (pre-defined)
typedef enum {
BLEND_ALPHA = 0,
@ -863,7 +857,7 @@ static bool texAnisotropicFilterSupported = false; // Anisotropic texture filte
static float maxAnisotropicLevel = 0.0f; // Maximum anisotropy level supported (minimum is 2.0f)
// Extension supported flag: Clamp mirror wrap mode
static bool texClampMirrorSupported = false; // Clamp mirror wrap mode supported
static bool texMirrorClampSupported = false; // Clamp mirror wrap mode supported
#if defined(GRAPHICS_API_OPENGL_ES2)
// NOTE: VAO functionality is exposed through extensions (OES)
@ -1423,7 +1417,7 @@ void rlTextureParameters(unsigned int id, int param, int value)
case RL_TEXTURE_WRAP_S:
case RL_TEXTURE_WRAP_T:
{
if ((value == RL_WRAP_CLAMP_MIRROR) && !texClampMirrorSupported) TraceLog(LOG_WARNING, "Clamp mirror wrap mode not supported");
if ((value == RL_WRAP_MIRROR_CLAMP) && !texMirrorClampSupported) TraceLog(LOG_WARNING, "Clamp mirror wrap mode not supported");
else glTexParameteri(GL_TEXTURE_2D, param, value);
} break;
case RL_TEXTURE_MAG_FILTER:
@ -1719,7 +1713,7 @@ void rlglInit(int width, int height)
}
// Clamp mirror wrap mode supported
if (strcmp(extList[i], (const char *)"GL_EXT_texture_mirror_clamp") == 0) texClampMirrorSupported = true;
if (strcmp(extList[i], (const char *)"GL_EXT_texture_mirror_clamp") == 0) texMirrorClampSupported = true;
// Debug marker support
if(strcmp(extList[i], (const char *)"GL_EXT_debug_marker") == 0) debugMarkerSupported = true;
@ -1744,7 +1738,7 @@ void rlglInit(int width, int height)
if (texCompASTCSupported) TraceLog(LOG_INFO, "[EXTENSION] ASTC compressed textures supported");
if (texAnisotropicFilterSupported) TraceLog(LOG_INFO, "[EXTENSION] Anisotropic textures filtering supported (max: %.0fX)", maxAnisotropicLevel);
if (texClampMirrorSupported) TraceLog(LOG_INFO, "[EXTENSION] Clamp mirror wrap texture mode supported");
if (texMirrorClampSupported) TraceLog(LOG_INFO, "[EXTENSION] Mirror clamp wrap texture mode supported");
if (debugMarkerSupported) TraceLog(LOG_INFO, "[EXTENSION] Debug Marker supported");

View File

@ -2354,10 +2354,15 @@ void SetTextureWrap(Texture2D texture, int wrapMode)
rlTextureParameters(texture.id, RL_TEXTURE_WRAP_S, RL_WRAP_CLAMP);
rlTextureParameters(texture.id, RL_TEXTURE_WRAP_T, RL_WRAP_CLAMP);
} break;
case WRAP_MIRROR:
case WRAP_MIRROR_REPEAT:
{
rlTextureParameters(texture.id, RL_TEXTURE_WRAP_S, RL_WRAP_CLAMP_MIRROR);
rlTextureParameters(texture.id, RL_TEXTURE_WRAP_T, RL_WRAP_CLAMP_MIRROR);
rlTextureParameters(texture.id, RL_TEXTURE_WRAP_S, RL_WRAP_MIRROR_REPEAT);
rlTextureParameters(texture.id, RL_TEXTURE_WRAP_T, RL_WRAP_MIRROR_REPEAT);
} break;
case WRAP_MIRROR_CLAMP:
{
rlTextureParameters(texture.id, RL_TEXTURE_WRAP_S, RL_WRAP_MIRROR_CLAMP);
rlTextureParameters(texture.id, RL_TEXTURE_WRAP_T, RL_WRAP_MIRROR_CLAMP);
} break;
default: break;
}