Skip to content

Commit

Permalink
Reviewed latest PR formating and variables naming #2741
Browse files Browse the repository at this point in the history
  • Loading branch information
raysan5 committed Oct 5, 2022
1 parent 2d88958 commit 9017be3
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions src/rlgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ RLAPI void rlClearScreenBuffers(void); // Clear used screen buf
RLAPI void rlCheckErrors(void); // Check and log OpenGL error codes
RLAPI void rlSetBlendMode(int mode); // Set blending mode
RLAPI void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation); // Set blending mode factor and equation (using OpenGL factors)
RLAPI void rlSetBlendFactorsSeparate(int srgb, int drgb, int salpha, int dalpha, int ergb, int ealpha); // Set blending mode factors and equations separately (using OpenGL factors)
RLAPI void rlSetBlendFactorsSeparate(int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha); // Set blending mode factors and equations separately (using OpenGL factors)

//------------------------------------------------------------------------------------
// Functions Declaration - rlgl functionality
Expand Down Expand Up @@ -928,6 +928,7 @@ typedef struct rlglData {
Matrix projectionStereo[2]; // VR stereo rendering eyes projection matrices
Matrix viewOffsetStereo[2]; // VR stereo rendering eyes view offset matrices

// Blending variables
int currentBlendMode; // Blending mode active
int glBlendSrcFactor; // Blending source factor
int glBlendDstFactor; // Blending destination factor
Expand Down Expand Up @@ -1813,14 +1814,15 @@ void rlSetBlendMode(int mode)
{
// NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactors()
glBlendFunc(RLGL.State.glBlendSrcFactor, RLGL.State.glBlendDstFactor); glBlendEquation(RLGL.State.glBlendEquation);

} break;
case RL_BLEND_CUSTOM_SEPARATE:
{
// NOTE: Using GL blend src/dst factors and GL equation configured with rlSetBlendFactorsSeparate()
glBlendFuncSeparate(RLGL.State.glBlendSrcFactorRGB, RLGL.State.glBlendDestFactorRGB, RLGL.State.glBlendSrcFactorAlpha, RLGL.State.glBlendDestFactorAlpha);
glBlendEquationSeparate(RLGL.State.glBlendEquationRGB, RLGL.State.glBlendEquationAlpha);
break;
}

} break;
default: break;
}

Expand All @@ -1831,20 +1833,23 @@ void rlSetBlendMode(int mode)
}

// Set blending mode factor and equation used by glBlendFuncSeparate and glBlendEquationSeparate
void rlSetBlendFactorsSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha, int modeRGB, int modeAlpha) {
void rlSetBlendFactorsSeparate(int glSrcRGB, int glDstRGB, int glSrcAlpha, int glDstAlpha, int glEqRGB, int glEqAlpha)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
if (RLGL.State.glBlendSrcFactorRGB == srcRGB
&& RLGL.State.glBlendDestFactorRGB == dstRGB
&& RLGL.State.glBlendSrcFactorAlpha == srcAlpha
&& RLGL.State.glBlendDestFactorAlpha == destAlpha
&& RLGL.State.glBlendEquationRGB == modeRGB
&& RLGL.State.glBlendEquationAlpha == modeAlpha) return;
RLGL.State.glBlendSrcFactorRGB = srcRGB;
RLGL.State.glBlendDestFactorRGB = destRGB;
RLGL.State.glBlendSrcFactorAlpha = srcAlpha;
RLGL.State.glBlendDestFactorAlpha = dstAlpha;
RLGL.State.glBlendEquationRGB = modeRGB;
RLGL.State.glBlendEquationAlpha = modeAlpha;
if ((RLGL.State.glBlendSrcFactorRGB == glSrcRGB) &&
(RLGL.State.glBlendDestFactorRGB == glDstRGB) &&
(RLGL.State.glBlendSrcFactorAlpha == glSrcAlpha) &&
(RLGL.State.glBlendDestFactorAlpha == glDstAlpha) &&
(RLGL.State.glBlendEquationRGB == glEqRGB) &&
(RLGL.State.glBlendEquationAlpha == glEqAlpha)) return;

RLGL.State.glBlendSrcFactorRGB = glSrcRGB;
RLGL.State.glBlendDestFactorRGB = glDstRGB;
RLGL.State.glBlendSrcFactorAlpha = glSrcAlpha;
RLGL.State.glBlendDestFactorAlpha = glDstAlpha;
RLGL.State.glBlendEquationRGB = glEqRGB;
RLGL.State.glBlendEquationAlpha = glEqAlpha;

RLGL.State.glCustomBlendModeModified = true;
#endif
}
Expand All @@ -1853,12 +1858,14 @@ void rlSetBlendFactorsSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlph
void rlSetBlendFactors(int glSrcFactor, int glDstFactor, int glEquation)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
if (RLGL.State.glBlendSrcFactor == glSrcFactor
&& RLGL.State.glBlendDstFactor == glDstFactor
&& RLGL.State.glBlendEquation == glEquation) return;
if ((RLGL.State.glBlendSrcFactor == glSrcFactor) &&
(RLGL.State.glBlendDstFactor == glDstFactor) &&
(RLGL.State.glBlendEquation == glEquation)) return;

RLGL.State.glBlendSrcFactor = glSrcFactor;
RLGL.State.glBlendDstFactor = glDstFactor;
RLGL.State.glBlendEquation = glEquation;

RLGL.State.glCustomBlendModeModified = true;
#endif
}
Expand Down Expand Up @@ -2009,9 +2016,6 @@ void rlglInit(int width, int height)
//----------------------------------------------------------
#endif

// Init state: custom blend factor and equation modification flag
RLGL.State.glCustomBlendModeModified = false;

// Init state: Color/Depth buffers clear
glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set clear color (black)
glClearDepth(1.0f); // Set clear depth value (default)
Expand Down

0 comments on commit 9017be3

Please sign in to comment.