From 866e00474be3bfe0e7dac73b720af0b9ebf7109a Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 13 Apr 2019 20:15:07 +0800 Subject: *misc --- .../asura-core/graphics/binding/_gpu_buffer.cpp | 13 ++++---- .../asura-core/graphics/binding/_index_buffer.cpp | 32 ++++++++++++++++++ .../asura-core/graphics/binding/_shader.cpp | 35 ++++++++++++++++++- .../asura-core/graphics/binding/_vertex_buffer.cpp | 39 ++++++++++++++++++++++ 4 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 source/modules/asura-core/graphics/binding/_index_buffer.cpp create mode 100644 source/modules/asura-core/graphics/binding/_vertex_buffer.cpp (limited to 'source/modules/asura-core/graphics/binding') 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(2); + uint offseti = state.GetValue(3, 0); + uint stridei = state.GetValue(4, 0); + bool normalized = state.GetValue(5, false); + self->SetAttribPosition(vbo, offseti, stridei, normalized); return 0; } @@ -149,6 +154,10 @@ namespace AsuraEngine { LUAX_PREPARE(L, Shader); + VertexBuffer* vbo = state.CheckUserdata(2); + uint offseti = state.GetValue(3, 0); + uint stridei = state.GetValue(4, 0); + self->SetAttribTangent(vbo, offseti, stridei); return 0; } @@ -157,6 +166,10 @@ namespace AsuraEngine { LUAX_PREPARE(L, Shader); + VertexBuffer* vbo = state.CheckUserdata(2); + uint offseti = state.GetValue(3, 0); + uint stridei = state.GetValue(4, 0); + self->SetAttribNormal(vbo, offseti, stridei); return 0; } @@ -165,6 +178,10 @@ namespace AsuraEngine { LUAX_PREPARE(L, Shader); + VertexBuffer* vbo = state.CheckUserdata(2); + uint offseti = state.GetValue(3, 0); + uint stridei = state.GetValue(4, 0); + self->SetAttribColor(vbo, offseti, stridei); return 0; } @@ -173,6 +190,10 @@ namespace AsuraEngine { LUAX_PREPARE(L, Shader); + VertexBuffer* vbo = state.CheckUserdata(2); + uint offseti = state.GetValue(3, 0); + uint stridei = state.GetValue(4, 0); + self->SetAttribPosition(vbo, offseti, stridei); return 0; } @@ -181,6 +202,10 @@ namespace AsuraEngine { LUAX_PREPARE(L, Shader); + VertexBuffer* vbo = state.CheckUserdata(2); + uint offseti = state.GetValue(3, 0); + uint stridei = state.GetValue(4, 0); + self->SetAttribPosition(vbo, offseti, stridei); return 0; } @@ -189,6 +214,10 @@ namespace AsuraEngine { LUAX_PREPARE(L, Shader); + VertexBuffer* vbo = state.CheckUserdata(2); + uint offseti = state.GetValue(3, 0); + uint stridei = state.GetValue(4, 0); + self->SetAttribPosition(vbo, offseti, stridei); return 0; } @@ -197,6 +226,10 @@ namespace AsuraEngine { LUAX_PREPARE(L, Shader); + VertexBuffer* vbo = state.CheckUserdata(2); + uint offseti = state.GetValue(3, 0); + uint stridei = state.GetValue(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(1); + BufferDataType datatype = (BufferDataType)state.CheckValue(2); + uint count = state.CheckValue(3); + + VertexBuffer* vbo = new VertexBuffer(usage, datatype, count * GPUBuffer::GetDataTypeSize(datatype)); + vbo->PushLuaxUserdata(state); + + return 1; + } + + } +} -- cgit v1.1-26-g67d0