-
Notifications
You must be signed in to change notification settings - Fork 2
/
TextureManager.h
84 lines (69 loc) · 2.41 KB
/
TextureManager.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//-----------------------------------------------------------------------------
// File: TextureManager.h
//
// Desc: A singleton texture manager that manages all textures for the world
//
// Copyright (c) 2002 Dan
//-----------------------------------------------------------------------------
#ifndef _TEXTUREMANAGER_H_
#define _TEXTUREMANAGER_H_
#define MAX_TEXTURES 64
#define CUSTOM_FILE "custom.tex"
#define SYSTEM_FILE "system.tex"
#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
#include <stdio.h>
#include "glext.h"
#include "Singleton.h"
#include "Buffer.h"
#include "LightmapManager.h"
typedef struct _TEXTURE
{
unsigned int id;
char path[256];
} HTEXTURE, *LPTEXTURE;
#define NOTEXTURE 99999
class CTextureManager : public CSingleton<CTextureManager>
{
public:
CTextureManager();
virtual ~CTextureManager();
bool Release();
void SetSelectedTexture( const HTEXTURE hTexture ) { m_CurrentlySelected = hTexture; }
HTEXTURE AddTextureFromFile( char* strFileName, bool bEngineTexture = false );
void SetNameFromTextureTab( const char* str) { strcpy( m_strTabTexture, str ); }
HTEXTURE GetSelectedTexture() const { return m_CurrentlySelected; }
bool LoadTextureSet( char* FileName, bool bEngineTexture = false );
bool IsAlreadyLoaded( char* strFileName, HTEXTURE &hTexture );
char* GetNameFromTextureTab() const { return m_strTabTexture; }
bool Save( const char* File, FILE* fileDescriptor );
bool Open( const char* File, FILE* fileDescriptor );
void Invalidate( HTEXTURE &hTexture );
bool Invalidate( LIGHTMAP* hTexture );
bool ClearAllTextures();
bool SelectDefault();
bool Init();
bool PrepareTexture1( const HTEXTURE hHandle, bool bEngineTexture = false );
bool PrepareTexture2( const HTEXTURE hHandle );
bool PrepareLightmap( const HTEXTURE hHandle );
void DisableTexture1();
void DisableTexture2();
void DisableLightmap();
void EnableTexture1();
void EnableTexture2();
void EnableLightmap();
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
private:
HTEXTURE m_EngineTextures[MAX_TEXTURES];
HTEXTURE m_CurrentlySelected;
HTEXTURE m_Textures[MAX_TEXTURES];
int m_LoadedEngineTextures;
char* m_strTabTexture;
int m_LoadedTextures;
char* m_FileName;
};
#define TextureManager CTextureManager::GetSingletonPtr()
#define TM CTextureManager::GetSingletonPtr()
#endif