mirror of
https://github.com/love2d/love.git
synced 2026-08-20 04:30:09 +02:00
Added a new variant of Shader:send for matrices: Shader:send(uniformname, is_column_major, matrix, ...).
If is_column_major is true, the table(s) passed as subsequent arguments will be treated as column-major instead of row-major. This matches the 0.10.x behaviour of Shader:send for matrices. --HG-- branch : minor
This commit is contained in:
@@ -150,6 +150,14 @@ int w_Shader_sendBooleans(lua_State *L, int startidx, Shader *shader, const Shad
|
|||||||
|
|
||||||
int w_Shader_sendMatrices(lua_State *L, int startidx, Shader *shader, const Shader::UniformInfo *info)
|
int w_Shader_sendMatrices(lua_State *L, int startidx, Shader *shader, const Shader::UniformInfo *info)
|
||||||
{
|
{
|
||||||
|
bool columnmajor = false;
|
||||||
|
|
||||||
|
if (lua_isboolean(L, startidx))
|
||||||
|
{
|
||||||
|
columnmajor = lua_toboolean(L, startidx);
|
||||||
|
startidx++;
|
||||||
|
}
|
||||||
|
|
||||||
int count = _getCount(L, startidx, info);
|
int count = _getCount(L, startidx, info);
|
||||||
int columns = info->matrix.columns;
|
int columns = info->matrix.columns;
|
||||||
int rows = info->matrix.rows;
|
int rows = info->matrix.rows;
|
||||||
@@ -169,6 +177,23 @@ int w_Shader_sendMatrices(lua_State *L, int startidx, Shader *shader, const Shad
|
|||||||
{
|
{
|
||||||
int n = i * elements;
|
int n = i * elements;
|
||||||
|
|
||||||
|
if (columnmajor)
|
||||||
|
{
|
||||||
|
for (int column = 0; column < columns; column++)
|
||||||
|
{
|
||||||
|
lua_rawgeti(L, startidx + i, column + 1);
|
||||||
|
|
||||||
|
for (int row = 0; row < rows; row++)
|
||||||
|
{
|
||||||
|
lua_rawgeti(L, -(row + 1), row + 1);
|
||||||
|
values[n + (column * rows + row)] = (float) luaL_checknumber(L, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
lua_pop(L, rows + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (int row = 0; row < rows; row++)
|
for (int row = 0; row < rows; row++)
|
||||||
{
|
{
|
||||||
lua_rawgeti(L, startidx + i, row + 1);
|
lua_rawgeti(L, startidx + i, row + 1);
|
||||||
@@ -184,10 +209,24 @@ int w_Shader_sendMatrices(lua_State *L, int startidx, Shader *shader, const Shad
|
|||||||
lua_pop(L, columns + 1);
|
lua_pop(L, columns + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int n = i * elements;
|
int n = i * elements;
|
||||||
|
|
||||||
|
if (columnmajor)
|
||||||
|
{
|
||||||
|
for (int column = 0; column < columns; column++)
|
||||||
|
{
|
||||||
|
for (int row = 0; row < rows; row++)
|
||||||
|
{
|
||||||
|
lua_rawgeti(L, startidx + i, column * rows + row + 1);
|
||||||
|
values[n + (column * rows + row)] = (float) luaL_checknumber(L, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (int column = 0; column < columns; column++)
|
for (int column = 0; column < columns; column++)
|
||||||
{
|
{
|
||||||
for (int row = 0; row < rows; row++)
|
for (int row = 0; row < rows; row++)
|
||||||
@@ -198,6 +237,7 @@ int w_Shader_sendMatrices(lua_State *L, int startidx, Shader *shader, const Shad
|
|||||||
values[n + (column * rows + row)] = (float) luaL_checknumber(L, -1);
|
values[n + (column * rows + row)] = (float) luaL_checknumber(L, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lua_pop(L, elements);
|
lua_pop(L, elements);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user