summaryrefslogtreecommitdiff
path: root/src/lua_core.c
diff options
context:
space:
mode:
authorjussi2023-10-26 20:09:16 +0300
committerjussi2023-10-26 20:09:16 +0300
commit56c365c8cc88455d69df42e7842c986e760c776e (patch)
treed4ad09280cdad3ad0e46146aa4cd149f5400b9b0 /src/lua_core.c
parent168f4959d4a265d7615a81b667917754ca85bfce (diff)
downloadreilua-enhanced-56c365c8cc88455d69df42e7842c986e760c776e.tar.gz
reilua-enhanced-56c365c8cc88455d69df42e7842c986e760c776e.tar.bz2
reilua-enhanced-56c365c8cc88455d69df42e7842c986e760c776e.zip
Buffer userdata object and rlgl Vertex buffers management.
Diffstat (limited to 'src/lua_core.c')
-rw-r--r--src/lua_core.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/lua_core.c b/src/lua_core.c
index f8b25bb..1d6372b 100644
--- a/src/lua_core.c
+++ b/src/lua_core.c
@@ -618,6 +618,11 @@ static void defineGlobals() {
assignGlobalInt( GLFW_RELEASE, "GLFW_RELEASE" );
assignGlobalInt( GLFW_PRESS, "GLFW_PRESS" );
assignGlobalInt( GLFW_REPEAT, "GLFW_REPEAT" );
+ /* CBuffer Data Types */
+ assignGlobalInt( BUFFER_UNSIGNED_CHAR, "BUFFER_UNSIGNED_CHAR" );
+ assignGlobalInt( BUFFER_UNSIGNED_SHORT, "BUFFER_UNSIGNED_SHORT" );
+ assignGlobalInt( BUFFER_UNSIGNED_INT, "BUFFER_UNSIGNED_INT" );
+ assignGlobalInt( BUFFER_FLOAT, "BUFFER_FLOAT" );
/* Window Events. */
assignGlobalInt( EVENT_WINDOW_SIZE, "EVENT_WINDOW_SIZE" );
assignGlobalInt( EVENT_WINDOW_MAXIMIZE, "EVENT_WINDOW_MAXIMIZE" );
@@ -636,6 +641,21 @@ static void defineGlobals() {
lua_pop( L, -1 );
}
+static int freeBuffer( lua_State *L ) {
+ Buffer *buffer = luaL_checkudata ( L, 1, "Buffer" );
+ free( buffer->data );
+}
+
+static void defineCBuffer() {
+ lua_State *L = state->luaState;
+
+ luaL_newmetatable( L, "Buffer" );
+ lua_pushvalue( L, -1 );
+ lua_setfield( L, -2, "__index" );
+ lua_pushcfunction( L, freeBuffer );
+ lua_setfield( L, -2, "__gc" );
+}
+
// Custom logging funtion.
static void logCustom( int logLevel, const char *text, va_list args ) {
char string[ STRING_LEN ] = {'\0'};
@@ -1019,6 +1039,7 @@ bool luaInit( int argn, const char **argc ) {
return false;
}
defineGlobals();
+ defineCBuffer();
/* Set arguments. */
lua_getglobal( L, "RL" );
@@ -1235,6 +1256,7 @@ void luaRegister() {
assingGlobalFunction( "SetLogLevelInvalid", lcoreSetLogLevelInvalid );
assingGlobalFunction( "GetLogLevelInvalid", lcoreGetLogLevelInvalid );
assingGlobalFunction( "OpenURL", lcoreOpenURL );
+ assingGlobalFunction( "LoadBuffer", lcoreLoadBuffer );
/* Cursor. */
assingGlobalFunction( "ShowCursor", lcoreShowCursor );
assingGlobalFunction( "HideCursor", lcoreHideCursor );
@@ -1944,10 +1966,18 @@ void luaRegister() {
/* Vertex buffers management. */
assingGlobalFunction( "rlLoadVertexArray", lrlglLoadVertexArray );
assingGlobalFunction( "rlLoadVertexBuffer", lrlglLoadVertexBuffer );
+ assingGlobalFunction( "rlLoadVertexBufferElement", lrlglLoadVertexBufferElement );
+ assingGlobalFunction( "rlUpdateVertexBuffer", lrlglUpdateVertexBuffer );
+ assingGlobalFunction( "rlUpdateVertexBufferElements", lrlglUpdateVertexBufferElements );
assingGlobalFunction( "rlUnloadVertexArray", lrlglUnloadVertexArray );
assingGlobalFunction( "rlUnloadVertexBuffer", lrlglUnloadVertexBuffer );
assingGlobalFunction( "rlSetVertexAttribute", lrlglSetVertexAttribute );
+ assingGlobalFunction( "rlSetVertexAttributeDivisor", lrlglSetVertexAttributeDivisor );
+ assingGlobalFunction( "rlSetVertexAttributeDefault", lrlglSetVertexAttributeDefault );
assingGlobalFunction( "rlDrawVertexArray", lrlglDrawVertexArray );
+ assingGlobalFunction( "rlDrawVertexArrayElements", lrlglDrawVertexArrayElements );
+ assingGlobalFunction( "rlDrawVertexArrayInstanced", lrlglDrawVertexArrayInstanced );
+ assingGlobalFunction( "rlDrawVertexArrayElementsInstanced", lrlglDrawVertexArrayElementsInstanced );
/* Textures management. */
assingGlobalFunction( "rlLoadTexture", lrlglLoadTexture );
assingGlobalFunction( "rlLoadTextureDepth", lrlglLoadTextureDepth );