blob: 03f005d3fc53310e6114c3ccc637d447ee302567 (
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
|
#include <asura-base/Exception.h>
#include "Texture.h"
namespace_begin(AsuraEngine)
namespace_begin(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;
}
namespace_end
namespace_end
|