summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/graphics/texture.cpp
blob: 4db6ad30a64db9ea47b5ce44fd3efdeea6aac52e (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
#include "Texture.h"

namespace AsuraEngine
{
	namespace Graphics
	{

		Texture::Texture()
			: mTex(0)
		{
			// GL texture
			glGenTextures(1, &mTex);
		}

		Texture::~Texture()
		{
			glDeleteTextures(1, &mTex);
		}

		GLuint Texture::GetGLTextureHandle() const
		{
			return mTex;
		}

		TextureFormat Texture::ConvertColorFormat(const ColorFormat& colorformat)
		{
			TextureFormat t;
			switch (colorformat)
			{
			case COLOR_FORMAT_RGBA8:
				t.internalformat = GL_RGBA8;
				t.externalformat = GL_RGBA;
				t.type = GL_UNSIGNED_BYTE;
				break;
			case COLOR_FORMAT_RGBA32F:
				t.internalformat = GL_RGBA32F;
				t.externalformat = GL_RGBA;
				t.type = GL_FLOAT;
				break;
			}
			return t;
		}

	}
}