WoW Model Viewer
Your premiere tool for viewing, equipping and animating World of Warcraft models.
Loading...
Searching...
No Matches
TextureManager.cpp
Go to the documentation of this file.
1
#include "
TextureManager.h
"
2
#include "
Logger.h
"
3
#include "
GameFile.h
"
4
#include "
Texture.h
"
5
#include <glad/gl.h>
6
7
TextureManager
TEXTUREMANAGER
;
8
9
GLuint
TextureManager::add
(
GameFile
* file)
10
{
11
GLuint
id
= 0;
12
13
if
(!file)
14
return
0;
15
16
const
auto
& name = file->
fullname
();
17
18
// if the item already exists, return the existing ID
19
if
(
names
.find(name) !=
names
.end())
20
{
21
id
=
names
[name];
22
items
[id]->addref();
23
return
id;
24
}
25
26
// Else, create the texture
27
Texture
* tex =
new
Texture
(file);
28
29
// clear old texture memory from vid card
30
glDeleteTextures(1, &
id
);
31
// create new texture and put it in memory
32
glGenTextures(1, &
id
);
33
34
tex->
id
= id;
35
tex->
load
();
36
37
do_add
(name,
id
, tex);
38
return
id;
39
}
40
41
//#define SAVE_BLP
42
43
void
TextureManager::doDelete
(GLuint
id
)
44
{
45
if
(glIsTexture(
id
))
46
{
47
glDeleteTextures(1, &
id
);
48
}
49
}
GameFile.h
Logger.h
TEXTUREMANAGER
TextureManager TEXTUREMANAGER
Definition
TextureManager.cpp:7
TextureManager.h
Texture.h
GameFile
Abstract base class representing a file within the game data archive.
Definition
GameFile.h:12
GameFile::fullname
const std::string & fullname() const
Definition
GameFile.h:56
Manager< GLuint >::items
std::map< GLuint, ManagedItem * > items
Definition
manager.h:50
Manager< GLuint >::names
std::map< std::string, GLuint > names
Definition
manager.h:49
Manager< GLuint >::do_add
void do_add(const std::string &name, GLuint id, ManagedItem *item)
Definition
manager.h:149
TextureManager
Manages OpenGL texture lifetimes with reference-counted caching.
Definition
TextureManager.h:15
TextureManager::add
virtual GLuint add(GameFile *)
Definition
TextureManager.cpp:9
TextureManager::doDelete
void doDelete(GLuint id)
Definition
TextureManager.cpp:43
Texture
Definition
Texture.h:9
Texture::load
void load()
Definition
Texture.cpp:20
Texture::id
GLuint id
Definition
Texture.h:12
Source
WoW
Texture
TextureManager.cpp
Generated by
1.9.8