Simple solid color shader

edited April 2014 in GLSL / Shaders

Hi all,

I am new to GLSL, I recently took a workshop that used GLSL and openFrameworks (first time) and would like to use what I learned with Processing. In this example I would like to just make the window a solid color.

PShader test;

void setup() {
  size(640, 360, P2D);
  noStroke();
  fill(204);
  test = loadShader("testFrag.glsl", "testVert.glsl");
}

void draw() {
  shader(test);
  rect(0, 0, width, height);
}

//testFrag.glsl
#define PROCESSING_COLOR_SHADER

void main()
{
    // Setting Each Pixel To Red
    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
}

//testVert.glsl
void main()
{
    // Transforming The Vertex
    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}

Thanks.

Tagged:

Answers

Sign In or Register to comment.