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/_gpu_buffer.cpp13
-rw-r--r--source/modules/asura-core/graphics/binding/_index_buffer.cpp32
-rw-r--r--source/modules/asura-core/graphics/binding/_shader.cpp35
-rw-r--r--source/modules/asura-core/graphics/binding/_vertex_buffer.cpp39
4 files changed, 111 insertions, 8 deletions
diff --git a/source/modules/asura-core/graphics/binding/_gpu_buffer.cpp b/source/modules/asura-core/graphics/binding/_gpu_buffer.cpp
index 7a63c48..f55ba64 100644
--- a/source/modules/asura-core/graphics/binding/_gpu_buffer.cpp
+++ b/source/modules/asura-core/graphics/binding/_gpu_buffer.cpp
@@ -14,7 +14,6 @@ namespace AsuraEngine
LUAX_REGISTRY(GPUBuffer)
{
LUAX_REGISTER_METHODS(state,
- { "New", _New },
{ "Fill", _Fill },
{ "GetSize", _GetSize },
{ "GetCount", _GetCount }
@@ -45,14 +44,14 @@ namespace AsuraEngine
// buffer = GPUBuffer.New(mesh2d)
// buffer = GPUBuffer.New(canvas)
// buffer = GPUBuffer.New(shape)
- LUAX_IMPL_METHOD(GPUBuffer, _New)
- {
- LUAX_STATE(L);
+ //LUAX_IMPL_METHOD(GPUBuffer, _New)
+ //{
+ // LUAX_STATE(L);
- return 0;
- }
+ // return 0;
+ //}
- // gpubuffer:Fill({data unit list}, offseti)
+ // gpubuffer:Fill({data_unit_list}, offseti)
// data_unit_list ݵtable
// offseti : ʼǵĵطڵ(0ʼ
LUAX_IMPL_METHOD(GPUBuffer, _Fill)
diff --git a/source/modules/asura-core/graphics/binding/_index_buffer.cpp b/source/modules/asura-core/graphics/binding/_index_buffer.cpp
new file mode 100644
index 0000000..56bffb7
--- /dev/null
+++ b/source/modules/asura-core/graphics/binding/_index_buffer.cpp
@@ -0,0 +1,32 @@
+#include "../index_buffer.h"
+
+using namespace std;
+using namespace Luax;
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ LUAX_REGISTRY(IndexBuffer)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "New", _New }
+ );
+ }
+
+ LUAX_POSTPROCESS(IndexBuffer)
+ {
+
+ }
+
+ // IndexBuffer.New()
+ LUAX_IMPL_METHOD(IndexBuffer, _New)
+ {
+ LUAX_STATE(L);
+
+ return 0;
+ }
+
+ }
+}
diff --git a/source/modules/asura-core/graphics/binding/_shader.cpp b/source/modules/asura-core/graphics/binding/_shader.cpp
index e0a6320..0484997 100644
--- a/source/modules/asura-core/graphics/binding/_shader.cpp
+++ b/source/modules/asura-core/graphics/binding/_shader.cpp
@@ -136,11 +136,16 @@ namespace AsuraEngine
return 0;
}
- // shader:SetAttribPosition()
+ // shader:SetAttribPosition(vbo, offseti, stridei, normalized)
LUAX_IMPL_METHOD(Shader, _SetAttribPosition)
{
LUAX_PREPARE(L, Shader);
+ VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2);
+ uint offseti = state.GetValue<uint>(3, 0);
+ uint stridei = state.GetValue<uint>(4, 0);
+ bool normalized = state.GetValue<bool>(5, false);
+ self->SetAttribPosition(vbo, offseti, stridei, normalized);
return 0;
}
@@ -149,6 +154,10 @@ namespace AsuraEngine
{
LUAX_PREPARE(L, Shader);
+ VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2);
+ uint offseti = state.GetValue<uint>(3, 0);
+ uint stridei = state.GetValue<uint>(4, 0);
+ self->SetAttribTangent(vbo, offseti, stridei);
return 0;
}
@@ -157,6 +166,10 @@ namespace AsuraEngine
{
LUAX_PREPARE(L, Shader);
+ VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2);
+ uint offseti = state.GetValue<uint>(3, 0);
+ uint stridei = state.GetValue<uint>(4, 0);
+ self->SetAttribNormal(vbo, offseti, stridei);
return 0;
}
@@ -165,6 +178,10 @@ namespace AsuraEngine
{
LUAX_PREPARE(L, Shader);
+ VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2);
+ uint offseti = state.GetValue<uint>(3, 0);
+ uint stridei = state.GetValue<uint>(4, 0);
+ self->SetAttribColor(vbo, offseti, stridei);
return 0;
}
@@ -173,6 +190,10 @@ namespace AsuraEngine
{
LUAX_PREPARE(L, Shader);
+ VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2);
+ uint offseti = state.GetValue<uint>(3, 0);
+ uint stridei = state.GetValue<uint>(4, 0);
+ self->SetAttribPosition(vbo, offseti, stridei);
return 0;
}
@@ -181,6 +202,10 @@ namespace AsuraEngine
{
LUAX_PREPARE(L, Shader);
+ VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2);
+ uint offseti = state.GetValue<uint>(3, 0);
+ uint stridei = state.GetValue<uint>(4, 0);
+ self->SetAttribPosition(vbo, offseti, stridei);
return 0;
}
@@ -189,6 +214,10 @@ namespace AsuraEngine
{
LUAX_PREPARE(L, Shader);
+ VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2);
+ uint offseti = state.GetValue<uint>(3, 0);
+ uint stridei = state.GetValue<uint>(4, 0);
+ self->SetAttribPosition(vbo, offseti, stridei);
return 0;
}
@@ -197,6 +226,10 @@ namespace AsuraEngine
{
LUAX_PREPARE(L, Shader);
+ VertexBuffer* vbo = state.CheckUserdata<VertexBuffer>(2);
+ uint offseti = state.GetValue<uint>(3, 0);
+ uint stridei = state.GetValue<uint>(4, 0);
+ self->SetAttribPosition(vbo, offseti, stridei);
return 0;
}
diff --git a/source/modules/asura-core/graphics/binding/_vertex_buffer.cpp b/source/modules/asura-core/graphics/binding/_vertex_buffer.cpp
new file mode 100644
index 0000000..666e529
--- /dev/null
+++ b/source/modules/asura-core/graphics/binding/_vertex_buffer.cpp
@@ -0,0 +1,39 @@
+#include "../vertex_buffer.h"
+
+using namespace std;
+using namespace Luax;
+
+namespace AsuraEngine
+{
+ namespace Graphics
+ {
+
+ LUAX_REGISTRY(VertexBuffer)
+ {
+ LUAX_REGISTER_METHODS(state,
+ { "New", _New }
+ );
+ }
+
+ LUAX_POSTPROCESS(VertexBuffer)
+ {
+
+ }
+
+ // vbo = VertexBuffer.New(usage, data_type, count)
+ LUAX_IMPL_METHOD(VertexBuffer, _New)
+ {
+ LUAX_STATE(L);
+
+ BufferUsage usage = (BufferUsage)state.CheckValue<uint>(1);
+ BufferDataType datatype = (BufferDataType)state.CheckValue<uint>(2);
+ uint count = state.CheckValue<uint>(3);
+
+ VertexBuffer* vbo = new VertexBuffer(usage, datatype, count * GPUBuffer::GetDataTypeSize(datatype));
+ vbo->PushLuaxUserdata(state);
+
+ return 1;
+ }
+
+ }
+}