Skip to content

Instantly share code, notes, and snippets.

@matkatmusic matkatmusic/opengl.cpp Secret
Created Mar 17, 2018

Embed
What would you like to do?
String fragmentShader = "uniform vec4 Color1;" NEW_LINE
"uniform vec4 Color2;" NEW_LINE
"uniform vec2 ScreenBounds;" NEW_LINE
"void main(void)" NEW_LINE
"{" NEW_LINE
" " //juce is ARGB, GL is RGBA. Destination is xyzw
" " NEW_LINE
/*
gl_FragCoord is in window coords. so, 1024 x 768 or whtaever
*/
"vec2 pos = gl_FragCoord.xy / ScreenBounds.xy;" NEW_LINE
"gl_FragColor = vec4(mix(Color1, Color2, pos.y));" NEW_LINE
"}" NEW_LINE;
//
auto r = getLocalBounds().toFloat();
shaderProgram->setUniform("ScreenBounds",
r.getWidth(),
r.getHeight(),
0.f,
0.f);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.