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
8
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
44{
45 if (glIsTexture(id))
46 {
47 glDeleteTextures(1, &id);
48 }
49}
TextureManager TEXTUREMANAGER
Abstract base class representing a file within the game data archive.
Definition GameFile.h:12
const std::string & fullname() const
Definition GameFile.h:56
std::map< GLuint, ManagedItem * > items
Definition manager.h:50
std::map< std::string, GLuint > names
Definition manager.h:49
void do_add(const std::string &name, GLuint id, ManagedItem *item)
Definition manager.h:149
Manages OpenGL texture lifetimes with reference-counted caching.
virtual GLuint add(GameFile *)
void doDelete(GLuint id)
void load()
Definition Texture.cpp:20
GLuint id
Definition Texture.h:12