[9781] | 1 | |
---|
| 2 | #include "resource_texture.h" |
---|
[9823] | 3 | #include "substring.h" |
---|
| 4 | #include "multi_type.h" |
---|
[9790] | 5 | #include "debug.h" |
---|
[9781] | 6 | |
---|
| 7 | |
---|
[9784] | 8 | ResourceTexture::ResourceTexture(const std::string& imageName, GLenum target) |
---|
[9788] | 9 | : NewResource(&ResourceTexture::type) |
---|
[9784] | 10 | { |
---|
[9791] | 11 | Resources::StorePointer* ptr = this->acquireResource(imageName + ',' + "TEST"); |
---|
[9781] | 12 | |
---|
[9784] | 13 | if (ptr) |
---|
[9786] | 14 | { |
---|
[9790] | 15 | PRINTF(5)("FOUNT TEXTURE: %s\n", imageName.c_str()); |
---|
[9784] | 16 | this->acquireData(static_cast<ResourceTexture::TextureResourcePointer*>(ptr)->ptr()); |
---|
[9786] | 17 | } |
---|
[9784] | 18 | else |
---|
| 19 | { |
---|
[9790] | 20 | PRINTF(5)("NOT FOUNT TEXTURE: %s\n", imageName.c_str()); |
---|
[9788] | 21 | std::string fileName = this->NewResource::locateFile(imageName); |
---|
[9785] | 22 | this->Texture::loadImage(fileName, target); |
---|
[9791] | 23 | this->NewResource::addResource(new ResourceTexture::TextureResourcePointer(imageName + ',' + "TEST", Resources::KeepLevel(0), this->Texture::dataPointer())); |
---|
[9784] | 24 | } |
---|
| 25 | } |
---|
| 26 | |
---|
[9823] | 27 | ResourceTexture ResourceTexture::createFromString(const std::string& loadString) |
---|
| 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(); |
---|
[9784] | 36 | |
---|
[9823] | 37 | return ResourceTexture(imageName, target); |
---|
| 38 | } |
---|
[9784] | 39 | |
---|
| 40 | |
---|
| 41 | |
---|
[9823] | 42 | Resources::tType<ResourceTexture> ResourceTexture::type("Texture"); |
---|
[9784] | 43 | |
---|
| 44 | |
---|
[9823] | 45 | |
---|
| 46 | |
---|
| 47 | |
---|
[9791] | 48 | ResourceTexture::TextureResourcePointer::TextureResourcePointer(const std::string& loadString, const Resources::KeepLevel& keepLevel, const TextureData::Pointer& data) |
---|
| 49 | : Resources::StorePointer(loadString, keepLevel) , pointer(data) |
---|
[9785] | 50 | {} |
---|
[9781] | 51 | |
---|
| 52 | |
---|