summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-core/graphics
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-27 22:18:14 +0800
committerchai <chaifix@163.com>2019-03-27 22:18:14 +0800
commit69f7d1bd745ed5680b9bc4e3cfdd882ff2a5ad26 (patch)
tree729e563da8fea6cf8c5455f3afdb3c6ce0aecde4 /source/libs/asura-lib-core/graphics
parent66c5fdc564dd892ed265132d6c1378dbe3cebcee (diff)
+threading
Diffstat (limited to 'source/libs/asura-lib-core/graphics')
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_image.cpp57
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_image_decode_task.cpp21
-rw-r--r--source/libs/asura-lib-core/graphics/binding/_window.cpp103
-rw-r--r--source/libs/asura-lib-core/graphics/image.h15
-rw-r--r--source/libs/asura-lib-core/graphics/window.h19
-rw-r--r--source/libs/asura-lib-core/graphics/window_impl_glew.cpp0
-rw-r--r--source/libs/asura-lib-core/graphics/window_impl_glew.h0
-rw-r--r--source/libs/asura-lib-core/graphics/window_impl_glut.cpp0
-rw-r--r--source/libs/asura-lib-core/graphics/window_impl_glut.h0
9 files changed, 198 insertions, 17 deletions
diff --git a/source/libs/asura-lib-core/graphics/binding/_image.cpp b/source/libs/asura-lib-core/graphics/binding/_image.cpp
index 7c1034c..b455ad5 100644
--- a/source/libs/asura-lib-core/graphics/binding/_image.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/_image.cpp
@@ -10,10 +10,13 @@ namespace AsuraEngine
LUAX_REGISTRY(Image)
{
LUAX_REGISTER_METHODS(state,
+ { "New", _New },
{ "Load", _Load },
{ "GetWidth", _GetWidth },
{ "GetHeight", _GetHeight },
- { "GetSize", _GetSize }
+ { "GetSize", _GetSize },
+ { "GetPixel", _GetPixel },
+ { "Render", _Render }
);
}
@@ -22,33 +25,75 @@ namespace AsuraEngine
}
- // image:Load()
+ // image = Image.New()
+ LUAX_IMPL_METHOD(Image, _New)
+ {
+ LUAX_STATE(L);
+
+ Image* image = new Image();
+ image->PushLuaxUserdata(state);
+ return 0;
+ }
+
+ // successed = image:Load(image_data)
LUAX_IMPL_METHOD(Image, _Load)
{
LUAX_PREPARE(L, Image);
+ ImageData* imgdata = state.CheckUserdata<ImageData>(2);
+ bool loaded = self->Load(imgdata);
+ state.Push(loaded);
+ return 1;
}
- // image:GetWidth()
+ // width = image:GetWidth()
LUAX_IMPL_METHOD(Image, _GetWidth)
{
LUAX_PREPARE(L, Image);
+ state.Push(self->GetWidth());
+ return 1;
}
- // image:GetHeight()
+ // height = image:GetHeight()
LUAX_IMPL_METHOD(Image, _GetHeight)
{
LUAX_PREPARE(L, Image);
+ state.Push(self->GetHeight());
+ return 1;
}
- // image:GetSize()
+ // w, h = image:GetSize()
LUAX_IMPL_METHOD(Image, _GetSize)
{
LUAX_PREPARE(L, Image);
+ Math::Vector2u size = self->GetSize();
+ state.Push(size.x);
+ state.Push(size.y);
+ return 2;
+ }
+
+ // color32 = image:GetPixel(x, y)
+ LUAX_IMPL_METHOD(Image, _GetPixel)
+ {
+ LUAX_PREPARE(L, Image);
+
+ uint x = state.CheckParam<uint>(2);
+ uint y = state.CheckParam<uint>(3);
+ Color32* c32 = new Color32(self->GetPixel(x, y));
+ c32->PushLuaxUserdata(state);
+ return 1;
+ }
+
+ // image:Render()
+ LUAX_IMPL_METHOD(Image, _Render)
+ {
+ LUAX_PREPARE(L, Image);
+
+ return 0;
}
}
-}
+} \ No newline at end of file
diff --git a/source/libs/asura-lib-core/graphics/binding/_image_decode_task.cpp b/source/libs/asura-lib-core/graphics/binding/_image_decode_task.cpp
new file mode 100644
index 0000000..76b544b
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/binding/_image_decode_task.cpp
@@ -0,0 +1,21 @@
+#include "../image_decode_task.h"
+
+using namespace std;
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ LUAX_REGISTRY(ImageDecodeTask)
+ {
+
+ }
+
+ LUAX_POSTPROCESS(ImageDecodeTask)
+ {
+
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-core/graphics/binding/_window.cpp b/source/libs/asura-lib-core/graphics/binding/_window.cpp
new file mode 100644
index 0000000..fc74d6c
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/binding/_window.cpp
@@ -0,0 +1,103 @@
+#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;
+ }
+
+ }
+}
diff --git a/source/libs/asura-lib-core/graphics/image.h b/source/libs/asura-lib-core/graphics/image.h
index 0e4ea0a..4c1c7b5 100644
--- a/source/libs/asura-lib-core/graphics/image.h
+++ b/source/libs/asura-lib-core/graphics/image.h
@@ -10,6 +10,7 @@
#include "texture.h"
#include "color.h"
+#include "color32.h"
#include "image_data.h"
#include "render_state.h"
@@ -31,6 +32,8 @@ namespace AsuraEngine
{
public:
+ LUAX_DECL_FACTORY(SimImage);
+
Image();
~Image();
@@ -56,21 +59,21 @@ namespace AsuraEngine
private:
- ImageData* mImageData;
+ ImageData* mImageData;
+ Luax::LuaxMemberRef mImageDataRef;
Math::Vector2u mSize;
- public:
-
- LUAX_DECL_FACTORY(SimImage);
-
+ LUAX_DECL_METHOD(_New);
LUAX_DECL_METHOD(_Load);
LUAX_DECL_METHOD(_GetWidth);
LUAX_DECL_METHOD(_GetHeight);
LUAX_DECL_METHOD(_GetSize);
+ LUAX_DECL_METHOD(_GetPixel);
+ LUAX_DECL_METHOD(_Render);
};
-
+
}
}
diff --git a/source/libs/asura-lib-core/graphics/window.h b/source/libs/asura-lib-core/graphics/window.h
index 0bfd6a1..1b219a2 100644
--- a/source/libs/asura-lib-core/graphics/window.h
+++ b/source/libs/asura-lib-core/graphics/window.h
@@ -12,15 +12,16 @@ namespace AsuraEngine
namespace Graphics
{
+ class WindowImpl;
+
enum WindowStyle
{
WINDOW_STYLE_FULLSCREEN = 1 << 1,
};
- class WindowImpl;
-
///
- /// ڣֶ֧രڡڱ༭Ҫ֧֣runnerֻҪһڡͬĿͻʵִ˽ӿڲֶעᵽlua
+ /// ϷĵڣrunnerֻҪһڡͬĿͻʵִ˽ӿڲֶעᵽlua༭ᵼ࣬޽ӵ༭
+ /// ⴰϡ
///
class Window
: public RenderTarget
@@ -63,6 +64,16 @@ namespace AsuraEngine
WindowImpl* mImpl;
+ LUAX_DECL_METHOD(_Show);
+ LUAX_DECL_METHOD(_Hide);
+ LUAX_DECL_METHOD(_SetResolution);
+ LUAX_DECL_METHOD(_SetFullScreen);
+ LUAX_DECL_METHOD(_SetTitle);
+ LUAX_DECL_METHOD(_SetWindowStyle);
+ LUAX_DECL_METHOD(_Clear);
+ LUAX_DECL_METHOD(_Draw);
+ LUAX_DECL_METHOD(_SwapRenderBuffer);
+
};
using RenderWindow = Window;
@@ -71,8 +82,6 @@ namespace AsuraEngine
{
public:
-
-
};
}
diff --git a/source/libs/asura-lib-core/graphics/window_impl_glew.cpp b/source/libs/asura-lib-core/graphics/window_impl_glew.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/window_impl_glew.cpp
diff --git a/source/libs/asura-lib-core/graphics/window_impl_glew.h b/source/libs/asura-lib-core/graphics/window_impl_glew.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/window_impl_glew.h
diff --git a/source/libs/asura-lib-core/graphics/window_impl_glut.cpp b/source/libs/asura-lib-core/graphics/window_impl_glut.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/window_impl_glut.cpp
diff --git a/source/libs/asura-lib-core/graphics/window_impl_glut.h b/source/libs/asura-lib-core/graphics/window_impl_glut.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/source/libs/asura-lib-core/graphics/window_impl_glut.h