Shaders in GLSL Flashcards
What is not allowed in a fragment shader?
No access to adjacent fragments. Cannot change fragment position.
What are the conversion rules for GLSL?
There is no implicit conversion.
What are the basic types for GLSL?
void bool int float vec2 vec3 vec4 bvec2 bvec3 bvec4 ivec2 ivec3 ivec4 mat2 mat3 mat4 sampler2D samplerCube
What are the non-type keywords in GLSL?
attribute const uniform varying break continue do for while if else in out inout true false lowp mediump highp precision invariant discard return struct
What preprocessor directives are defined in GLSL?
# #define #undef #if #ifdef #ifndef #else #elif #endif #error #pragma #extension #version #line
What is the operator precedence for GLSL?
() defined + - ~ ! * / % \+ - << >> < > = == != & ^ | && ||
What is a sampler type?
Sampler2D and SamplerCube are opaque handlers to textures.
What are the usage restrictions on sampler types?
They can only be declared as function parameters or uniforms. Their use in expressions is limited. The cannot be used as out or inout function parameters.
What is an anonymous structure?
This: struct S { int i; }; S myStruct; // Illegal in GLSL, need "struct S myStruct"
What is an embedded structure definition?
struct S { struct T { } } // Illegal in GLSL, but this is OK: struct T { } struct S { T foo; }
How are arrays initialized at declaration in GLSL?
This is impossible.
How are variables scoped in GLSL?
By a system of statically nested scopes, as in C or Java { { } }.
What is the only shared global allowed in GLSL?
uniform
How is const used in GLSL?
Compile-time constants and read-only function parameters.
What is a GLSL attribute?
A linkage between a vertex shader and OpenGL ES per-vertex data
What is a GLSL uniform?
Uniforms form the linkage between a fragment shader, OpenGL ES, and the application. This value does not change across the primitive being processed.
What is a GLSL varying?
A linkage between a vertex shader and a fragment shader through interpolation.