DrawMeshInstanced takes transforms as Buffer.

This commit is contained in:
jussi
2025-08-30 16:41:05 +03:00
parent 15deeccc4b
commit de672a85d2
9 changed files with 50 additions and 56 deletions

View File

@@ -2201,7 +2201,7 @@ int lcoreDecodeDataBase64( lua_State* L ) {
/*
> code = RL.ComputeCRC32( Buffer data )
Compute CRC32 hash code. Note! Buffer should be type BUFFER_UNSIGNED_CHAR
Compute CRC32 hash code.
- Failure return false
- Success return int
@@ -2209,12 +2209,7 @@ Compute CRC32 hash code. Note! Buffer should be type BUFFER_UNSIGNED_CHAR
int lcoreComputeCRC32( lua_State* L ) {
Buffer* buffer = uluaGetBuffer( L, 1 );
if ( buffer->type == BUFFER_UNSIGNED_CHAR ) {
lua_pushinteger( L, ComputeCRC32( buffer->data, buffer->size ) );
}
else {
lua_pushboolean( L, false );
}
lua_pushinteger( L, ComputeCRC32( buffer->data, buffer->size ) );
return 1;
}
@@ -2222,7 +2217,7 @@ int lcoreComputeCRC32( lua_State* L ) {
/*
> code = RL.ComputeMD5( Buffer data )
Compute MD5 hash code, returns static int[4] (16 bytes). Note! Buffer should be type BUFFER_UNSIGNED_CHAR
Compute MD5 hash code, returns static int[4] (16 bytes).
- Failure return false
- Success return int{4}
@@ -2230,17 +2225,12 @@ Compute MD5 hash code, returns static int[4] (16 bytes). Note! Buffer should be
int lcoreComputeMD5( lua_State* L ) {
Buffer* buffer = uluaGetBuffer( L, 1 );
if ( buffer->type == BUFFER_UNSIGNED_CHAR ) {
unsigned int* code = ComputeMD5( buffer->data, buffer->size );
lua_createtable( L, 4, 0 );
unsigned int* code = ComputeMD5( buffer->data, buffer->size );
lua_createtable( L, 4, 0 );
for ( unsigned int i = 0; i < 4; i++ ) {
lua_pushinteger( L, code[i] );
lua_rawseti( L, -2, i + 1 );
}
}
else {
lua_pushboolean( L, false );
for ( unsigned int i = 0; i < 4; i++ ) {
lua_pushinteger( L, code[i] );
lua_rawseti( L, -2, i + 1 );
}
return 1;
@@ -2249,7 +2239,7 @@ int lcoreComputeMD5( lua_State* L ) {
/*
> code = RL.ComputeSHA1( Buffer data )
Compute SHA1 hash code, returns static int[5] (20 bytes). Note! Buffer should be type BUFFER_UNSIGNED_CHAR
Compute SHA1 hash code, returns static int[5] (20 bytes).
- Failure return false
- Success return int{5}
@@ -2257,17 +2247,12 @@ Compute SHA1 hash code, returns static int[5] (20 bytes). Note! Buffer should be
int lcoreComputeSHA1( lua_State* L ) {
Buffer* buffer = uluaGetBuffer( L, 1 );
if ( buffer->type == BUFFER_UNSIGNED_CHAR ) {
unsigned int* code = ComputeSHA1( buffer->data, buffer->size );
lua_createtable( L, 5, 0 );
unsigned int* code = ComputeSHA1( buffer->data, buffer->size );
lua_createtable( L, 5, 0 );
for ( unsigned int i = 0; i < 5; i++ ) {
lua_pushinteger( L, code[i] );
lua_rawseti( L, -2, i + 1 );
}
}
else {
lua_pushboolean( L, false );
for ( unsigned int i = 0; i < 5; i++ ) {
lua_pushinteger( L, code[i] );
lua_rawseti( L, -2, i + 1 );
}
return 1;

View File

@@ -1145,29 +1145,17 @@ int lmodelsDrawMesh( lua_State* L ) {
}
/*
> RL.DrawMeshInstanced( Mesh mesh, Material material, Matrix{} transforms, int instances )
> RL.DrawMeshInstanced( Mesh mesh, Material material, Buffer transforms, int instances )
Draw multiple mesh instances with material and different transforms
*/
int lmodelsDrawMeshInstanced( lua_State* L ) {
Mesh* mesh = uluaGetMesh( L, 1 );
Material* material = uluaGetMaterial( L, 2 );
luaL_checktype( L, 3, LUA_TTABLE );
Buffer* transforms = uluaGetBuffer( L, 3 );
int instances = luaL_checkinteger( L, 4 );
Matrix transforms[ instances ];
int t = 3, i = 0;
lua_pushnil( L );
while ( lua_next( L, t ) != 0 ) {
if ( lua_istable( L, -1 ) ) {
transforms[i] = uluaGetMatrix( L, lua_gettop( L ) );
}
i++;
lua_pop( L, 1 );
}
DrawMeshInstanced( *mesh, *material, transforms, instances );
DrawMeshInstanced( *mesh, *material, (Matrix*)transforms->data, instances );
return 0;
}

View File

@@ -99,7 +99,6 @@ int lcoreGetKeyScancode( lua_State* L ) {
Called when the window is resized. Type GLFW_WINDOW_SIZE_EVENT
*/
static void windowSizeEvent( GLFWwindow* window, int width, int height ) {
// GLFWwindowsizefun windowSizeEvent( GLFWwindow* window, int width, int height ) {
/* Pass through to raylib callback. */
state->raylibWindowSizeCallback( window, width, height );