Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

added resource_shader, the new ResourceLoadHandler for the Shader

File:
1 copied

Legend:

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

    r9818 r9820  
    11
    2 #include "resource_texture.h"
     2#include "resource_shader.h"
    33#include "debug.h"
    44
    55
    6 ResourceTexture::ResourceTexture(const std::string& imageName, GLenum target)
    7     : NewResource(&ResourceTexture::type)
     6ResourceShader::ResourceShader(const std::string& vertexShaderName, const std::string& fragmentShaderName)
     7    : NewResource(&ResourceShader::type)
    88{
    9   Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + "TEST");
     9  Resources::StorePointer* ptr = this->acquireResource(vertexShaderName +'|'+fragmentShaderName);
    1010
    1111  if (ptr)
    1212  {
    13     PRINTF(5)("FOUNT TEXTURE: %s\n", imageName.c_str());
    14     this->acquireData(static_cast<ResourceTexture::TextureResourcePointer*>(ptr)->ptr());
     13    PRINTF(5)("FOUND SHADER: %s\n", vertexShaderName.c_str());
     14    this->acquireData(static_cast<ResourceShader::ShaderResourcePointer*>(ptr)->ptr());
    1515  }
    1616  else
    1717  {
    18     PRINTF(5)("NOT FOUNT TEXTURE: %s\n", imageName.c_str());
    19     std::string fileName = this->NewResource::locateFile(imageName);
    20     this->Texture::loadImage(fileName, target);
    21     this->NewResource::addResource(new ResourceTexture::TextureResourcePointer(imageName + ',' + "TEST", Resources::KeepLevel(0), this->Texture::dataPointer()));
     18    PRINTF(5)("NOT FOUND SHADER: %s\n", vertexShaderName.c_str());
     19    std::string vertexFileName = this->NewResource::locateFile(vertexShaderName);
     20    std::string fragmentFileName;
     21    if (!fragmentShaderName.empty())
     22      fragmentFileName = this->NewResource::locateFile(fragmentShaderName);
     23
     24    this->Shader::load(vertexFileName, fragmentFileName);
     25    this->NewResource::addResource(new ResourceShader::ShaderResourcePointer(vertexShaderName+'|'+fragmentShaderName, Resources::KeepLevel(0), this->Shader::dataPointer()));
    2226  }
    2327}
    2428
    2529
    26 Resources::Type ResourceTexture::type("Texture");
     30Resources::Type ResourceShader::type("Shader");
    2731
    2832
     
    3034
    3135
    32 ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data)
     36ResourceShader::ShaderResourcePointer::ShaderResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const ShaderData::Pointer& data)
    3337    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
    3438{}
    35 
    36 
Note: See TracChangeset for help on using the changeset viewer.