forked from a1928370421/Bongobs-Cat-Plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLAppTextureManager.hpp
More file actions
108 lines (94 loc) · 2.69 KB
/
Copy pathLAppTextureManager.hpp
File metadata and controls
108 lines (94 loc) · 2.69 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* Copyright(c) Live2D Inc. All rights reserved.
*
* Use of this source code is governed by the Live2D Open Software license
* that can be found at https://www.live2d.com/eula/live2d-open-software-license-agreement_en.html.
*/
#pragma once
#include <string>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <Type/csmVector.hpp>
/**
* @brief テクスチャ管理クラス
*
* 画像読み込み、管理を行うクラス。
*/
class LAppTextureManager
{
public:
/**
* @brief 画像情報構造体
*/
struct TextureInfo
{
GLuint id; ///< テクスチャID
int width; ///< 横幅
int height; ///< 高さ
std::string fileName; ///< ファイル名
};
/**
* @brief コンストラクタ
*/
LAppTextureManager();
/**
* @brief デストラクタ
*
*/
~LAppTextureManager();
/**
* @brief プリマルチプライ処理
*
* @param[in] red 画像のRed値
* @param[in] green 画像のGreen値
* @param[in] blue 画像のBlue値
* @param[in] alpha 画像のAlpha値
*
* @return プリマルチプライ処理後のカラー値
*/
inline unsigned int Premultiply(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
{
return static_cast<unsigned>(\
(red * (alpha + 1) >> 8) | \
((green * (alpha + 1) >> 8) << 8) | \
((blue * (alpha + 1) >> 8) << 16) | \
(((alpha)) << 24) \
);
}
/**
* @brief 画像読み込み
*
* @param[in] fileName 読み込む画像ファイルパス名
* @return 画像情報。読み込み失敗時はNULLを返す
*/
TextureInfo* CreateTextureFromPngFile(std::string fileName);
/**
* @brief 画像の解放
*
* 配列に存在する画像全てを解放する
*/
void ReleaseTextures();
/**
* @brief 画像の解放
*
* 指定したテクスチャIDの画像を解放する
* @param[in] textureId 解放するテクスチャID
**/
void ReleaseTexture(Csm::csmUint32 textureId);
/**
* @brief 画像の解放
*
* 指定した名前の画像を解放する
* @param[in] fileName 解放する画像ファイルパス名
**/
void ReleaseTexture(std::string fileName);
/**
* @brief テクスチャIDからテクスチャ情報を得る
*
* @param textureId[in] 取得したいテクスチャID
* @return テクスチャが存在していればTextureInfoが返る
*/
TextureInfo* GetTextureInfoById(GLuint textureId) const;
private:
Csm::csmVector<TextureInfo*> _textures;
};