u authored by Hannu Hanhi's avatar Hannu Hanhi
...@@ -15,7 +15,7 @@ Prepares the shader system for use. Compiles the fallback shader. Returns false ...@@ -15,7 +15,7 @@ Prepares the shader system for use. Compiles the fallback shader. Returns false
- `void LoadShader(int slot, char *code, hwdshaderstage_t stage)` - `void LoadShader(int slot, char *code, hwdshaderstage_t stage)`
Loads shader source code from the null-terminated string `code` into `slot`. Slots start from 1, the first slot 0 is reserved for the fallback shader. `stage` is either fragment or vertex. (Perhaps in the future the rest of the stages could be added) Loads shader source code from the null-terminated string `code` into `slot`. Valid slots are from 0 to `HWR_MAXSHADERS`. `stage` is either `HWD_SHADERSTAGE_VERTEX` or `HWD_SHADERSTAGE_FRAGMENT`. The memory in `code` belongs to the backend now. Any previous shader code in `slot` and `stage` is freed from memory. (Perhaps in the far future the rest of the stages could be added)
- `boolean CompileShader(int slot)` - `boolean CompileShader(int slot)`
...@@ -37,6 +37,28 @@ The fixed function pipeline is used for draw calls instead of shaders. (used for ...@@ -37,6 +37,28 @@ The fixed function pipeline is used for draw calls instead of shaders. (used for
Sets certain values that are given to shader uniform variables. (currently only level time) Sets certain values that are given to shader uniform variables. (currently only level time)
hw_shaders.c
------------
Each geometry type has a "shader target", which contains references to the vanilla and custom shaders used for that geometry. `HWR_GetShaderFromTarget` is used to get the shader that should currently be used for that target.
```
enum
{
SHADER_FLOOR,
SHADER_WALL,
SHADER_SPRITE,
SHADER_MODEL,
SHADER_WATER,
SHADER_FOG,
SHADER_SKY,
NUMSHADERTARGETS,
};
```
Custom shader loading functions from `hw_main.c` are adapted and moved to `hw_shaders.c`.
The shader "pre-preprocessor" The shader "pre-preprocessor"
----------------------------- -----------------------------
... ...
......