-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTexture.h
More file actions
72 lines (57 loc) · 2.33 KB
/
Texture.h
File metadata and controls
72 lines (57 loc) · 2.33 KB
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
/*
Copyright (c) 2024-2025 Toksisitee. All rights reserved.
This work is licensed under the terms of the MIT license.
For a copy, refer to license.md or https://opensource.org/licenses/MIT
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
*/
#pragma once
#//include <D3dx9tex.h>
#include <string>
#include <map>
#include "Palette.h"
typedef struct IDirect3DTexture9* LPDIRECT3DTEXTURE9, * PDIRECT3DTEXTURE9;
typedef struct IDirect3DDevice9* LPDIRECT3DDEVICE9, * PDIRECT3DDEVICE9;
class CTexture2D
{
public:
CTexture2D( LPDIRECT3DDEVICE9 pd3dDevice, const std::string& sDirectory, std::string sName, int nWidth, int nHeight );
CTexture2D( LPDIRECT3DDEVICE9 pd3dDevice, const std::string& sDirectory, std::string sName );
CTexture2D( LPDIRECT3DDEVICE9 pd3dDevice, int nWidth, int nHeight, Assets::CPalette* pPalette );
CTexture2D( LPDIRECT3DDEVICE9 pd3dDevice, int nWidth, int nHeight, uint8_t* pData, Assets::CPalette* pPalette );
CTexture2D( LPDIRECT3DDEVICE9 pd3dDevice, int nWidth, int nHeight );
~CTexture2D();
[[nodiscard]] LPDIRECT3DTEXTURE9 GetTexture() { return m_pD3DTexture; };
[[nodiscard]] int GetHeight() const { return m_nHeight; };
[[nodiscard]] int GetWidth() const { return m_nWidth; };
void Clear();
private:
LPDIRECT3DTEXTURE9 m_pD3DTexture;
int m_nHeight, m_nWidth;
LPDIRECT3DDEVICE9 m_pd3dDevice;
};
class CTextureManager
{
public:
CTextureManager() = default;
~CTextureManager();
void AddTexture( const std::string& sTexture, CTexture2D* pTexture );
CTexture2D* LoadTexture( LPDIRECT3DDEVICE9 pd3dDevice, const std::string& sDirectory, const std::string& sName, int nWidth, int nHeight );
CTexture2D* LoadTexture( LPDIRECT3DDEVICE9 pd3dDevice, const std::string& sDirectory, const std::string& sName );
CTexture2D* GetTexture2D( const std::string& sName );
void DeleteAll();
void ClearAll();
private:
typedef std::map<std::string, CTexture2D*> Texture2DMap;
Texture2DMap m_TextureMap;
};
CTexture2D* CopyTexture( LPDIRECT3DDEVICE9 pd3dDevice, CTexture2D* pSrcTex2D, const std::string& sName, int nDownscale = 0 );
extern CTextureManager g_TextureManager;
inline void SafeDestroyTexture( CTexture2D*& pTexture )
{
if ( pTexture ) {
delete pTexture;
pTexture = nullptr;
}
}