Part of a [[Program (GPU)]].
Shaders first live in the [[CPU]] as plain [[Me Bitching about C++/Null Terminated|Null Terminated]] strings, and when the [[CPU]] program starts - it will send the shader to the [[GPU]] for it to compile and eventually linked.
>[!example] Compiling a shader with [[OpenGL]]
>```cpp
>u32 compile_shader(const char* const fragment_shader) {
> u32 shader = glCreateShader(GL_FRAGMENT_SHADER);
> glShaderSource(shader, 1, &fragment_shader, 0);
> glCompileShader(shader):
>
> i32 success = 0;
> glGetShaderiv(shader, GL_COMPILE_STATUS, &success);
>
> if (not shader) {
> char info_log[512];
> glGetShaderInfoLog(shader, sizeof(info_log), 0, info_log);
> std::cerr << "Failed to compile: " << info_log << std::endl;
> return 0;
> }
>
> return shader;
>}
>``