]> git.sesse.net Git - casparcg/blobdiff - core/mixer/gpu/shader.cpp
2.1.0: Merged bug fixes from 2.0.2.
[casparcg] / core / mixer / gpu / shader.cpp
index ca5a7f55957107c45991c0dc3fc9fe0974b88a17..ffd20de2788f46fba708809cf08edfd140bfa881 100644 (file)
@@ -1,9 +1,32 @@
+/*\r
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
+*\r
+* This file is part of CasparCG (www.casparcg.com).\r
+*\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
+*\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+* Author: Robert Nagy, ronag89@gmail.com\r
+*/\r
+\r
 #include "../../../stdafx.h"\r
 \r
 #include "shader.h"\r
 \r
 #include <common/gl/gl_check.h>\r
 \r
+#include <gl/glew.h>\r
+\r
 #include <unordered_map>\r
 \r
 namespace caspar { namespace core {\r
@@ -89,10 +112,10 @@ public:
                        it = locations_.insert(std::make_pair(name, glGetUniformLocation(program_, name))).first;\r
                return it->second;\r
        }\r
-\r
-       void use()\r
-       {       \r
-               GL(glUseProgramObjectARB(program_));            \r
+       \r
+       void set(const std::string& name, bool value)\r
+       {\r
+               set(name, value ? 1 : 0);\r
        }\r
 \r
        void set(const std::string& name, int value)\r
@@ -104,12 +127,19 @@ public:
        {\r
                GL(glUniform1f(get_location(name.c_str()), value));\r
        }\r
+\r
+       void set(const std::string& name, double value)\r
+       {\r
+               GL(glUniform1f(get_location(name.c_str()), static_cast<float>(value)));\r
+       }\r
 };\r
 \r
 \r
 shader::shader(const std::string& vertex_source_str, const std::string& fragment_source_str) : impl_(new implementation(vertex_source_str, fragment_source_str)){}\r
-void shader::use(){impl_->use();}\r
+void shader::set(const std::string& name, bool value){impl_->set(name, value);}\r
 void shader::set(const std::string& name, int value){impl_->set(name, value);}\r
 void shader::set(const std::string& name, float value){impl_->set(name, value);}\r
+void shader::set(const std::string& name, double value){impl_->set(name, value);}\r
+int shader::id() const{return impl_->program_;}\r
 \r
 }}
\ No newline at end of file