summaryrefslogtreecommitdiff
path: root/Source/modules/asura-core/Graphics/Image.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/modules/asura-core/Graphics/Image.cpp')
-rw-r--r--Source/modules/asura-core/Graphics/Image.cpp103
1 files changed, 0 insertions, 103 deletions
diff --git a/Source/modules/asura-core/Graphics/Image.cpp b/Source/modules/asura-core/Graphics/Image.cpp
deleted file mode 100644
index 36d2478..0000000
--- a/Source/modules/asura-core/Graphics/Image.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-#include <asura-base/Exception.h>
-
-#include "../CoreConfig.h"
-
-#include "Shader.h"
-#include "Image.h"
-#include "GfxDevice.h"
-
-using namespace AEFileSystem;
-using namespace AEImage;
-
-namespace_begin(AsuraEngine)
-namespace_begin(Graphics)
-
-Image::Image()
- : m_Width(0)
- , m_Height(0)
-{
-}
-
-Image::~Image()
-{
-}
-
-bool Image::Load(ImageData* imgData)
-{
- if (!imgData) return false;
-
- if (m_TexID == 0)
- {
- glGenTextures(1, &m_TexID);
- if (m_TexID == 0)
- throw Exception("OpenGL glGenTextures failed.");
- }
-
- glBindTexture(GL_TEXTURE_2D, m_TexID);
- imgData->Lock();
- int width = imgData->width;
- int height = imgData->height;
- TextureFormat tf = ConvertColorFormat(imgData->format);
- glTexImage2D(
- GL_TEXTURE_2D
- , 0
- , tf.internalformat
- , width, height
- , 0
- , tf.externalformat
- , tf.type
- , imgData->pixels
- );
-
- m_Width = imgData->width;
- m_Height = imgData->height;
- imgData->Unlock();
- GLenum err = glGetError();
- if (err != GL_NO_ERROR)
- throw Exception("OpenGL glTexImage2D cause error, error code=%d", err);
- glBindTexture(GL_TEXTURE_2D, 0);
-
- return true;
-}
-
-bool Image::Load(ImageData* imgData, const AEMath::Vector2i& pos)
-{
- if (!imgData) return false;
-
- glBindTexture(GL_TEXTURE_2D, m_TexID);
- imgData->Lock();
- int width = imgData->width;
- int height = imgData->height;
- TextureFormat tf = ConvertColorFormat(imgData->format);
- glTexSubImage2D(
- GL_TEXTURE_2D
- , 0
- , pos.x
- , pos.y
- , imgData->width
- , imgData->height
- , tf.externalformat
- , tf.type
- , imgData->pixels
- );
- imgData->Unlock();
- GLenum err = glGetError();
- if (err != GL_NO_ERROR)
- throw Exception("OpenGL glTexSubImage2D cause error, error code=%d", err);
- glBindTexture(GL_TEXTURE_2D, 0);
-
- return true;
-}
-
-uint32 Image::GetWidth()
-{
- return m_Width;
-}
-
-uint32 Image::GetHeight()
-{
- return m_Height;
-}
-
-namespace_end
-namespace_end \ No newline at end of file