1 #ifndef Magnum_Examples_ReflectorShader_h 2 #define Magnum_Examples_ReflectorShader_h 3 /* 4 This file is part of Magnum. 5 6 Original authors — credit is appreciated but not required: 7 8 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 — 9 Vladimír Vondruš <mosra@centrum.cz> 10 11 This is free and unencumbered software released into the public domain. 12 13 Anyone is free to copy, modify, publish, use, compile, sell, or distribute 14 this software, either in source code form or as a compiled binary, for any 15 purpose, commercial or non-commercial, and by any means. 16 17 In jurisdictions that recognize copyright laws, the author or authors of 18 this software dedicate any and all copyright interest in the software to 19 the public domain. We make this dedication for the benefit of the public 20 at large and to the detriment of our heirs and successors. We intend this 21 dedication to be an overt act of relinquishment in perpetuity of all 22 present and future rights to this software under copyright law. 23 24 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 27 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 28 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 */ 31 32 #include <Magnum/GL/AbstractShaderProgram.h> 33 #include <Magnum/Math/Color.h> 34 #include <Magnum/Math/Matrix3.h> 35 #include <Magnum/Math/Matrix4.h> 36 37 namespace Magnum { namespace Examples { 38 39 class ReflectorShader: public GL::AbstractShaderProgram { 40 public: 41 typedef GL::Attribute<0, Vector3> Position; 42 typedef GL::Attribute<1, Vector2> TextureCoords; 43 44 explicit ReflectorShader(); 45 setTransformationMatrix(const Matrix4 & matrix)46 ReflectorShader& setTransformationMatrix(const Matrix4& matrix) { 47 setUniform(_transformationMatrixUniform, matrix); 48 return *this; 49 } 50 setNormalMatrix(const Matrix3 & matrix)51 ReflectorShader& setNormalMatrix(const Matrix3& matrix) { 52 setUniform(_normalMatrixUniform, matrix); 53 return *this; 54 } 55 setProjectionMatrix(const Matrix4 & matrix)56 ReflectorShader& setProjectionMatrix(const Matrix4& matrix) { 57 setUniform(_projectionMatrixUniform, matrix); 58 return *this; 59 } 60 setCameraMatrix(const Matrix3 & matrix)61 ReflectorShader& setCameraMatrix(const Matrix3& matrix) { 62 setUniform(_cameraMatrixUniform, matrix); 63 return *this; 64 } 65 setReflectivity(Float reflectivity)66 ReflectorShader& setReflectivity(Float reflectivity) { 67 setUniform(_reflectivityUniform, reflectivity); 68 return *this; 69 } 70 setDiffuseColor(const Color3 & color)71 ReflectorShader& setDiffuseColor(const Color3& color) { 72 setUniform(_diffuseColorUniform, color); 73 return *this; 74 } 75 76 ReflectorShader& setTexture(GL::CubeMapTexture& texture); 77 78 ReflectorShader& setTarnishTexture(GL::Texture2D& texture); 79 80 private: 81 Int _transformationMatrixUniform, 82 _normalMatrixUniform, 83 _projectionMatrixUniform, 84 _cameraMatrixUniform, 85 _reflectivityUniform, 86 _diffuseColorUniform; 87 }; 88 89 }} 90 91 #endif 92