From 8f499100e85472a68dda49be7471e97080639614 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 18 Feb 2022 05:55:42 +0100 Subject: rename source files --- TexturedQuadExample.cpp | 95 ----------------------------------------- TexturedQuadShader.cpp | 61 -------------------------- TexturedQuadShader.h | 63 --------------------------- main.cpp | 95 +++++++++++++++++++++++++++++++++++++++++ resources.conf | 4 +- shaders/TexturedQuadShader.frag | 40 ----------------- shaders/TexturedQuadShader.vert | 39 ----------------- shaders/tile-shader.frag | 40 +++++++++++++++++ shaders/tile-shader.vert | 39 +++++++++++++++++ tile-shader.cpp | 61 ++++++++++++++++++++++++++ tile-shader.hpp | 63 +++++++++++++++++++++++++++ 11 files changed, 300 insertions(+), 300 deletions(-) delete mode 100644 TexturedQuadExample.cpp delete mode 100644 TexturedQuadShader.cpp delete mode 100644 TexturedQuadShader.h create mode 100644 main.cpp delete mode 100644 shaders/TexturedQuadShader.frag delete mode 100644 shaders/TexturedQuadShader.vert create mode 100644 shaders/tile-shader.frag create mode 100644 shaders/tile-shader.vert create mode 100644 tile-shader.cpp create mode 100644 tile-shader.hpp diff --git a/TexturedQuadExample.cpp b/TexturedQuadExample.cpp deleted file mode 100644 index ec166d6e..00000000 --- a/TexturedQuadExample.cpp +++ /dev/null @@ -1,95 +0,0 @@ -#include "chunk.hpp" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "TexturedQuadShader.h" - -namespace Magnum::Examples { - -struct TexturedQuadExample: Platform::Application { - explicit TexturedQuadExample(const Arguments& arguments); - void drawEvent() override; - - const Utility::Resource rs{"texturedquad-data"}; - PluginManager::Manager plugins; - Containers::Pointer tga_importer = - plugins.loadAndInstantiate("TgaImporter"); - - GL::Mesh _mesh; - TexturedQuadShader _shader; - atlas_texture atlas = make_atlas("images/tiles.tga", {8, 4}); - - atlas_texture make_atlas(const std::string& file, Vector2i dims) - { - if(!tga_importer || !tga_importer->openFile(file)) - std::exit(1); - - Containers::Optional image = tga_importer->image2D(0); - CORRADE_INTERNAL_ASSERT(image); - - return atlas_texture{*image, dims}; - } -}; - -TexturedQuadExample::TexturedQuadExample(const Arguments& arguments): - Platform::Application{arguments, Configuration{} - .setTitle("Magnum Textured Quad Example") - .setSize({512, 512})} -{ - struct QuadVertex { - Vector3 position; - Vector2 textureCoordinates; - }; - QuadVertex vertices[4]; - auto positions = atlas.floor_quad({}, {2, 2}); - auto texcoords = atlas.texcoords_for_id(2); - auto indices = atlas.indices(0); - - for (unsigned i = 0; i < std::size(vertices); i++) - vertices[i] = { positions[i], texcoords[i] }; - - _mesh.setCount(std::size(indices)) - .addVertexBuffer(GL::Buffer{vertices}, 0, - TexturedQuadShader::Position{}, - TexturedQuadShader::TextureCoordinates{}) - .setIndexBuffer(GL::Buffer{indices}, 0, - GL::MeshIndexType::UnsignedShort); -} - -void TexturedQuadExample::drawEvent() { - GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); - - using namespace Math::Literals; - - _shader - .setColor(0xffffff_rgbf) - .bindTexture(atlas.texture()) - .draw(_mesh); - - swapBuffers(); -} - -} // namespace Magnum::Examples - -MAGNUM_APPLICATION_MAIN(Magnum::Examples::TexturedQuadExample); - -#include - -#if defined _MSC_VER -int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int /* nCmdShow */) -{ - return main(__argc, __argv); -} -#endif diff --git a/TexturedQuadShader.cpp b/TexturedQuadShader.cpp deleted file mode 100644 index c6d91c4b..00000000 --- a/TexturedQuadShader.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - This file is part of Magnum. - - Original authors — credit is appreciated but not required: - - 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, - 2020, 2021, 2022 — Vladimír Vondruš - - This is free and unencumbered software released into the public domain. - - Anyone is free to copy, modify, publish, use, compile, sell, or distribute - this software, either in source code form or as a compiled binary, for any - purpose, commercial or non-commercial, and by any means. - - In jurisdictions that recognize copyright laws, the author or authors of - this software dedicate any and all copyright interest in the software to - the public domain. We make this dedication for the benefit of the public - at large and to the detriment of our heirs and successors. We intend this - dedication to be an overt act of relinquishment in perpetuity of all - present and future rights to this software under copyright law. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include "TexturedQuadShader.h" - -#include -#include -#include -#include -#include - -namespace Magnum::Examples { - -TexturedQuadShader::TexturedQuadShader() { - MAGNUM_ASSERT_GL_VERSION_SUPPORTED(GL::Version::GL330); - - const Utility::Resource rs{"texturedquad-data"}; - - GL::Shader vert{GL::Version::GL330, GL::Shader::Type::Vertex}; - GL::Shader frag{GL::Version::GL330, GL::Shader::Type::Fragment}; - - vert.addSource(rs.get("shaders/TexturedQuadShader.vert")); - frag.addSource(rs.get("shaders/TexturedQuadShader.frag")); - - CORRADE_INTERNAL_ASSERT_OUTPUT(GL::Shader::compile({vert, frag})); - - attachShaders({vert, frag}); - - CORRADE_INTERNAL_ASSERT_OUTPUT(link()); - - _colorUniform = uniformLocation("color"); - setUniform(uniformLocation("textureData"), TextureUnit); -} - -} // namespace Magnum::Examples diff --git a/TexturedQuadShader.h b/TexturedQuadShader.h deleted file mode 100644 index de7b5c04..00000000 --- a/TexturedQuadShader.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef Magnum_Examples_TexturedQuad_TexturedQuadShader_h -#define Magnum_Examples_TexturedQuad_TexturedQuadShader_h -/* - This file is part of Magnum. - - Original authors — credit is appreciated but not required: - - 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, - 2020, 2021, 2022 — Vladimír Vondruš - - This is free and unencumbered software released into the public domain. - - Anyone is free to copy, modify, publish, use, compile, sell, or distribute - this software, either in source code form or as a compiled binary, for any - purpose, commercial or non-commercial, and by any means. - - In jurisdictions that recognize copyright laws, the author or authors of - this software dedicate any and all copyright interest in the software to - the public domain. We make this dedication for the benefit of the public - at large and to the detriment of our heirs and successors. We intend this - dedication to be an overt act of relinquishment in perpetuity of all - present and future rights to this software under copyright law. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include - -namespace Magnum::Examples { - -class TexturedQuadShader: public GL::AbstractShaderProgram { -public: - typedef GL::Attribute<0, Vector3> Position; - typedef GL::Attribute<1, Vector2> TextureCoordinates; - - explicit TexturedQuadShader(); - - TexturedQuadShader& setColor(const Color3& color) { - setUniform(_colorUniform, color); - return *this; - } - - TexturedQuadShader& bindTexture(GL::Texture2D& texture) { - texture.bind(TextureUnit); - return *this; - } - -private: - enum: Int { TextureUnit = 0 }; - - Int _colorUniform; -}; - -} // namespace Magnum::Examples - -#endif diff --git a/main.cpp b/main.cpp new file mode 100644 index 00000000..6ee11db9 --- /dev/null +++ b/main.cpp @@ -0,0 +1,95 @@ +#include "chunk.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tile-shader.hpp" + +namespace Magnum::Examples { + +struct TexturedQuadExample: Platform::Application { + explicit TexturedQuadExample(const Arguments& arguments); + void drawEvent() override; + + const Utility::Resource rs{"texturedquad-data"}; + PluginManager::Manager plugins; + Containers::Pointer tga_importer = + plugins.loadAndInstantiate("TgaImporter"); + + GL::Mesh _mesh; + TexturedQuadShader _shader; + atlas_texture atlas = make_atlas("images/tiles.tga", {8, 4}); + + atlas_texture make_atlas(const std::string& file, Vector2i dims) + { + if(!tga_importer || !tga_importer->openFile(file)) + std::exit(1); + + Containers::Optional image = tga_importer->image2D(0); + CORRADE_INTERNAL_ASSERT(image); + + return atlas_texture{*image, dims}; + } +}; + +TexturedQuadExample::TexturedQuadExample(const Arguments& arguments): + Platform::Application{arguments, Configuration{} + .setTitle("Magnum Textured Quad Example") + .setSize({512, 512})} +{ + struct QuadVertex { + Vector3 position; + Vector2 textureCoordinates; + }; + QuadVertex vertices[4]; + auto positions = atlas.floor_quad({}, {2, 2}); + auto texcoords = atlas.texcoords_for_id(2); + auto indices = atlas.indices(0); + + for (unsigned i = 0; i < std::size(vertices); i++) + vertices[i] = { positions[i], texcoords[i] }; + + _mesh.setCount(std::size(indices)) + .addVertexBuffer(GL::Buffer{vertices}, 0, + TexturedQuadShader::Position{}, + TexturedQuadShader::TextureCoordinates{}) + .setIndexBuffer(GL::Buffer{indices}, 0, + GL::MeshIndexType::UnsignedShort); +} + +void TexturedQuadExample::drawEvent() { + GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); + + using namespace Math::Literals; + + _shader + .setColor(0xffffff_rgbf) + .bindTexture(atlas.texture()) + .draw(_mesh); + + swapBuffers(); +} + +} // namespace Magnum::Examples + +MAGNUM_APPLICATION_MAIN(Magnum::Examples::TexturedQuadExample); + +#include + +#if defined _MSC_VER +int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int /* nCmdShow */) +{ + return main(__argc, __argv); +} +#endif diff --git a/resources.conf b/resources.conf index 43cf92f1..cc2e5e9e 100644 --- a/resources.conf +++ b/resources.conf @@ -1,7 +1,7 @@ group=texturedquad-data [file] -filename=shaders/TexturedQuadShader.frag +filename=shaders/tile-shader.frag [file] -filename=shaders/TexturedQuadShader.vert +filename=shaders/tile-shader.vert diff --git a/shaders/TexturedQuadShader.frag b/shaders/TexturedQuadShader.frag deleted file mode 100644 index 06d647f8..00000000 --- a/shaders/TexturedQuadShader.frag +++ /dev/null @@ -1,40 +0,0 @@ -/* - This file is part of Magnum. - - Original authors — credit is appreciated but not required: - - 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, - 2020, 2021, 2022 — Vladimír Vondruš - - This is free and unencumbered software released into the public domain. - - Anyone is free to copy, modify, publish, use, compile, sell, or distribute - this software, either in source code form or as a compiled binary, for any - purpose, commercial or non-commercial, and by any means. - - In jurisdictions that recognize copyright laws, the author or authors of - this software dedicate any and all copyright interest in the software to - the public domain. We make this dedication for the benefit of the public - at large and to the detriment of our heirs and successors. We intend this - dedication to be an overt act of relinquishment in perpetuity of all - present and future rights to this software under copyright law. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -uniform vec3 color = vec3(1.0, 1.0, 1.0); -uniform sampler2D textureData; - -in vec2 interpolatedTextureCoordinates; - -out vec4 fragmentColor; - -void main() { - fragmentColor.rgb = color*texture(textureData, interpolatedTextureCoordinates).rgb; - fragmentColor.a = 1.0; -} diff --git a/shaders/TexturedQuadShader.vert b/shaders/TexturedQuadShader.vert deleted file mode 100644 index 2fd94f8f..00000000 --- a/shaders/TexturedQuadShader.vert +++ /dev/null @@ -1,39 +0,0 @@ -/* - This file is part of Magnum. - - Original authors — credit is appreciated but not required: - - 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, - 2020, 2021, 2022 — Vladimír Vondruš - - This is free and unencumbered software released into the public domain. - - Anyone is free to copy, modify, publish, use, compile, sell, or distribute - this software, either in source code form or as a compiled binary, for any - purpose, commercial or non-commercial, and by any means. - - In jurisdictions that recognize copyright laws, the author or authors of - this software dedicate any and all copyright interest in the software to - the public domain. We make this dedication for the benefit of the public - at large and to the detriment of our heirs and successors. We intend this - dedication to be an overt act of relinquishment in perpetuity of all - present and future rights to this software under copyright law. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER - IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -layout(location = 0) in vec4 position; -layout(location = 1) in vec2 textureCoordinates; - -out vec2 interpolatedTextureCoordinates; - -void main() { - interpolatedTextureCoordinates = textureCoordinates; - - gl_Position = position; -} diff --git a/shaders/tile-shader.frag b/shaders/tile-shader.frag new file mode 100644 index 00000000..06d647f8 --- /dev/null +++ b/shaders/tile-shader.frag @@ -0,0 +1,40 @@ +/* + This file is part of Magnum. + + Original authors — credit is appreciated but not required: + + 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020, 2021, 2022 — Vladimír Vondruš + + This is free and unencumbered software released into the public domain. + + Anyone is free to copy, modify, publish, use, compile, sell, or distribute + this software, either in source code form or as a compiled binary, for any + purpose, commercial or non-commercial, and by any means. + + In jurisdictions that recognize copyright laws, the author or authors of + this software dedicate any and all copyright interest in the software to + the public domain. We make this dedication for the benefit of the public + at large and to the detriment of our heirs and successors. We intend this + dedication to be an overt act of relinquishment in perpetuity of all + present and future rights to this software under copyright law. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +uniform vec3 color = vec3(1.0, 1.0, 1.0); +uniform sampler2D textureData; + +in vec2 interpolatedTextureCoordinates; + +out vec4 fragmentColor; + +void main() { + fragmentColor.rgb = color*texture(textureData, interpolatedTextureCoordinates).rgb; + fragmentColor.a = 1.0; +} diff --git a/shaders/tile-shader.vert b/shaders/tile-shader.vert new file mode 100644 index 00000000..2fd94f8f --- /dev/null +++ b/shaders/tile-shader.vert @@ -0,0 +1,39 @@ +/* + This file is part of Magnum. + + Original authors — credit is appreciated but not required: + + 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020, 2021, 2022 — Vladimír Vondruš + + This is free and unencumbered software released into the public domain. + + Anyone is free to copy, modify, publish, use, compile, sell, or distribute + this software, either in source code form or as a compiled binary, for any + purpose, commercial or non-commercial, and by any means. + + In jurisdictions that recognize copyright laws, the author or authors of + this software dedicate any and all copyright interest in the software to + the public domain. We make this dedication for the benefit of the public + at large and to the detriment of our heirs and successors. We intend this + dedication to be an overt act of relinquishment in perpetuity of all + present and future rights to this software under copyright law. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +layout(location = 0) in vec4 position; +layout(location = 1) in vec2 textureCoordinates; + +out vec2 interpolatedTextureCoordinates; + +void main() { + interpolatedTextureCoordinates = textureCoordinates; + + gl_Position = position; +} diff --git a/tile-shader.cpp b/tile-shader.cpp new file mode 100644 index 00000000..dd61f67c --- /dev/null +++ b/tile-shader.cpp @@ -0,0 +1,61 @@ +/* + This file is part of Magnum. + + Original authors — credit is appreciated but not required: + + 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020, 2021, 2022 — Vladimír Vondruš + + This is free and unencumbered software released into the public domain. + + Anyone is free to copy, modify, publish, use, compile, sell, or distribute + this software, either in source code form or as a compiled binary, for any + purpose, commercial or non-commercial, and by any means. + + In jurisdictions that recognize copyright laws, the author or authors of + this software dedicate any and all copyright interest in the software to + the public domain. We make this dedication for the benefit of the public + at large and to the detriment of our heirs and successors. We intend this + dedication to be an overt act of relinquishment in perpetuity of all + present and future rights to this software under copyright law. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "tile-shader.hpp" + +#include +#include +#include +#include +#include + +namespace Magnum::Examples { + +TexturedQuadShader::TexturedQuadShader() { + MAGNUM_ASSERT_GL_VERSION_SUPPORTED(GL::Version::GL330); + + const Utility::Resource rs{"texturedquad-data"}; + + GL::Shader vert{GL::Version::GL330, GL::Shader::Type::Vertex}; + GL::Shader frag{GL::Version::GL330, GL::Shader::Type::Fragment}; + + vert.addSource(rs.get("shaders/tile-shader.vert")); + frag.addSource(rs.get("shaders/tile-shader.frag")); + + CORRADE_INTERNAL_ASSERT_OUTPUT(GL::Shader::compile({vert, frag})); + + attachShaders({vert, frag}); + + CORRADE_INTERNAL_ASSERT_OUTPUT(link()); + + _colorUniform = uniformLocation("color"); + setUniform(uniformLocation("textureData"), TextureUnit); +} + +} // namespace Magnum::Examples diff --git a/tile-shader.hpp b/tile-shader.hpp new file mode 100644 index 00000000..de7b5c04 --- /dev/null +++ b/tile-shader.hpp @@ -0,0 +1,63 @@ +#ifndef Magnum_Examples_TexturedQuad_TexturedQuadShader_h +#define Magnum_Examples_TexturedQuad_TexturedQuadShader_h +/* + This file is part of Magnum. + + Original authors — credit is appreciated but not required: + + 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2020, 2021, 2022 — Vladimír Vondruš + + This is free and unencumbered software released into the public domain. + + Anyone is free to copy, modify, publish, use, compile, sell, or distribute + this software, either in source code form or as a compiled binary, for any + purpose, commercial or non-commercial, and by any means. + + In jurisdictions that recognize copyright laws, the author or authors of + this software dedicate any and all copyright interest in the software to + the public domain. We make this dedication for the benefit of the public + at large and to the detriment of our heirs and successors. We intend this + dedication to be an overt act of relinquishment in perpetuity of all + present and future rights to this software under copyright law. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include +#include +#include + +namespace Magnum::Examples { + +class TexturedQuadShader: public GL::AbstractShaderProgram { +public: + typedef GL::Attribute<0, Vector3> Position; + typedef GL::Attribute<1, Vector2> TextureCoordinates; + + explicit TexturedQuadShader(); + + TexturedQuadShader& setColor(const Color3& color) { + setUniform(_colorUniform, color); + return *this; + } + + TexturedQuadShader& bindTexture(GL::Texture2D& texture) { + texture.bind(TextureUnit); + return *this; + } + +private: + enum: Int { TextureUnit = 0 }; + + Int _colorUniform; +}; + +} // namespace Magnum::Examples + +#endif -- cgit v1.2.3