summaryrefslogtreecommitdiff
path: root/source/libs/asura-lib-core/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'source/libs/asura-lib-core/graphics')
-rw-r--r--source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp56
-rw-r--r--source/libs/asura-lib-core/graphics/canvas.h14
-rw-r--r--source/libs/asura-lib-core/graphics/color.h5
-rw-r--r--source/libs/asura-lib-core/graphics/gl.cpp2
-rw-r--r--source/libs/asura-lib-core/graphics/image_data.cpp3
-rw-r--r--source/libs/asura-lib-core/graphics/image_data.h24
-rw-r--r--source/libs/asura-lib-core/graphics/image_decoder.h4
7 files changed, 73 insertions, 35 deletions
diff --git a/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp b/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp
index 0d68c11..72e33da 100644
--- a/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp
+++ b/source/libs/asura-lib-core/graphics/binding/image_data.binding.cpp
@@ -1,4 +1,4 @@
-#include "../image.h"
+#include "../image_data.h"
using namespace Luax;
@@ -7,23 +7,55 @@ namespace AsuraEngine
namespace Graphics
{
- void Image::RegisterLuaxClass(LuaxState& state)
+ LUAX_REGISTRY(ImageData)
{
}
- void Image::RegisterLuaxPostprocess(LuaxState& state)
+ LUAX_POSTPROCESS(ImageData)
+ {
+ LUAX_REGISTER_ENUM(state, "EBlendMode",
+ { "Additive", 1 }
+ );
+ LUAX_REGISTER_ENUM(state, "EPixelFormat",
+ { "RGBA32", 1 }
+ );
+ }
+
+ // imagedata = ImageData.New(databuffer)
+ LUAX_IMPL_METHOD(ImageData, _New)
+ {
+ LUAX_STATE(L);
+
+ Filesystem::DataBuffer* db = state.CheckUserdata<Filesystem::DataBuffer>(1);
+ ImageData* image = new ImageData(*db);
+ image->PushLuaxUserdata(state);
+ return 1;
+ }
+
+ LUAX_IMPL_METHOD(ImageData, _GetPixel)
+ {
+
+ }
+
+ LUAX_IMPL_METHOD(ImageData, _GetSize)
+ {
+
+ }
+
+ LUAX_IMPL_METHOD(ImageData, _GetWidth)
+ {
+
+ }
+
+ LUAX_IMPL_METHOD(ImageData, _GetHeight)
+ {
+
+ }
+
+ LUAX_IMPL_METHOD(ImageData, _GetPixelFormat)
{
- // blendö٣AsuraEngine.EBlendMode
- LuaxEnum EBlendMode[] = {
- { "Additive", 1 },
- { "PreBlend", 2 },
- { "Substruction", 3 },
- { "Multiplied", 4 },
- {0, 0}
- };
- state.RegisterEnum("EBlendMode", EBlendMode);
}
}
diff --git a/source/libs/asura-lib-core/graphics/canvas.h b/source/libs/asura-lib-core/graphics/canvas.h
index c4e0f65..6b8b630 100644
--- a/source/libs/asura-lib-core/graphics/canvas.h
+++ b/source/libs/asura-lib-core/graphics/canvas.h
@@ -1,12 +1,14 @@
#ifndef __ASURA_ENGINE_CANVAS_H__
#define __ASURA_ENGINE_CANVAS_H__
-#include <Scripting/Luax.hpp>
+#include <asura-lib-utils/scripting/portable.hpp>
+#include <asura-lib-utils/math/rect.hpp>
+#include <asura-lib-utils/math/vector2.hpp>
-#include "Math/Rect.hpp"
-#include "GL.h"
-#include "Texture.h"
-#include "RenderTarget.h"
+#include "gl.h"
+#include "texture.h"
+#include "render_target.h"
+#include "render_state.h"
namespace AsuraEngine
{
@@ -19,7 +21,7 @@ namespace AsuraEngine
class Canvas ASURA_FINAL
: public Drawable
, public RenderTarget
- , public Scripting::Portable
+ , public Scripting::Portable<Canvas>
{
public:
diff --git a/source/libs/asura-lib-core/graphics/color.h b/source/libs/asura-lib-core/graphics/color.h
index a18c682..74cf8f3 100644
--- a/source/libs/asura-lib-core/graphics/color.h
+++ b/source/libs/asura-lib-core/graphics/color.h
@@ -1,8 +1,9 @@
#ifndef __ASURA_ENGINE_COLOR_H__
#define __ASURA_ENGINE_COLOR_H__
-#include "config.h"
-#include "scripting/portable.hpp"
+#include <asura-lib-utils/scripting/portable.hpp>
+
+#include "../core_config.h"
namespace AsuraEngine
{
diff --git a/source/libs/asura-lib-core/graphics/gl.cpp b/source/libs/asura-lib-core/graphics/gl.cpp
index 01c90de..7c68c8f 100644
--- a/source/libs/asura-lib-core/graphics/gl.cpp
+++ b/source/libs/asura-lib-core/graphics/gl.cpp
@@ -1,4 +1,4 @@
-#include "config.h"
+#include "../core_config.h"
#include "gl.h"
namespace AsuraEngine
diff --git a/source/libs/asura-lib-core/graphics/image_data.cpp b/source/libs/asura-lib-core/graphics/image_data.cpp
index 821bfd6..28c706a 100644
--- a/source/libs/asura-lib-core/graphics/image_data.cpp
+++ b/source/libs/asura-lib-core/graphics/image_data.cpp
@@ -1,6 +1,7 @@
#include "image_data.h"
#include "png_decoder.h"
#include "stb_decoder.h"
+#include "image_decoder.h"
namespace AsuraEngine
{
@@ -35,7 +36,7 @@ namespace AsuraEngine
{
if (decoder->CanDecode(buffer))
{
- decoder->Decode(buffer, this);
+ decoder->Decode(buffer, *this);
return;
}
}
diff --git a/source/libs/asura-lib-core/graphics/image_data.h b/source/libs/asura-lib-core/graphics/image_data.h
index 1e711a8..53a9e85 100644
--- a/source/libs/asura-lib-core/graphics/image_data.h
+++ b/source/libs/asura-lib-core/graphics/image_data.h
@@ -3,9 +3,10 @@
#include <list>
-#include "scripting/luax.hpp"
-#include "filesystem/decoded_data.h"
-#include "image_decoder.h"
+#include <asura-lib-utils/scripting/portable.hpp>
+#include <asura-lib-utils/filesystem/decoded_data.h>
+#include <asura-lib-utils/filesystem/data_buffer.h>
+
#include "pixel_format.h"
#include "color.h"
@@ -14,9 +15,11 @@ namespace AsuraEngine
namespace Graphics
{
+ class ImageDecoder;
+
class ImageData ASURA_FINAL
: public Filesystem::DecodedData
- , public Scripting::Portable
+ , public Scripting::Portable<ImageData>
{
public:
@@ -24,7 +27,6 @@ namespace AsuraEngine
/// ͼƬļϢʧܣ׳쳣
///
ImageData(const Filesystem::DataBuffer& buffer);
-
~ImageData();
Color GetPixel(uint x, uint y);
@@ -45,14 +47,14 @@ namespace AsuraEngine
public:
- //----------------------------------------------------------------------------------------------------------
-
LUAX_DECL_FACTORY(ImageData);
- LUAX_DECL_METHOD(l_GetPixel);
- LUAX_DECL_METHOD(l_GetSize);
-
- //----------------------------------------------------------------------------------------------------------
+ LUAX_DECL_METHOD(_New);
+ LUAX_DECL_METHOD(_GetPixel);
+ LUAX_DECL_METHOD(_GetSize);
+ LUAX_DECL_METHOD(_GetWidth);
+ LUAX_DECL_METHOD(_GetHeight);
+ LUAX_DECL_METHOD(_GetPixelFormat);
};
diff --git a/source/libs/asura-lib-core/graphics/image_decoder.h b/source/libs/asura-lib-core/graphics/image_decoder.h
index 2c73fd1..921d129 100644
--- a/source/libs/asura-lib-core/graphics/image_decoder.h
+++ b/source/libs/asura-lib-core/graphics/image_decoder.h
@@ -1,9 +1,9 @@
#ifndef __ASURA_ENGINE_IMAGE_DECODER_H__
#define __ASURA_ENGINE_IMAGE_DECODER_H__
-#include "FileSystem/DataBuffer.h"
+#include <asura-lib-utils/filesystem/data_buffer.h>
-#include "ImageData.h"
+#include "image_data.h"
namespace AsuraEngine
{