mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Add Depth compare / shadow sampler support. Officially this is only supported in glsl3 shaders.
- Add Texture:setDepthSampleMode(comparemode). Only works on textures with depth pixel formats. A texture with the depth sample mode set will only work with a depth sampler. - Add DepthImage, DepthArrayImage, and DepthCubeImage sampler keywords to glsl3. --HG-- branch : minor
This commit is contained in:
@@ -244,6 +244,42 @@ int w_Texture_isReadable(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int w_Texture_setDepthSampleMode(lua_State *L)
|
||||
{
|
||||
Texture *t = luax_checktexture(L, 1);
|
||||
|
||||
Optional<CompareMode> mode;
|
||||
if (!lua_isnoneornil(L, 2))
|
||||
{
|
||||
const char *str = luaL_checkstring(L, 2);
|
||||
|
||||
mode.hasValue = true;
|
||||
if (!getConstant(str, mode.value))
|
||||
return luaL_error(L, "Invalid compare mode: %s", str);
|
||||
}
|
||||
|
||||
luax_catchexcept(L, [&]() { t->setDepthSampleMode(mode); });
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_Texture_getDepthSampleMode(lua_State *L)
|
||||
{
|
||||
Texture *t = luax_checktexture(L, 1);
|
||||
Optional<CompareMode> mode = t->getDepthSampleMode();
|
||||
|
||||
if (mode.hasValue)
|
||||
{
|
||||
const char *str = nullptr;
|
||||
if (!getConstant(mode.value, str))
|
||||
return luaL_error(L, "Unknown compare mode.");
|
||||
lua_pushstring(L, str);
|
||||
}
|
||||
else
|
||||
lua_pushnil(L);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
const luaL_Reg w_Texture_functions[] =
|
||||
{
|
||||
{ "getTextureType", w_Texture_getTextureType },
|
||||
@@ -265,6 +301,8 @@ const luaL_Reg w_Texture_functions[] =
|
||||
{ "getWrap", w_Texture_getWrap },
|
||||
{ "getFormat", w_Texture_getFormat },
|
||||
{ "isReadable", w_Texture_isReadable },
|
||||
{ "getDepthSampleMode", w_Texture_getDepthSampleMode },
|
||||
{ "setDepthSampleMode", w_Texture_setDepthSampleMode },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user