Created
February 9, 2021 15:53
-
-
Save ofZach/9cc3bf0b0c8e1f22eeae97e3a53fb522 to your computer and use it in GitHub Desktop.
hunt for blend func
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// written by Golan Levin | |
// for example, huntForBlendFunc(1, -1, -1); | |
void huntForBlendFunc(float period, int defaultSid, int defaultDid){ | |
// sets all possible (24) combinations of blend functions, | |
// changing modes every period seconds. | |
int sfact[] = { | |
GL_ZERO, | |
GL_ONE, | |
GL_DST_COLOR, | |
GL_ONE_MINUS_DST_COLOR, | |
GL_SRC_ALPHA, | |
GL_ONE_MINUS_SRC_ALPHA, | |
GL_DST_ALPHA, | |
GL_ONE_MINUS_DST_ALPHA, | |
GL_SRC_ALPHA_SATURATE | |
}; | |
int dfact[] = { | |
GL_ZERO, | |
GL_ONE, | |
GL_SRC_COLOR, | |
GL_ONE_MINUS_SRC_COLOR, | |
GL_SRC_ALPHA, | |
GL_ONE_MINUS_SRC_ALPHA, | |
GL_DST_ALPHA, | |
GL_ONE_MINUS_DST_ALPHA | |
}; | |
if ((defaultSid == -1) && (defaultDid == -1)) { | |
int sid = ((int)(ofGetElapsedTimef()*1000)/(8*(int)(period*1000)))%9; | |
int did = ( (int)(ofGetElapsedTimef()*1000)/(int)((period)*1000))%8; | |
glEnable(GL_BLEND); | |
glBlendFunc(dfact[sid], dfact[did]); | |
printf("SRC %d DST %d\n", sid, did); | |
} else { | |
glEnable(GL_BLEND); | |
glBlendFunc(dfact[defaultSid], dfact[defaultDid]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment