summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/graphics/binding
diff options
context:
space:
mode:
Diffstat (limited to 'source/modules/asura-core/graphics/binding')
-rw-r--r--source/modules/asura-core/graphics/binding/_image.cpp51
-rw-r--r--source/modules/asura-core/graphics/binding/_texture.cpp86
-rw-r--r--source/modules/asura-core/graphics/binding/_window.cpp103
3 files changed, 119 insertions, 121 deletions
diff --git a/source/modules/asura-core/graphics/binding/_image.cpp b/source/modules/asura-core/graphics/binding/_image.cpp
index 1d43067..cc9a669 100644
--- a/source/modules/asura-core/graphics/binding/_image.cpp
+++ b/source/modules/asura-core/graphics/binding/_image.cpp
@@ -9,6 +9,8 @@ namespace AsuraEngine
LUAX_REGISTRY(Image)
{
+ LUAX_INHERIT(state, Texture);
+
LUAX_REGISTER_METHODS(state,
{ "New", _New },
{ "Refresh", _Refresh },
@@ -22,55 +24,68 @@ namespace AsuraEngine
LUAX_POSTPROCESS(Image)
{
-
}
- // Image.New()
+ // image = Image.New()
LUAX_IMPL_METHOD(Image, _New)
{
LUAX_STATE(L);
-
- return 0;
+ Image* img = new Image();
+ img->PushLuaxUserdata(state);
+ return 1;
}
- // image:Refresh()
+ // successed = image:Refresh(imgData)
LUAX_IMPL_METHOD(Image, _Refresh)
{
LUAX_PREPARE(L, Image);
-
- return 0;
+ ImageData* imgData = state.CheckUserdata<ImageData>(2);
+ bool successed = self->Refresh(imgData);
+ if (successed)
+ self->SetLuaxMemberRef(state, self->mImageDataRef, 2);
+ state.Push(successed);
+ return 1;
}
- // image:GetWidth()
+ // width = image:GetWidth()
LUAX_IMPL_METHOD(Image, _GetWidth)
{
LUAX_PREPARE(L, Image);
-
- return 0;
+ state.Push(self->GetWidth());
+ return 1;
}
- // image:GetHeight()
+ // height = image:GetHeight()
LUAX_IMPL_METHOD(Image, _GetHeight)
{
LUAX_PREPARE(L, Image);
-
- return 0;
+ state.Push(self->GetHeight());
+ return 1;
}
- // image:GetSize()
+ // width, height = image:GetSize()
LUAX_IMPL_METHOD(Image, _GetSize)
{
LUAX_PREPARE(L, Image);
-
- return 0;
+ int width = self->GetWidth();
+ int height = self->GetHeight();
+ state.Push(width);
+ state.Push(height);
+ return 2;
}
- // image:GetPixel()
+ // color32 = image:GetPixel(x, y)
LUAX_IMPL_METHOD(Image, _GetPixel)
{
LUAX_PREPARE(L, Image);
- return 0;
+ uint x, y;
+ x = state.CheckValue<uint>(2);
+ y = state.CheckValue<uint>(3);
+ Color32* c32 = new Color32();
+ c32->Set(self->GetPixel(x, y));
+ c32->PushLuaxUserdata(state);
+ return 1;
}
// image:Render()
diff --git a/source/modules/asura-core/graphics/binding/_texture.cpp b/source/modules/asura-core/graphics/binding/_texture.cpp
new file mode 100644
index 0000000..489d362
--- /dev/null
+++ b/source/modules/asura-core/graphics/binding/_texture.cpp
@@ -0,0 +1,86 @@
+#include "../texture.h"
+
+using namespace std;
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ LUAX_REGISTRY(Texture)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "SetFilterMode", _SetFilterMode },
+ { "SetWrapMode", _SetWrapMode },
+ { "GetFilterMode", _GetFilterMode },
+ { "GetWrapMode", _GetWrapMode },
+ { "IsGenMipmap", _IsGenMipmap }
+ );
+ }
+
+ LUAX_POSTPROCESS(Texture)
+ {
+ LUAX_REGISTER_ENUM(state, "EColorFormat",
+ { "UNKNOWN", COLOR_FORMAT_UNKNOWN },
+ { "RGBA8", COLOR_FORMAT_RGBA8 },
+ { "RGBA32F", COLOR_FORMAT_RGBA32F }
+ );
+ LUAX_REGISTER_ENUM(state, "EFilterMode",
+ { "NEAREST", FILTER_MODE_NEAREST },
+ { "LINEAR", FILTER_MODE_LINEAR }
+ );
+ LUAX_REGISTER_ENUM(state, "EWrapMode",
+ { "REPEAT", WRAP_MODE_REPEAT },
+ { "MIRROR", WRAP_MODE_MIRROR },
+ { "CLAMPTOEDGE", WRAP_MODE_CLAMPTOEDGE },
+ { "CLAMPTOBORDER", WRAP_MODE_CLAMPTOBORDER }
+ );
+
+ }
+
+ // texture:SetFilterMode(minFilter, magFilter)
+ LUAX_IMPL_METHOD(Texture, _SetFilterMode)
+ {
+ LUAX_PREPARE(L, Texture);
+ FilterMode min = (FilterMode)state.CheckValue<int>(2);
+ FilterMode mag = (FilterMode)state.CheckValue<int>(3);
+ self->SetFilterMode(min, mag);
+ return 0;
+ }
+
+ // texture:SetWrapMode(wrap_mode)
+ LUAX_IMPL_METHOD(Texture, _SetWrapMode)
+ {
+ LUAX_PREPARE(L, Texture);
+ WrapMode wrap_mode = (WrapMode)state.CheckValue<int>(2);
+ self->SetWrapMode(wrap_mode);
+ return 0;
+ }
+
+ // min, mag = texture:GetFilterMode()
+ LUAX_IMPL_METHOD(Texture, _GetFilterMode)
+ {
+ LUAX_PREPARE(L, Texture);
+ state.Push((int)self->mMinFilter);
+ state.Push((int)self->mMagFilter);
+ return 2;
+ }
+
+ // wrapmode= texture:GetWrapMode()
+ LUAX_IMPL_METHOD(Texture, _GetWrapMode)
+ {
+ LUAX_PREPARE(L, Texture);
+ state.Push((int)self->mWrapMode);
+ return 1;
+ }
+
+ // texture:IsGenMipmap()
+ LUAX_IMPL_METHOD(Texture, _IsGenMipmap)
+ {
+ LUAX_PREPARE(L, Texture);
+ state.Push(self->IsGenMipmap());
+ return 1;
+ }
+
+ }
+} \ No newline at end of file
diff --git a/source/modules/asura-core/graphics/binding/_window.cpp b/source/modules/asura-core/graphics/binding/_window.cpp
deleted file mode 100644
index fc74d6c..0000000
--- a/source/modules/asura-core/graphics/binding/_window.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-#include "../window.h"
-
-using namespace std;
-
-namespace AsuraEngine
-{
- namespace Graphics
- {
-
- LUAX_REGISTRY(Window)
- {
- LUAX_REGISTER_METHODS(state,
- { "Show", _Show },
- { "Hide", _Hide },
- { "SetResolution", _SetResolution },
- { "SetFullScreen", _SetFullScreen },
- { "SetTitle", _SetTitle },
- { "SetWindowStyle", _SetWindowStyle },
- { "Clear", _Clear },
- { "Draw", _Draw },
- { "SwapRenderBuffer", _SwapRenderBuffer }
- );
- }
-
- LUAX_POSTPROCESS(Window)
- {
-
- }
-
- // window:Show()
- LUAX_IMPL_METHOD(Window, _Show)
- {
- LUAX_PREPARE(L, Window);
-
- return 0;
- }
-
- // window:Hide()
- LUAX_IMPL_METHOD(Window, _Hide)
- {
- LUAX_PREPARE(L, Window);
-
- return 0;
- }
-
- // window:SetResolution()
- LUAX_IMPL_METHOD(Window, _SetResolution)
- {
- LUAX_PREPARE(L, Window);
-
- return 0;
- }
-
- // window:SetFullScreen()
- LUAX_IMPL_METHOD(Window, _SetFullScreen)
- {
- LUAX_PREPARE(L, Window);
-
- return 0;
- }
-
- // window:SetTitle()
- LUAX_IMPL_METHOD(Window, _SetTitle)
- {
- LUAX_PREPARE(L, Window);
-
- return 0;
- }
-
- // window:SetWindowStyle()
- LUAX_IMPL_METHOD(Window, _SetWindowStyle)
- {
- LUAX_PREPARE(L, Window);
-
- return 0;
- }
-
- // window:Clear()
- LUAX_IMPL_METHOD(Window, _Clear)
- {
- LUAX_PREPARE(L, Window);
-
- return 0;
- }
-
- // window:Draw()
- LUAX_IMPL_METHOD(Window, _Draw)
- {
- LUAX_PREPARE(L, Window);
-
- return 0;
- }
-
- // window:SwapRenderBuffer()
- LUAX_IMPL_METHOD(Window, _SwapRenderBuffer)
- {
- LUAX_PREPARE(L, Window);
-
- return 0;
- }
-
- }
-}