mitsuba/src/libhw/gpuprogram.cpp

57 lines
1.5 KiB
C++
Raw Normal View History

/*
This file is part of Mitsuba, a physically based rendering system.
2011-04-14 21:15:59 +08:00
Copyright (c) 2007-2011 by Wenzel Jakob and others.
Mitsuba is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License Version 3
as published by the Free Software Foundation.
Mitsuba is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
2011-04-14 21:15:59 +08:00
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mitsuba/hw/gpuprogram.h>
MTS_NAMESPACE_BEGIN
GPUProgram::GPUProgram(const std::string &name)
: m_name(name), m_maxVertices(0), m_bound(false) {
}
GPUProgram::~GPUProgram() {
}
2011-02-24 03:45:49 +08:00
void GPUProgram::setSourceFile(EType type, const fs::path &path) {
fs::ifstream ifs(path);
if (ifs.fail() || ifs.bad())
Log(EError, "Unable to load GPU program \"%s\"",
path.file_string().c_str());
2011-02-24 03:45:49 +08:00
std::string code, line;
while (getline(ifs, line)) {
code += line;
code += "\n";
}
ifs.close();
setSource(type, code);
}
std::string GPUProgram::toString() const {
std::ostringstream oss;
oss << "GPUProgram[name = '" << m_name<< "'";
if (m_maxVertices != 0)
oss << ", maxVertices=" << m_maxVertices;
oss << "]";
return oss.str();
}
MTS_IMPLEMENT_CLASS(GPUProgram, true, Object)
MTS_NAMESPACE_END