mirror of
https://github.com/bjornbytes/lovr.git
synced 2024-07-02 12:33:52 +00:00
Add the ability to set Texture LOD bias;
This commit is contained in:
parent
66ca77abd1
commit
eb45b6f04f
|
@ -28,11 +28,12 @@ int l_lovrTextureGetFilter(lua_State* L) {
|
|||
Texture* texture = luax_checktypeof(L, 1, Texture);
|
||||
TextureFilter filter = lovrTextureGetFilter(texture);
|
||||
lua_pushstring(L, FilterModes[filter.mode]);
|
||||
lua_pushnumber(L, filter.sharpness);
|
||||
if (filter.mode == FILTER_ANISOTROPIC) {
|
||||
lua_pushnumber(L, filter.anisotropy);
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
|
||||
int l_lovrTextureGetHeight(lua_State* L) {
|
||||
|
@ -85,8 +86,10 @@ int l_lovrTextureReplacePixels(lua_State* L) {
|
|||
int l_lovrTextureSetFilter(lua_State* L) {
|
||||
Texture* texture = luax_checktypeof(L, 1, Texture);
|
||||
FilterMode mode = luaL_checkoption(L, 2, NULL, FilterModes);
|
||||
float anisotropy = luaL_optnumber(L, 3, 1.);
|
||||
lovrTextureSetFilter(texture, (TextureFilter) { .mode = mode, .anisotropy = anisotropy });
|
||||
float sharpness = luaL_optnumber(L, 3, 0.);
|
||||
float anisotropy = luaL_optnumber(L, 4, 1.);
|
||||
TextureFilter filter = { .mode = mode, .sharpness = sharpness, .anisotropy = anisotropy };
|
||||
lovrTextureSetFilter(texture, filter);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1025,6 +1025,7 @@ void lovrTextureSetFilter(Texture* texture, TextureFilter filter) {
|
|||
break;
|
||||
}
|
||||
|
||||
glTexParameteri(texture->glType, GL_TEXTURE_LOD_BIAS, -filter.sharpness);
|
||||
glTexParameteri(texture->glType, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropy);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ typedef enum {
|
|||
typedef struct {
|
||||
FilterMode mode;
|
||||
float anisotropy;
|
||||
float sharpness;
|
||||
} TextureFilter;
|
||||
|
||||
typedef enum {
|
||||
|
|
Loading…
Reference in a new issue