Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9820 in orxonox.OLD for branches/new_class_id


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

added resource_shader, the new ResourceLoadHandler for the Shader

Location:
branches/new_class_id/src
Files:
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/graphics/Makefile.am

    r9818 r9820  
    1010                shader.cc \
    1111                shader_data.cc \
     12                resource_shader.cc \
    1213                \
    1314                render2D/render_2d.cc \
     
    2829                shader.h \
    2930                shader_data.h \
     31                resource_shader.h \
    3032                \
    3133                render2D/render_2d.h \
  • 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 
  • branches/new_class_id/src/lib/graphics/resource_shader.h

    r9818 r9820  
    11/*!
    2  * @file resource_texture.h
    3  * @brief Contains the ResourceTexture class, that handles the Resource-specific loading part of the Texture.
     2 * @file resource_shader.h
     3 * @brief Contains the ResourceShader class, that handles the Resource-specific loading part of the Shader.
    44 *
    55 */
    66
    7 #ifndef _RESOURCE_TEXTURE_H
    8 #define _RESOURCE_TEXTURE_H
     7#ifndef _RESOURCE_SHADER_H
     8#define _RESOURCE_SHADER_H
    99
    1010#include "util/loading/resource.h"
    11 #include "texture.h"
     11#include "shader.h"
    1212
    1313
    14 class ResourceTexture : public Texture, public Resources::NewResource
     14class ResourceShader : public Shader, public Resources::NewResource
    1515{
    1616public:
    17   ResourceTexture(const std::string& imageName, GLenum target = GL_TEXTURE_2D);
     17  ResourceShader(const std::string& vertexShaderName, const std::string& fragmentShaderName);
    1818
    1919
    2020private:
    21 class TextureResourcePointer : public Resources::StorePointer
     21class ShaderResourcePointer : public Resources::StorePointer
    2222  {
    2323  public:
    24     TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data);
    25     inline const TextureData::Pointer& ptr() const { return pointer; }
     24    ShaderResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const ShaderData::Pointer& data);
     25    inline const ShaderData::Pointer& ptr() const { return pointer; }
    2626  private:
    27     TextureData::Pointer pointer;
     27    ShaderData::Pointer pointer;
    2828  };
    2929
     
    3333
    3434
    35 #endif /* _RESOURCE_TEXTURE_H */
     35#endif /* _RESOURCE_SHADER_H */
  • branches/new_class_id/src/world_entities/environments/mapped_water.cc

    r9818 r9820  
    164164{
    165165  // load shader files
    166   shader = Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
     166  shader = Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/mapped_water.vert",
     167                   ResourceManager::getInstance()->getDataDir() +"/shaders/mapped_water.frag");
    167168
    168169  this->shader.activateShader();
Note: See TracChangeset for help on using the changeset viewer.