diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-02-18 06:14:39 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-02-18 06:14:39 +0100 |
commit | 0a49fb9df26c1a7b5a8a156b32f5ff2bf771e6ac (patch) | |
tree | 419c72f372b02af1ab9aab324b1e22324e0f8767 | |
parent | e6a030dfc955bd50adf9d55ab29861586a0777cf (diff) |
rename types
-rw-r--r-- | main.cpp | 18 | ||||
-rw-r--r-- | tile-shader.cpp | 8 | ||||
-rw-r--r-- | tile-shader.hpp | 13 |
3 files changed, 17 insertions, 22 deletions
@@ -18,8 +18,8 @@ namespace Magnum::Examples { -struct TexturedQuadExample: Platform::Application { - explicit TexturedQuadExample(const Arguments& arguments); +struct application : Platform::Application { + explicit application(const Arguments& arguments); void drawEvent() override; const Utility::Resource rs{"texturedquad-data"}; @@ -28,7 +28,7 @@ struct TexturedQuadExample: Platform::Application { plugins.loadAndInstantiate("TgaImporter"); GL::Mesh _mesh; - TexturedQuadShader _shader; + tile_shader _shader; atlas_texture atlas = make_atlas("images/tiles.tga", {8, 4}); atlas_texture make_atlas(const std::string& file, Vector2i dims) @@ -43,7 +43,7 @@ struct TexturedQuadExample: Platform::Application { } }; -TexturedQuadExample::TexturedQuadExample(const Arguments& arguments): +application::application(const Arguments& arguments): Platform::Application{arguments, Configuration{} .setTitle("Magnum Textured Quad Example") .setSize({512, 512})} @@ -60,15 +60,13 @@ TexturedQuadExample::TexturedQuadExample(const Arguments& arguments): 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{}) + _mesh.setCount((int)std::size(indices)) + .addVertexBuffer(GL::Buffer{vertices}, 0, tile_shader::Position{}, tile_shader::TextureCoordinates{}) .setIndexBuffer(GL::Buffer{indices}, 0, GL::MeshIndexType::UnsignedShort); } -void TexturedQuadExample::drawEvent() { +void application::drawEvent() { GL::defaultFramebuffer.clear(GL::FramebufferClear::Color); using namespace Math::Literals; @@ -83,7 +81,7 @@ void TexturedQuadExample::drawEvent() { } // namespace Magnum::Examples -MAGNUM_APPLICATION_MAIN(Magnum::Examples::TexturedQuadExample); +MAGNUM_APPLICATION_MAIN(Magnum::Examples::application); #include <windows.h> diff --git a/tile-shader.cpp b/tile-shader.cpp index dd61f67c..2e92cfc1 100644 --- a/tile-shader.cpp +++ b/tile-shader.cpp @@ -37,13 +37,13 @@ namespace Magnum::Examples { -TexturedQuadShader::TexturedQuadShader() { - MAGNUM_ASSERT_GL_VERSION_SUPPORTED(GL::Version::GL330); +tile_shader::tile_shader() { + MAGNUM_ASSERT_GL_VERSION_SUPPORTED(GL::Version::GL460); 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}; + GL::Shader vert{GL::Version::GL460, GL::Shader::Type::Vertex}; + GL::Shader frag{GL::Version::GL460, GL::Shader::Type::Fragment}; vert.addSource(rs.get("shaders/tile-shader.vert")); frag.addSource(rs.get("shaders/tile-shader.frag")); diff --git a/tile-shader.hpp b/tile-shader.hpp index de7b5c04..68a2c0e5 100644 --- a/tile-shader.hpp +++ b/tile-shader.hpp @@ -1,5 +1,4 @@ -#ifndef Magnum_Examples_TexturedQuad_TexturedQuadShader_h -#define Magnum_Examples_TexturedQuad_TexturedQuadShader_h +#pragma once /* This file is part of Magnum. @@ -35,19 +34,19 @@ namespace Magnum::Examples { -class TexturedQuadShader: public GL::AbstractShaderProgram { +class tile_shader : public GL::AbstractShaderProgram { public: typedef GL::Attribute<0, Vector3> Position; typedef GL::Attribute<1, Vector2> TextureCoordinates; - explicit TexturedQuadShader(); + explicit tile_shader(); - TexturedQuadShader& setColor(const Color3& color) { + tile_shader& setColor(const Color3& color) { setUniform(_colorUniform, color); return *this; } - TexturedQuadShader& bindTexture(GL::Texture2D& texture) { + tile_shader& bindTexture(GL::Texture2D& texture) { texture.bind(TextureUnit); return *this; } @@ -59,5 +58,3 @@ private: }; } // namespace Magnum::Examples - -#endif |