summaryrefslogtreecommitdiff
path: root/Runtime/Graphics
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Graphics')
-rw-r--r--Runtime/Graphics/Color.cpp4
-rw-r--r--Runtime/Graphics/Color.h2
-rw-r--r--Runtime/Graphics/GPUDataBuffer.cpp1
-rw-r--r--Runtime/Graphics/RenderCommands.h1
-rw-r--r--Runtime/Graphics/Texture.cpp17
5 files changed, 24 insertions, 1 deletions
diff --git a/Runtime/Graphics/Color.cpp b/Runtime/Graphics/Color.cpp
new file mode 100644
index 0000000..7e792e6
--- /dev/null
+++ b/Runtime/Graphics/Color.cpp
@@ -0,0 +1,4 @@
+#include "Color.h"
+
+const Color32 Color32::white = Color32(255, 255, 255, 255);
+
diff --git a/Runtime/Graphics/Color.h b/Runtime/Graphics/Color.h
index ebccafe..41ca2a4 100644
--- a/Runtime/Graphics/Color.h
+++ b/Runtime/Graphics/Color.h
@@ -41,6 +41,8 @@ namespace Internal
this->a = a;
}
unsigned char r, g, b, a;
+
+ static const Color32 white;
};
}
diff --git a/Runtime/Graphics/GPUDataBuffer.cpp b/Runtime/Graphics/GPUDataBuffer.cpp
index 707cacb..f5149d9 100644
--- a/Runtime/Graphics/GPUDataBuffer.cpp
+++ b/Runtime/Graphics/GPUDataBuffer.cpp
@@ -12,6 +12,7 @@ namespace GPU
DataBuffer::DataBuffer()
{
glGenBuffers(1, &m_Handle);
+ m_Size = 0;
}
DataBuffer::~DataBuffer()
diff --git a/Runtime/Graphics/RenderCommands.h b/Runtime/Graphics/RenderCommands.h
index 123e6f0..ecb0904 100644
--- a/Runtime/Graphics/RenderCommands.h
+++ b/Runtime/Graphics/RenderCommands.h
@@ -70,6 +70,7 @@ struct Cmd_Blend : RenderCommand
if (!enable)
glDisable(GL_BLEND);
glEnable(GL_BLEND);
+ glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
GLenum src, dst;
switch (srcFac)
{
diff --git a/Runtime/Graphics/Texture.cpp b/Runtime/Graphics/Texture.cpp
index a1f4181..0cabd07 100644
--- a/Runtime/Graphics/Texture.cpp
+++ b/Runtime/Graphics/Texture.cpp
@@ -84,7 +84,22 @@ void Texture::Init(TextureSetting setting, ImageData* imgData)
break;
}
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imgData->width, imgData->height, 0, GL_RGB, GL_UNSIGNED_BYTE, imgData->pixels);
+ GLint srcFormat = GL_RGB;
+ switch (imgData->format)
+ {
+ case PixelFormat_R: srcFormat = GL_RED; break;
+ case PixelFormat_RGB: srcFormat = GL_RGB; break;
+ case PixelFormat_RGBA: srcFormat = GL_RGBA; break;
+ default: Assert(false);
+ }
+ GLint srcType = GL_UNSIGNED_BYTE;
+ switch (imgData->type)
+ {
+ case PixelType_UNSIGNED_BYTE: srcType = GL_UNSIGNED_BYTE; break;
+ default: Assert(false);
+ }
+
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, imgData->width, imgData->height, 0, srcFormat, srcType, imgData->pixels);
CheckGLError(
glDeleteTextures(1, &m_GPUID);