mirror of
https://github.com/love2d/love.git
synced 2026-08-14 01:20:56 +02:00
Add basic ortho and perspective projection APIs to love.graphics.
- Added love.graphics.setOrthoProjection. - Added love.graphics.setPerspectiveProjection. - Added love.graphics.resetProjection. Note that the projection is reset whenever the canvas changes.
This commit is contained in:
@@ -3572,6 +3572,34 @@ int w_inverseTransformPoint(lua_State *L)
|
||||
return 2;
|
||||
}
|
||||
|
||||
int w_setOrthoProjection(lua_State *L)
|
||||
{
|
||||
float w = (float) luaL_checknumber(L, 1);
|
||||
float h = (float) luaL_checknumber(L, 2);
|
||||
float near = (float) luaL_optnumber(L, 3, -10.0);
|
||||
float far = (float) luaL_optnumber(L, 4, 10.0);
|
||||
|
||||
luax_catchexcept(L, [&]() { instance()->setOrthoProjection(w, h, near, far); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_setPerspectiveProjection(lua_State *L)
|
||||
{
|
||||
float verticalfov = (float) luaL_checknumber(L, 1);
|
||||
float aspect = (float) luaL_checknumber(L, 2);
|
||||
float near = (float) luaL_checknumber(L, 3);
|
||||
float far = (float) luaL_checknumber(L, 4);
|
||||
|
||||
luax_catchexcept(L, [&]() { instance()->setPerspectiveProjection(verticalfov, aspect, near, far); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_resetProjection(lua_State */*L*/)
|
||||
{
|
||||
instance()->resetProjection();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// List of functions to wrap.
|
||||
static const luaL_Reg functions[] =
|
||||
@@ -3710,6 +3738,10 @@ static const luaL_Reg functions[] =
|
||||
{ "transformPoint", w_transformPoint },
|
||||
{ "inverseTransformPoint", w_inverseTransformPoint },
|
||||
|
||||
{ "setOrthoProjection", w_setOrthoProjection },
|
||||
{ "setPerspectiveProjection", w_setPerspectiveProjection },
|
||||
{ "resetProjection", w_resetProjection },
|
||||
|
||||
// Deprecated
|
||||
{ "newImage", w_newImage },
|
||||
{ "newArrayImage", w_newArrayImage },
|
||||
|
||||
Reference in New Issue
Block a user