Created
November 20, 2018 16:26
-
-
Save minexew/7862643493e4335b75e633e2236f4abe to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Renderer.hpp | |
class ShaderGlobal { | |
public: | |
ShaderGlobal(const char* name) { | |
this->handle = Rend::CreateShaderGlobal(name); | |
} | |
template <typename T> | |
void operator = (const T& value) { | |
Rend::UpdateShaderGlobal(this->handle, value); | |
} | |
private: | |
void* handle; | |
}; | |
// Game.hpp | |
struct MyShaderGlobals { | |
ShaderGlobal sun_dir = "sun_dir", | |
sun_ambient = "sun_amb", | |
sun_diffuse = "sun_diff", | |
sun_specular = "sun_spec"; | |
}; | |
MyShaderGlobals shaderGlobal; | |
// Game.cpp | |
// Automagically propagate uniform to the current shader and any shaders bound in the future | |
shaderGlobal.sun_diffuse = Float4(1.0, 0.9, 0.5, 1.0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment