Multiple blendmodes (#1324)
Co-authored-by: max <max.cedercreutz@cetopo.com>
This commit is contained in:
parent
dcbe481a28
commit
bfafb80cde
2 changed files with 31 additions and 13 deletions
|
@ -808,7 +808,8 @@ typedef enum {
|
||||||
BLEND_ALPHA = 0, // Blend textures considering alpha (default)
|
BLEND_ALPHA = 0, // Blend textures considering alpha (default)
|
||||||
BLEND_ADDITIVE, // Blend textures adding colors
|
BLEND_ADDITIVE, // Blend textures adding colors
|
||||||
BLEND_MULTIPLIED, // Blend textures multiplying colors
|
BLEND_MULTIPLIED, // Blend textures multiplying colors
|
||||||
BLEND_ADD_COLORS // Blend textures adding colors (alternative)
|
BLEND_ADD_COLORS, // Blend textures adding colors (alternative)
|
||||||
|
BLEND_SUBTRACT_COLORS // Blend textures subtracting colors (alternative)
|
||||||
} BlendMode;
|
} BlendMode;
|
||||||
|
|
||||||
// Gestures type
|
// Gestures type
|
||||||
|
@ -1390,8 +1391,10 @@ RLAPI Texture2D GenTextureBRDF(Shader shader, int size); // Gen
|
||||||
RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||||
RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)
|
RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||||
RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||||
|
RLAPI void BeginBlendModeEx(int sFactor, int dFactor, int equation); // Begin blending mode (full options)
|
||||||
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||||
|
|
||||||
|
|
||||||
// VR control functions
|
// VR control functions
|
||||||
RLAPI void InitVrSimulator(void); // Init VR simulator for selected device parameters
|
RLAPI void InitVrSimulator(void); // Init VR simulator for selected device parameters
|
||||||
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
RLAPI void CloseVrSimulator(void); // Close VR simulator for current device
|
||||||
|
|
39
src/rlgl.h
39
src/rlgl.h
|
@ -589,6 +589,7 @@ RLAPI Texture2D GenTextureBRDF(Shader shader, int size); // Gen
|
||||||
RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
RLAPI void BeginShaderMode(Shader shader); // Begin custom shader drawing
|
||||||
RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)
|
RLAPI void EndShaderMode(void); // End custom shader drawing (use default shader)
|
||||||
RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
RLAPI void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied)
|
||||||
|
RLAPI void BeginBlendModeEx(int sFactor, int dFactor, int equation); // Begin blending mode (full options)
|
||||||
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
RLAPI void EndBlendMode(void); // End blending mode (reset to default: alpha blending)
|
||||||
|
|
||||||
// VR control functions
|
// VR control functions
|
||||||
|
@ -3608,26 +3609,40 @@ Texture2D GenTextureBRDF(Shader shader, int size)
|
||||||
return brdf;
|
return brdf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BeginBlendModeEx(int sFactor, int dFactor, int equation)
|
||||||
|
{
|
||||||
|
static int glSFactor = 0; // Track current blending mode
|
||||||
|
static int glDFactor = 0; // Track current blending mode
|
||||||
|
static int glEquation = 0; // Track current blending mode
|
||||||
|
|
||||||
|
if (glSFactor != sFactor || glDFactor != dFactor || glEquation != equation) {
|
||||||
|
|
||||||
|
rlglDraw();
|
||||||
|
glBlendFunc(sFactor, dFactor);
|
||||||
|
glBlendEquation(equation);
|
||||||
|
|
||||||
|
glSFactor = sFactor;
|
||||||
|
glDFactor = dFactor;
|
||||||
|
glEquation = equation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Begin blending mode (alpha, additive, multiplied)
|
// Begin blending mode (alpha, additive, multiplied)
|
||||||
// NOTE: Only 3 blending modes supported, default blend mode is alpha
|
// NOTE: Only 3 blending modes supported, default blend mode is alpha
|
||||||
void BeginBlendMode(int mode)
|
void BeginBlendMode(int mode)
|
||||||
{
|
{
|
||||||
static int blendMode = 0; // Track current blending mode
|
if (mode < 5)
|
||||||
|
|
||||||
if ((blendMode != mode) && (mode < 4))
|
|
||||||
{
|
{
|
||||||
rlglDraw();
|
|
||||||
|
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case BLEND_ALPHA: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break;
|
case BLEND_ALPHA: BeginBlendModeEx(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_FUNC_ADD); break;
|
||||||
case BLEND_ADDITIVE: glBlendFunc(GL_SRC_ALPHA, GL_ONE); break;
|
case BLEND_ADDITIVE: BeginBlendModeEx(GL_SRC_ALPHA, GL_ONE, GL_FUNC_ADD); break;
|
||||||
case BLEND_MULTIPLIED: glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA); break;
|
case BLEND_MULTIPLIED: BeginBlendModeEx(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA, GL_FUNC_ADD); break;
|
||||||
case BLEND_ADD_COLORS: glBlendFunc(GL_ONE, GL_ONE); break;
|
case BLEND_ADD_COLORS: BeginBlendModeEx(GL_ONE, GL_ONE, GL_FUNC_ADD); break;
|
||||||
default: break;
|
case BLEND_SUBTRACT_COLORS: BeginBlendModeEx(GL_ONE, GL_ONE, GL_FUNC_SUBTRACT); break;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
blendMode = mode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue