Skip to content

Add rlSetBlendFactorsSeparate and checks for custom blend mode modifications#2741

Merged
raysan5 merged 1 commit intoraysan5:masterfrom
pure01fx:master
Oct 5, 2022
Merged

Add rlSetBlendFactorsSeparate and checks for custom blend mode modifications#2741
raysan5 merged 1 commit intoraysan5:masterfrom
pure01fx:master

Conversation

@pure01fx
Copy link
Contributor

@pure01fx pure01fx commented Oct 5, 2022

Coincidentally it seems like #2717 found some similar problems mentioned in this PR... I have made these changed a long time ago, sorry for that.

There are several problems.

  1. In some cases rlSetBlendMode is not enough for all situations (like some 3rd party libraries like Live2D, actually I have written a raylib renderer for Live2D for fun, with changes in this PR)
  2. If custom blend factors or equations is changed, some functions, like glBlendFunc, should be called. No function call is made now if RLGL.State.currentBlendMode is not changed

For problem 1, I used a more modest approach. I think glBlendFuncSeparate will not be used in most cases, so I add one more blend mode for this case. I don't know if it is appropriate to force developers to use glBlendFuncSeparate...

And I add custom blend mode modification checks in rlSetBlendFactors (and rlSetBlendFactorsSeparate) so that we can know if the custom blend factors and equations changed in rlSetBlendMode and avoid useless blend mode modification calls.

If #2717 is accepted, I can open a new PR to solve problem 2 😊.

@raysan5 raysan5 merged commit 2d88958 into raysan5:master Oct 5, 2022
@raysan5
Copy link
Owner

raysan5 commented Oct 5, 2022

@pure01fx Thank you very much for the improvement! I agree with your assumptions! Most users won't probably need glBlendFuncSeparate() but still nice to have it for advance users. Also nice to consider avoiding useless blend mode modification calls!

I'm merging this PR.

@SAOMDVN
Copy link
Contributor

SAOMDVN commented Oct 5, 2022

Hi @pure01fx do you have plan to publish your Live2D renderer?

@SAOMDVN
Copy link
Contributor

SAOMDVN commented Oct 5, 2022

Hi @raysan5 I think there's a missing BLEND_CUSTOM_SEPARATE enum in raylib.h. It's small so I don't think I need to make a PR

raysan5 added a commit that referenced this pull request Oct 5, 2022
@raysan5
Copy link
Owner

raysan5 commented Oct 5, 2022

@SAOMDVN Thanks! Added! :)

@beetaa
Copy link

beetaa commented Dec 6, 2022

@pure01fx @raysan5 thanks a lot for this pr, this dramatically increase the font rendering, especially in webassembly compiling. btw, I use this function for example:

BeginBlendMode(BLEND_CUSTOM_SEPARATE);
rlSetBlendFactorsSeparate(0x0302, 0x0303, 1, 0x0303, 0x8006, 0x8006);

...balalalala

EndBlendMode();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants