Data flow today! How to get information from your program into the graphics card! CPU program to shaders Vertex shader to Fragment shader Can't go from vertex shader to vertex shader Or fragment shader to fragment shader No sideways data movements! Vertex shaders go first, then fragment You can't control the order of vertex shaders Or fragment shaders That'll be a hassle when we use these for general-purpose computation First: Data Types in GLSL float int bool No double, short, char, size_t, uint64_t, or any such No implicit conversion from float to int or int to float No requirement for particular bit sizes (up to the GPU manufacturer) But, int is at least 16 No bitwise operations vec2 (and 3 and 4), and ivec, and bvec Vectors have members x, y, z and w Also r, g, b, and a Also s, t, p, and q (for texture coordinates) Can also use array notation mat2, mat3, and mat4 Column-major Can treat it as an array of columns which are vectors Double-index works samplers: Won't make sense until we talk about textures struct and arrays work Constructor notation, NOT C static casts Qualifiers: const: Like in C attribute: Frequently changing, from application to vertex shader Can't modify these in the shader uniform: Infrequently changing, from application to either type of shader Can't modify these in the shader either varying: Information passed from a vertex shader to a fragment shader Vertex shader writes these, per vertex Fragment shader can read them, interpolated between vertices Fragment shader can't write these attribute, uniform, and varying have global scope in the shader Without a qualifier: "normal" Global scope is shared between shaders of a type (vertex or fragment) Other stuff: No goto or switch Calling: in, out, inout, but NOT by reference (copy at beginning and/or end) swizzling and vector components Ok, let's get a rotation matrix into our triangle and rotate it properly Not like last time It's kind of a hassle to have the programs embedded in the C code. Loading from a file Now we can change them without recompiling the program! Lab today: Make the triangle get a little smaller every frame You'll need a count of how many frames have happened And a formula for scaling And the framecount will have to go into the vertex shader Can use glutGet and get GLUT_ELAPSED_TIME if you prefer It'll keep the movement independent of the framerate This is a good thing