Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 25, 2006, 11:28:28 PM (18 years ago)
Author:
bensch
Message:

orxonox/new_class_id: now it should also be possible, to cache the resources, by suppling a LoadString.
This is vital to loading Resources, when you only know the TypeName and a LoadString, but not the c++-type and the LoadParameters as is the case when loading over the internet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/graphics/resource_shader.cc

    r9820 r9823  
    22#include "resource_shader.h"
    33#include "debug.h"
    4 
     4#include "substring.h"
    55
    66ResourceShader::ResourceShader(const std::string& vertexShaderName, const std::string& fragmentShaderName)
    77    : NewResource(&ResourceShader::type)
    88{
    9   Resources::StorePointer* ptr = this->acquireResource(vertexShaderName +'|'+fragmentShaderName);
     9  Resources::StorePointer* ptr = this->acquireResource(vertexShaderName +','+fragmentShaderName);
    1010
    1111  if (ptr)
     
    2323
    2424    this->Shader::load(vertexFileName, fragmentFileName);
    25     this->NewResource::addResource(new ResourceShader::ShaderResourcePointer(vertexShaderName+'|'+fragmentShaderName, Resources::KeepLevel(0), this->Shader::dataPointer()));
     25    this->NewResource::addResource(new ResourceShader::ShaderResourcePointer(vertexShaderName+','+fragmentShaderName, Resources::KeepLevel(0), this->Shader::dataPointer()));
    2626  }
    2727}
    2828
     29ResourceShader ResourceShader::createFromString(const std::string& loadString)
     30{
     31  std::string vertexShaderName;
     32  std::string fragmentShaderName;
    2933
    30 Resources::Type ResourceShader::type("Shader");
     34  SubString shaderNames(loadString, ',');
     35  if (shaderNames.size() > 0)
     36    vertexShaderName = shaderNames[0];
     37  if (shaderNames.size() > 1)
     38    fragmentShaderName = shaderNames[1];
    3139
     40  return ResourceShader(vertexShaderName, fragmentShaderName);
     41}
    3242
    33 
    34 
     43Resources::tType<ResourceShader> ResourceShader::type("Shader");
    3544
    3645ResourceShader::ShaderResourcePointer::ShaderResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const ShaderData::Pointer& data)
Note: See TracChangeset for help on using the changeset viewer.