You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openmw/components/bgsm/reader.cpp

34 lines
810 B
C++

#include "reader.hpp"
#include <array>
#include <stdexcept>
#include <string>
#include "stream.hpp"
namespace Bgsm
{
void Reader::parse(Files::IStreamPtr&& inputStream)
{
BGSMStream stream(std::move(inputStream));
std::array<char, 4> signature;
stream.readArray(signature);
std::string shaderType(signature.data(), 4);
if (shaderType == "BGEM")
{
mFile = std::make_unique<BGEMFile>();
mFile->mShaderType = Bgsm::ShaderType::Effect;
}
else if (shaderType == "BGSM")
{
mFile = std::make_unique<BGSMFile>();
mFile->mShaderType = Bgsm::ShaderType::Lighting;
}
else
throw std::runtime_error("Invalid material file");
mFile->read(stream);
}
}