add mipmaps and bilinear/trilinear/anisotropic filters

This commit is contained in:
darkrose 2013-12-08 19:50:36 +10:00
parent 63991834a9
commit 3814c0459c
5 changed files with 107 additions and 5 deletions

View File

@ -82,6 +82,10 @@ void set_default_settings(Settings *settings)
settings->setDefault("enable_3d_clouds", "false");
settings->setDefault("opaque_water", "false");
settings->setDefault("enable_particles", "true");
settings->setDefault("mip_map", "false");
settings->setDefault("anisotropic_filter", "false");
settings->setDefault("bilinear_filter", "false");
settings->setDefault("trilinear_filter", "false");
// Server stuff
// "map-dir" doesn't exist by default.

View File

@ -85,6 +85,10 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
bool clouds_3d;
bool opaque_water;
bool particles;
bool mipmap;
bool bilinear;
bool trilinear;
bool anisotropic;
m_screensize = screensize;
@ -145,6 +149,34 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
else
particles = m_data->particles;
}
{
gui::IGUIElement *e = getElementFromId(GUI_ID_MIPMAP_CB);
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
mipmap = ((gui::IGUICheckBox*)e)->isChecked();
else
mipmap = m_data->mip_map;
}
{
gui::IGUIElement *e = getElementFromId(GUI_ID_BILINEAR_CB);
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
bilinear = ((gui::IGUICheckBox*)e)->isChecked();
else
bilinear = m_data->bilinear_filter;
}
{
gui::IGUIElement *e = getElementFromId(GUI_ID_TRILINEAR_CB);
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
trilinear = ((gui::IGUICheckBox*)e)->isChecked();
else
trilinear = m_data->trilinear_filter;
}
{
gui::IGUIElement *e = getElementFromId(GUI_ID_ANISOTROPIC_CB);
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
anisotropic = ((gui::IGUICheckBox*)e)->isChecked();
else
anisotropic = m_data->anisotropic_filter;
}
// Server options
{
@ -340,11 +372,35 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
Environment->addCheckBox(particles, rect, this, GUI_ID_PARTICLES_CB,
wgettext("Particles"));
}
{
core::rect<s32> rect(0, 0, 200, 30);
rect += topleft_content + v2s32(85, 210);
Environment->addCheckBox(mipmap, rect, this, GUI_ID_MIPMAP_CB,
wgettext("Mip-Mapping"));
}
{
core::rect<s32> rect(0, 0, 200, 30);
rect += topleft_content + v2s32(85, 240);
Environment->addCheckBox(bilinear, rect, this, GUI_ID_BILINEAR_CB,
wgettext("Bi-Linear Filtering"));
}
{
core::rect<s32> rect(0, 0, 200, 30);
rect += topleft_content + v2s32(85, 270);
Environment->addCheckBox(trilinear, rect, this, GUI_ID_TRILINEAR_CB,
wgettext("Tri-Linear Filtering"));
}
{
core::rect<s32> rect(0, 0, 200, 30);
rect += topleft_content + v2s32(85, 300);
Environment->addCheckBox(anisotropic, rect, this, GUI_ID_ANISOTROPIC_CB,
wgettext("Anisotropic Filtering"));
}
// Key change button
{
core::rect<s32> rect(0, 0, 130, 30);
rect += topleft_content + v2s32(90, 230);
rect += topleft_content + v2s32(90, 350);
Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON,
wgettext("Change keys"));
}
@ -508,6 +564,26 @@ void GUIMainMenu::acceptInput()
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
m_data->particles = ((gui::IGUICheckBox*)e)->isChecked();
}
{
gui::IGUIElement *e = getElementFromId(GUI_ID_MIPMAP_CB);
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
m_data->mip_map = ((gui::IGUICheckBox*)e)->isChecked();
}
{
gui::IGUIElement *e = getElementFromId(GUI_ID_BILINEAR_CB);
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
m_data->bilinear_filter = ((gui::IGUICheckBox*)e)->isChecked();
}
{
gui::IGUIElement *e = getElementFromId(GUI_ID_TRILINEAR_CB);
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
m_data->trilinear_filter = ((gui::IGUICheckBox*)e)->isChecked();
}
{
gui::IGUIElement *e = getElementFromId(GUI_ID_ANISOTROPIC_CB);
if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
m_data->anisotropic_filter = ((gui::IGUICheckBox*)e)->isChecked();
}
m_accepted = true;
}

View File

@ -36,6 +36,10 @@ enum {
GUI_ID_SMOOTH_LIGHTING_CB,
GUI_ID_3D_CLOUDS_CB,
GUI_ID_OPAQUE_WATER_CB,
GUI_ID_MIPMAP_CB,
GUI_ID_BILINEAR_CB,
GUI_ID_TRILINEAR_CB,
GUI_ID_ANISOTROPIC_CB,
GUI_ID_PARTICLES_CB,
GUI_ID_DAMAGE_CB,
GUI_ID_CREATIVE_CB,
@ -85,10 +89,10 @@ struct MainMenuData
bool smooth_lighting;
bool clouds_3d;
bool opaque_water;
//bool mip_map;
//bool anisotropic_filter;
//bool bilinear_filter;
//bool trilinear_filter;
bool mip_map;
bool anisotropic_filter;
bool bilinear_filter;
bool trilinear_filter;
//int enable_shaders;
bool particles;
// Server options

View File

@ -1560,6 +1560,11 @@ int main(int argc, char *argv[])
menudata.clouds_3d = g_settings->getBool("enable_3d_clouds");
menudata.opaque_water = g_settings->getBool("opaque_water");
menudata.particles = g_settings->getBool("enable_particles");
menudata.mip_map = g_settings->getBool("mip_map");
menudata.anisotropic_filter = g_settings->getBool("anisotropic_filter");
menudata.bilinear_filter = g_settings->getBool("bilinear_filter");
menudata.trilinear_filter = g_settings->getBool("trilinear_filter");
driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, menudata.mip_map);
menudata.creative_mode = g_settings->getBool("creative_mode");
menudata.enable_damage = g_settings->getBool("enable_damage");
@ -1634,6 +1639,10 @@ int main(int argc, char *argv[])
g_settings->set("smooth_lighting", itos(menudata.smooth_lighting));
g_settings->set("enable_3d_clouds", itos(menudata.clouds_3d));
g_settings->set("opaque_water", itos(menudata.opaque_water));
g_settings->set("mip_map", itos(menudata.mip_map));
g_settings->set("anisotropic_filter", itos(menudata.anisotropic_filter));
g_settings->set("bilinear_filter", itos(menudata.bilinear_filter));
g_settings->set("trilinear_filter", itos(menudata.trilinear_filter));
g_settings->set("enable_particles", itos(menudata.particles));
g_settings->set("creative_mode", itos(menudata.creative_mode));
g_settings->set("enable_damage", itos(menudata.enable_damage));

View File

@ -3668,6 +3668,10 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
m_last_drawn_sectors.clear();
}
bool use_trilinear_filter = g_settings->getBool("trilinear_filter");
bool use_bilinear_filter = g_settings->getBool("bilinear_filter");
bool use_anisotropic_filter = g_settings->getBool("anisotropic_filter");
/*
Get time for measuring timeout.
@ -3963,6 +3967,11 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
scene::IMeshBuffer *buf = mesh->getMeshBuffer(i);
if (buf == NULL)
continue;
buf->getMaterial().setFlag(video::EMF_TRILINEAR_FILTER, use_trilinear_filter);
buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, use_bilinear_filter);
buf->getMaterial().setFlag(video::EMF_ANISOTROPIC_FILTER, use_anisotropic_filter);
const video::SMaterial& material = buf->getMaterial();
video::IMaterialRenderer* rnd =
driver->getMaterialRenderer(material.MaterialType);