- [CHG] surf.target() i surf.source() sense paràmetres ara el que fan es tornar les surfaces actuals de target i de source

This commit is contained in:
2026-02-24 22:18:54 +01:00
parent fc962b4e18
commit a17a1bb517
5 changed files with 27 additions and 5 deletions

View File

@@ -97,8 +97,8 @@ extern "C" {
const int numargs = lua_gettop(L); const int numargs = lua_gettop(L);
switch (numargs) { switch (numargs) {
case 0: { case 0: {
setdest(0); lua_pushinteger(L, getdest());
return 0; return 1;
} }
case 1: { case 1: {
uint8_t surface = luaL_checkinteger(L, 1); uint8_t surface = luaL_checkinteger(L, 1);
@@ -114,8 +114,8 @@ extern "C" {
const int numargs = lua_gettop(L); const int numargs = lua_gettop(L);
switch (numargs) { switch (numargs) {
case 0: { case 0: {
setsource(0); lua_pushinteger(L, getsource());
return 0; return 1;
} }
case 1: { case 1: {
uint8_t surface = luaL_checkinteger(L, 1); uint8_t surface = luaL_checkinteger(L, 1);

View File

@@ -359,6 +359,18 @@ void setmap(uint8_t surface) {
map_surface = &surfaces[surface]; map_surface = &surfaces[surface];
} }
uint8_t getdest()
{
for (unsigned int i=0; i<MAX_SURFACES; ++i) if (dest_surface == &surfaces[i]) return i;
return 0;
}
uint8_t getsource()
{
for (unsigned int i=0; i<MAX_SURFACES; ++i) if (source_surface == &surfaces[i]) return i;
return 0;
}
uint8_t getmap() uint8_t getmap()
{ {
for (unsigned int i=0; i<MAX_SURFACES; ++i) if (map_surface == &surfaces[i]) return i; for (unsigned int i=0; i<MAX_SURFACES; ++i) if (map_surface == &surfaces[i]) return i;

2
mini.h
View File

@@ -134,6 +134,8 @@ int surfh(uint8_t surface);
void setdest(uint8_t surface); void setdest(uint8_t surface);
void setsource(uint8_t surface); void setsource(uint8_t surface);
void setmap(uint8_t surface); void setmap(uint8_t surface);
uint8_t getdest();
uint8_t getsource();
uint8_t getmap(); uint8_t getmap();
void shader_init(const char* vshader, const char* fshader); void shader_init(const char* vshader, const char* fshader);

View File

@@ -1,3 +1,3 @@
#pragma once #pragma once
#define MINI_VERSION "1.3.15" #define MINI_VERSION "1.3.16"

View File

@@ -37,10 +37,18 @@ function surf.free(surface) end
---Retrieve width and height of surface ---Retrieve width and height of surface
function surf.size(surface) end function surf.size(surface) end
---@return number surface
---Get current target surface
function surf.target() end
---@param surface number ---@param surface number
---Set surface as target ---Set surface as target
function surf.target(surface) end function surf.target(surface) end
---@return number surface
---Get current source surface
function surf.source() end
---@param surface number ---@param surface number
---Set surface as source ---Set surface as source
function surf.source(surface) end function surf.source(surface) end