Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/resource_shader.cc @ 10328

Last change on this file since 10328 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 1.8 KB
RevLine 
[9781]1
[9820]2#include "resource_shader.h"
[9790]3#include "debug.h"
[9823]4#include "substring.h"
[9781]5
[9854]6ResourceShader::ResourceShader(const std::string& vertexShaderName, const std::string& fragmentShaderName, const Resources::KeepLevel& keepLevel)
[9847]7    : Resource(&ResourceShader::type)
[9784]8{
[9823]9  Resources::StorePointer* ptr = this->acquireResource(vertexShaderName +','+fragmentShaderName);
[9781]10
[9784]11  if (ptr)
[9786]12  {
[9820]13    PRINTF(5)("FOUND SHADER: %s\n", vertexShaderName.c_str());
14    this->acquireData(static_cast<ResourceShader::ShaderResourcePointer*>(ptr)->ptr());
[9786]15  }
[9784]16  else
17  {
[9820]18    PRINTF(5)("NOT FOUND SHADER: %s\n", vertexShaderName.c_str());
[9847]19    std::string vertexFileName = this->Resource::locateFile(vertexShaderName);
[9820]20    std::string fragmentFileName;
21    if (!fragmentShaderName.empty())
[9847]22      fragmentFileName = this->Resource::locateFile(fragmentShaderName);
[9820]23
24    this->Shader::load(vertexFileName, fragmentFileName);
[9854]25    this->Resource::addResource(new ResourceShader::ShaderResourcePointer(vertexShaderName+','+fragmentShaderName, keepLevel, this->Shader::dataPointer()));
[9784]26  }
27}
28
[9854]29ResourceShader ResourceShader::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel)
[9823]30{
31  std::string vertexShaderName;
32  std::string fragmentShaderName;
[9784]33
[9823]34  SubString shaderNames(loadString, ',');
35  if (shaderNames.size() > 0)
36    vertexShaderName = shaderNames[0];
37  if (shaderNames.size() > 1)
38    fragmentShaderName = shaderNames[1];
[9784]39
[9854]40  return ResourceShader(vertexShaderName, fragmentShaderName, keepLevel);
[9823]41}
[9784]42
[9823]43Resources::tType<ResourceShader> ResourceShader::type("Shader");
[9784]44
[9820]45ResourceShader::ShaderResourcePointer::ShaderResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const ShaderData::Pointer& data)
[9791]46    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
[9785]47{}
Note: See TracBrowser for help on using the repository browser.