blob: ef85cebeed63d5d23a0232c80f6466e678274f94 (
plain)
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
|
#include <asura-utils/exceptions/exception.h>
#include "Texture.h"
namespace AsuraEngine
{
namespace Graphics
{
Texture::Texture()
: m_TexID(0)
{
}
Texture::~Texture()
{
// ͷԴ
if(m_TexID != 0)
glDeleteTextures(1, &m_TexID);
}
GLuint Texture::GetGLTexture() const
{
return m_TexID;
}
TextureFormat Texture::ConvertColorFormat(const ColorFormat& colorformat)
{
TextureFormat t;
switch (colorformat)
{
case COLOR_FORMAT_RGBA8:
t.internalformat = GL_RGBA8; // 4*sizeof(byte) ~= 4 bytes
t.externalformat = GL_RGBA;
t.type = GL_UNSIGNED_BYTE;
break;
case COLOR_FORMAT_RGBA32F:
t.internalformat = GL_RGBA32F; // 4*sizeof(float) = 16 bytes
t.externalformat = GL_RGBA;
t.type = GL_FLOAT;
break;
default:
ASSERT(false);
}
return t;
}
}
}
|