source/Graphics/Shader.cpp: use the new File API
This commit is contained in:
parent
624a979356
commit
59a4f1347a
1 changed files with 11 additions and 11 deletions
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
#include <fstream>
|
||||
#include <Spectre/System/Path.h>
|
||||
#include <Spectre/System/File.h>
|
||||
#include <Spectre/Graphics/Shader.h>
|
||||
#include <Graphics/GL/gl.h>
|
||||
|
||||
|
|
@ -30,26 +30,26 @@ const std::string& Shader::getName() const
|
|||
return m_name;
|
||||
}
|
||||
|
||||
bool Shader::loadFromFile(const std::string& file)
|
||||
bool Shader::loadFromFile(const std::string& filename)
|
||||
{
|
||||
std::string src;
|
||||
std::ifstream strm;
|
||||
File file;
|
||||
|
||||
// If this shader does not have a name, pick the filename.
|
||||
if (m_name.length() < 1) {
|
||||
m_name = Path::getBasename(file);
|
||||
m_name = Path::getBasename(filename);
|
||||
}
|
||||
|
||||
// Load file into memory.
|
||||
strm.open(file.c_str(), std::fstream::in);
|
||||
if (!strm.is_open()) {
|
||||
m_error = "Can't open file: " + file;
|
||||
if (!file.open(filename)) {
|
||||
m_error = "Can't open file: " + filename;
|
||||
return false;
|
||||
}
|
||||
|
||||
src.assign(std::istreambuf_iterator<char>(strm), std::istreambuf_iterator<char>());
|
||||
|
||||
strm.close();
|
||||
// Load file into memory.
|
||||
if (!file.read(src)) {
|
||||
m_error = "Could not read file: " + filename;
|
||||
return false;
|
||||
}
|
||||
|
||||
return loadFromMemory(src);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue