From 816f132c9def34a5417f919c2acf5d6e9c2a6d02 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 18 Jan 2020 17:37:03 -0400 Subject: [PATCH] Expose GraphicsBuffer type to Lua. It currently doesn't have any methods or any way to access it, yet. --- CMakeLists.txt | 2 + .../xcode/liblove.xcodeproj/project.pbxproj | 10 +++++ src/modules/graphics/wrap_Buffer.cpp | 45 +++++++++++++++++++ src/modules/graphics/wrap_Buffer.h | 37 +++++++++++++++ src/modules/graphics/wrap_Graphics.cpp | 1 + src/modules/graphics/wrap_Graphics.h | 1 + 6 files changed, 96 insertions(+) create mode 100644 src/modules/graphics/wrap_Buffer.cpp create mode 100644 src/modules/graphics/wrap_Buffer.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 72953c5e4..b5fb4786c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -559,6 +559,8 @@ set(LOVE_SRC_MODULE_GRAPHICS_ROOT src/modules/graphics/Video.h src/modules/graphics/Volatile.cpp src/modules/graphics/Volatile.h + src/modules/graphics/wrap_Buffer.cpp + src/modules/graphics/wrap_Buffer.h src/modules/graphics/wrap_Canvas.cpp src/modules/graphics/wrap_Canvas.h src/modules/graphics/wrap_Font.cpp diff --git a/platform/xcode/liblove.xcodeproj/project.pbxproj b/platform/xcode/liblove.xcodeproj/project.pbxproj index 79bc992f1..2fa20c99a 100644 --- a/platform/xcode/liblove.xcodeproj/project.pbxproj +++ b/platform/xcode/liblove.xcodeproj/project.pbxproj @@ -781,6 +781,9 @@ FA15DFB01F9B8D6A0042AB22 /* wrap_Data.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA6A2B651F5F7B6B0074C308 /* wrap_Data.cpp */; }; FA15DFB11F9B8D820042AB22 /* OggDemuxer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAA54AC91F91660400A8FA7B /* OggDemuxer.cpp */; }; FA15DFB21F9B8D840042AB22 /* TheoraVideoStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FAA54AC81F91660400A8FA7B /* TheoraVideoStream.cpp */; }; + FA18CEC523D3AE6700263725 /* wrap_Buffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA18CEC323D3AE6700263725 /* wrap_Buffer.cpp */; }; + FA18CEC623D3AE6800263725 /* wrap_Buffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA18CEC323D3AE6700263725 /* wrap_Buffer.cpp */; }; + FA18CEC723D3AE6800263725 /* wrap_Buffer.h in Headers */ = {isa = PBXBuildFile; fileRef = FA18CEC423D3AE6700263725 /* wrap_Buffer.h */; }; FA1BA09D1E16CFCE00AA2803 /* Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA09B1E16CFCE00AA2803 /* Font.cpp */; }; FA1BA09E1E16CFCE00AA2803 /* Font.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FA1BA09B1E16CFCE00AA2803 /* Font.cpp */; }; FA1BA09F1E16CFCE00AA2803 /* Font.h in Headers */ = {isa = PBXBuildFile; fileRef = FA1BA09C1E16CFCE00AA2803 /* Font.h */; }; @@ -1801,6 +1804,8 @@ FA1557C11CE90BD200AFF582 /* EXRHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EXRHandler.cpp; sourceTree = ""; }; FA1557C21CE90BD200AFF582 /* EXRHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXRHandler.h; sourceTree = ""; }; FA15DFAB1F9B8C850042AB22 /* StringMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringMap.cpp; sourceTree = ""; }; + FA18CEC323D3AE6700263725 /* wrap_Buffer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Buffer.cpp; sourceTree = ""; }; + FA18CEC423D3AE6700263725 /* wrap_Buffer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = wrap_Buffer.h; sourceTree = ""; }; FA1BA09B1E16CFCE00AA2803 /* Font.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Font.cpp; sourceTree = ""; }; FA1BA09C1E16CFCE00AA2803 /* Font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Font.h; sourceTree = ""; }; FA1BA0A01E16D97500AA2803 /* wrap_Font.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Font.cpp; sourceTree = ""; }; @@ -2879,6 +2884,8 @@ FADF54061E3D78F700012CC0 /* Video.h */, FA0B7BC01A95902C000E1D17 /* Volatile.cpp */, FA0B7BC11A95902C000E1D17 /* Volatile.h */, + FA18CEC323D3AE6700263725 /* wrap_Buffer.cpp */, + FA18CEC423D3AE6700263725 /* wrap_Buffer.h */, FA1BA0AA1E16F9EE00AA2803 /* wrap_Canvas.cpp */, FA1BA0AB1E16F9EE00AA2803 /* wrap_Canvas.h */, FA1BA0A01E16D97500AA2803 /* wrap_Font.cpp */, @@ -3967,6 +3974,7 @@ FA0B7A631A958EA3000E1D17 /* b2ContactManager.h in Headers */, FA0B7E771A95902C000E1D17 /* wrap_WeldJoint.h in Headers */, FA0B7A911A958EA3000E1D17 /* b2FrictionJoint.h in Headers */, + FA18CEC723D3AE6800263725 /* wrap_Buffer.h in Headers */, FA0B7E291A95902C000E1D17 /* PulleyJoint.h in Headers */, FA6BDE5C1F31725300786805 /* Color.h in Headers */, FA0B7E231A95902C000E1D17 /* PolygonShape.h in Headers */, @@ -4539,6 +4547,7 @@ FAF6C9E023C2DE2900D7B5BC /* SpvTools.cpp in Sources */, FAE64A8F2071364200BC7981 /* physfs_platform_unix.c in Sources */, FA0B7A681A958EA3000E1D17 /* b2Island.cpp in Sources */, + FA18CEC623D3AE6800263725 /* wrap_Buffer.cpp in Sources */, FA0B7E2B1A95902C000E1D17 /* RevoluteJoint.cpp in Sources */, FA0B7B291A958EA3000E1D17 /* simplexnoise1234.cpp in Sources */, FA0B7D261A95902C000E1D17 /* wrap_Font.cpp in Sources */, @@ -4794,6 +4803,7 @@ FAF140A91E20934C00F898D2 /* SymbolTable.cpp in Sources */, FA0B7E181A95902C000E1D17 /* MotorJoint.cpp in Sources */, FA0B7E4E1A95902C000E1D17 /* wrap_Fixture.cpp in Sources */, + FA18CEC523D3AE6700263725 /* wrap_Buffer.cpp in Sources */, FAF6C9F423C2DE2900D7B5BC /* Logger.cpp in Sources */, FA0B7EBE1A95902C000E1D17 /* Thread.cpp in Sources */, FAC7CD8F1FE35E95006A60C7 /* physfs_platform_posix.c in Sources */, diff --git a/src/modules/graphics/wrap_Buffer.cpp b/src/modules/graphics/wrap_Buffer.cpp new file mode 100644 index 000000000..7b69a6519 --- /dev/null +++ b/src/modules/graphics/wrap_Buffer.cpp @@ -0,0 +1,45 @@ +/** +* Copyright (c) 2006-2020 LOVE Development Team +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +**/ + +#include "wrap_Buffer.h" +#include "Buffer.h" + +namespace love +{ +namespace graphics +{ + +Buffer *luax_checkbuffer(lua_State *L, int idx) +{ + return luax_checktype(L, idx); +} + +static const luaL_Reg w_Buffer_functions[] = +{ + { 0, 0 } +}; + +extern "C" int luaopen_graphicsbuffer(lua_State *L) +{ + return luax_register_type(L, &Buffer::type, w_Buffer_functions, nullptr); +} + +} // graphics +} // love diff --git a/src/modules/graphics/wrap_Buffer.h b/src/modules/graphics/wrap_Buffer.h new file mode 100644 index 000000000..6a0d42412 --- /dev/null +++ b/src/modules/graphics/wrap_Buffer.h @@ -0,0 +1,37 @@ +/** +* Copyright (c) 2006-2020 LOVE Development Team +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +**/ + +#pragma once + +// LOVE +#include "common/runtime.h" + +namespace love +{ +namespace graphics +{ + +class Buffer; + +Buffer *luax_checkbuffer(lua_State *L, int idx); +extern "C" int luaopen_graphicsbuffer(lua_State *L); + +} // graphics +} // love diff --git a/src/modules/graphics/wrap_Graphics.cpp b/src/modules/graphics/wrap_Graphics.cpp index 741954b48..0ea9e52c0 100644 --- a/src/modules/graphics/wrap_Graphics.cpp +++ b/src/modules/graphics/wrap_Graphics.cpp @@ -3134,6 +3134,7 @@ static const lua_CFunction types[] = luaopen_font, luaopen_image, luaopen_quad, + luaopen_graphicsbuffer, luaopen_spritebatch, luaopen_particlesystem, luaopen_canvas, diff --git a/src/modules/graphics/wrap_Graphics.h b/src/modules/graphics/wrap_Graphics.h index 7359ef652..7876f3040 100644 --- a/src/modules/graphics/wrap_Graphics.h +++ b/src/modules/graphics/wrap_Graphics.h @@ -32,6 +32,7 @@ #include "wrap_Mesh.h" #include "wrap_Text.h" #include "wrap_Video.h" +#include "wrap_Buffer.h" #include "Graphics.h" namespace love