Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/ai/src/lib/graphics/importer/resource_texture.cc @ 10266

Last change on this file since 10266 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.6 KB
Line 
1
2#include "resource_texture.h"
3#include "substring.h"
4#include "multi_type.h"
5#include "debug.h"
6
7
8ResourceTexture::ResourceTexture(const std::string& imageName, GLenum target, const Resources::KeepLevel& keepLevel)
9    : Resource(&ResourceTexture::type)
10{
11  Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + MultiType((int)target).getString());
12
13  if (ptr)
14  {
15    PRINTF(5)("FOUND TEXTURE: %s\n", imageName.c_str());
16    this->acquireData(static_cast<ResourceTexture::TextureResourcePointer*>(ptr)->ptr());
17  }
18  else
19  {
20    PRINTF(5)("NOT FOUND TEXTURE: %s\n", imageName.c_str());
21    std::string fileName = this->Resource::locateFile(imageName);
22    this->Texture::loadImage(fileName, target);
23    this->Resource::addResource(new ResourceTexture::TextureResourcePointer(imageName + ',' + MultiType((int)target).getString(), keepLevel, this->Texture::dataPointer()));
24  }
25}
26
27ResourceTexture ResourceTexture::createFromString(const std::string& loadString, const Resources::KeepLevel& keepLevel)
28{
29  SubString loadValues(loadString, ',');
30  std::string imageName;
31  GLenum target = GL_TEXTURE_2D;
32  if (loadValues.size() > 0)
33    imageName = loadValues[0];
34  if (loadValues.size() > 1)
35    target = (GLenum)MultiType(loadValues[2]).getInt();
36
37  return ResourceTexture(imageName, target, keepLevel);
38}
39
40
41
42Resources::tType<ResourceTexture> ResourceTexture::type("Texture");
43
44
45
46
47
48ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data)
49    : Resources::StorePointer(loadString, keepLevel) , pointer(data)
50{}
51
52
Note: See TracBrowser for help on using the repository browser.