-
Notifications
You must be signed in to change notification settings - Fork 2
/
TextureCache.cpp
37 lines (26 loc) · 786 Bytes
/
TextureCache.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "TextureCache.h"
#include "ImageLoader.h"
#include <iostream>
namespace NeroEngine{
TextureCache::TextureCache()
{
}
TextureCache::~TextureCache()
{
}
GLTexture TextureCache::getTexture(std::string texturePath){
//auto mit = _textureMap.find(texturePath);
//在map中查找texture
std::map<std::string, GLTexture>::iterator mit = _textureMap.find(texturePath);
if (mit == _textureMap.end()){
GLTexture newTexture = ImageLoader::loadPNG(texturePath);
std::pair<std::string, GLTexture> newPair(texturePath, newTexture);
//_textureMap.insert(make_pair(texturePath,newTexture));
_textureMap.insert(newPair);
std::cout << "读取贴图:" + texturePath + "\n";
return newTexture;
}
//std::cout << "使用缓存贴图\n";
return mit->second;
}
}