diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-10-22 07:29:34 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-10-22 07:29:34 +0200 |
commit | a80bf6bb6cb8ab8c5a1430f9f9dbc214f71bdddf (patch) | |
tree | efcab64abdcfa211020bf4410e12d6182a1c8d90 /tests | |
parent | c9ee5e1c1feccb073863ba17cbfdcf094f235886 (diff) |
Use shader
Diffstat (limited to 'tests')
-rw-r--r-- | tests/main.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tests/main.cpp b/tests/main.cpp index bca9f67..68e3778 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -8,6 +8,7 @@ #include <mglpp/graphics/Text.hpp> #include <mglpp/graphics/Rectangle.hpp> #include <mglpp/graphics/VertexBuffer.hpp> +#include <mglpp/graphics/Shader.hpp> struct Delegate { Delegate() {} @@ -17,9 +18,11 @@ struct Delegate { rect.set_color({255, 0, 0, 255}); window->draw(rect); + shader_program->set_uniform("resolution", mgl::vec2f(window->get_size().x, window->get_size().y)); + mgl::Sprite sprite(*texture, { 100.0f - 10.0f, 0.0f }); sprite.set_color({255, 255, 255, 128}); - window->draw(sprite); + window->draw(sprite, shader_program); mgl::Text text("hello world!\nGood bye world!", { 0.0f, 0.0f }, *font); window->draw(text); @@ -32,6 +35,7 @@ struct Delegate { mgl::Texture *texture; mgl::Font *font; mgl::VertexBuffer *vertex_buffer; + mgl::Shader *shader_program; }; int main(int argc, char **argv) { @@ -49,6 +53,10 @@ int main(int argc, char **argv) { if(!font.load_from_file("/usr/share/fonts/noto/NotoSans-Regular.ttf", 32)) return 1; + mgl::Shader shader; + if(!shader.load_from_file("depends/mgl/tests/circle_mask.glsl", mgl::Shader::Fragment)) + return 1; + mgl::Vertex vertices[4] = { { {0.0f, 0.0f}, @@ -83,6 +91,7 @@ int main(int argc, char **argv) { delegate.texture = &texture; delegate.font = &font; delegate.vertex_buffer = &vertex_buffer; + delegate.shader_program = &shader; mgl::Event event; while(true) { |