diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-12 16:12:01 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-12-12 16:12:01 +0000 |
commit | 6c268e0f98722c3253366b639a3a0abe37c8835d (patch) | |
tree | 409376e0b302009d29ed27dcb4601f037f377e6f /gfx/gl/uiShader.cpp | |
parent | Move program handle to its own files (diff) | |
download | ilt-6c268e0f98722c3253366b639a3a0abe37c8835d.tar.bz2 ilt-6c268e0f98722c3253366b639a3a0abe37c8835d.tar.xz ilt-6c268e0f98722c3253366b639a3a0abe37c8835d.zip |
Introduce the UI shader
Diffstat (limited to 'gfx/gl/uiShader.cpp')
-rw-r--r-- | gfx/gl/uiShader.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gfx/gl/uiShader.cpp b/gfx/gl/uiShader.cpp new file mode 100644 index 0000000..2fbb0d4 --- /dev/null +++ b/gfx/gl/uiShader.cpp @@ -0,0 +1,14 @@ +#include "uiShader.h" +#include <gfx/gl/shaders/fs-uiShader.h> +#include <gfx/gl/shaders/vs-uiShader.h> +#include <glm/gtc/type_ptr.hpp> +#include <glm/gtx/transform.hpp> + +UIShader::UIShader(size_t width, size_t height) : program {uiShader_vs.compile(), uiShader_fs.compile()} +{ + if (auto loc = glGetUniformLocation(program.m_program, "uiProjection"); loc >= 0) { + glUseProgram(program.m_program); + const auto uiProjection = glm::ortho<float>(0, static_cast<float>(width), 0, static_cast<float>(height)); + glUniformMatrix4fv(loc, 1, GL_FALSE, glm::value_ptr(uiProjection)); + } +} |