Some work with scale rtts.
IMO auto scale doesn't have much sense on desktop computers, because advanced lighting was enabled by default for a long time and graphics level 3 should be fast enough as it is. And still now rtts scale it's easily configurable in options. I fixed deactivated "render resolution" spinner when you enter graphics options when advanced lighting is disabled. I also added a function that reads dpi on android and it sets rtts scale based on this value. SDL is not initialized yet in this place, so getDisplayDPI() is not possible.
This commit is contained in:
parent
6d3ee0ce31
commit
a7a1c8abca
@ -52,12 +52,6 @@
|
||||
<div layout="vertical-row" proportion="1" height="100%">
|
||||
<label id="scale_rtts_label" height="100%" I18N="In the video settings" text="Render resolution" align="left"/>
|
||||
</div>
|
||||
<div proportion="1" layout="horizontal-row" height="fit">
|
||||
<spacer width="5%" height="100%" />
|
||||
<checkbox id="scale_rtts_custom"/>
|
||||
<spacer width="2%" height="100%" />
|
||||
<label id="scale_rtts_custom_label" height="100%" I18N="In the video settings" text="Custom"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<spacer width="5" height="1%"/>
|
||||
|
@ -674,14 +674,6 @@ namespace UserConfigParams
|
||||
PARAM_PREFIX BoolUserConfigParam m_old_driver_popup
|
||||
PARAM_DEFAULT(BoolUserConfigParam(true, "old_driver_popup",
|
||||
&m_video_group, "Determines if popup message about too old drivers should be displayed."));
|
||||
PARAM_PREFIX IntUserConfigParam m_scale_rtts_mode
|
||||
PARAM_DEFAULT(IntUserConfigParam(5, "scale_rtts_mode",
|
||||
&m_video_group, "Allows one to increase performance by setting lower RTTs "
|
||||
"resolution. 0 = Max performance, 1 = Performance, "
|
||||
"2 = Balanced, 3 = Quality, 4 = High Quality, 5 = Always Full"));
|
||||
PARAM_PREFIX BoolUserConfigParam m_scale_rtts_custom
|
||||
PARAM_DEFAULT(BoolUserConfigParam(false, "scale_rtts_custom",
|
||||
&m_video_group, "Determines if custom value for RTTs resolution is used."));
|
||||
PARAM_PREFIX FloatUserConfigParam m_scale_rtts_factor
|
||||
PARAM_DEFAULT(FloatUserConfigParam(1.0f, "scale_rtts_factor",
|
||||
&m_video_group, "Custom value for RTTs resolution. "
|
||||
|
@ -626,55 +626,6 @@ void ShaderBasedRenderer::onLoadWorld()
|
||||
unsigned int width = viewport.LowerRightCorner.X - viewport.UpperLeftCorner.X;
|
||||
unsigned int height = viewport.LowerRightCorner.Y - viewport.UpperLeftCorner.Y;
|
||||
|
||||
float ddpi = 0.f;
|
||||
float hdpi = 0.f;
|
||||
float vdpi = 0.f;
|
||||
|
||||
if (!UserConfigParams::m_scale_rtts_custom) // Calculate scale factor
|
||||
{
|
||||
if (!irr_driver->getDevice()->getDisplayDPI(&ddpi, &hdpi, &vdpi))
|
||||
{
|
||||
Log::warn("Renderer", "Failed to get display DPI, falling back to 100% render scaling.");
|
||||
UserConfigParams::m_scale_rtts_factor = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (UserConfigParams::m_scale_rtts_mode)
|
||||
{
|
||||
case 0: // Max Performance
|
||||
UserConfigParams::m_scale_rtts_factor = 72.f / ddpi;
|
||||
break;
|
||||
case 1: // Performance
|
||||
UserConfigParams::m_scale_rtts_factor = 96.f / ddpi;
|
||||
break;
|
||||
case 2: // Balanced
|
||||
UserConfigParams::m_scale_rtts_factor = 120.f / ddpi;
|
||||
break;
|
||||
case 3: // Quality
|
||||
UserConfigParams::m_scale_rtts_factor = 160.f / ddpi;
|
||||
break;
|
||||
case 4: // High Quality
|
||||
UserConfigParams::m_scale_rtts_factor = 210.f / ddpi;
|
||||
break;
|
||||
case 5: // Always Full
|
||||
UserConfigParams::m_scale_rtts_factor = 1.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
// Round to nearest 5%
|
||||
UserConfigParams::m_scale_rtts_factor = (float)((((int)(UserConfigParams::m_scale_rtts_factor*100.f)+2)/5)*5) / 100.f;
|
||||
|
||||
// Round up to 100% if at 90% or more; also make sure scale is at least 30%
|
||||
if (UserConfigParams::m_scale_rtts_factor >= 0.9f)
|
||||
UserConfigParams::m_scale_rtts_factor = 1.0f;
|
||||
if (UserConfigParams::m_scale_rtts_factor < 0.3f)
|
||||
UserConfigParams::m_scale_rtts_factor = 0.3f;
|
||||
|
||||
Log::info("Renderer", "Display DPI: %f", ddpi);
|
||||
Log::info("Renderer", "Render scale: %f", (float)UserConfigParams::m_scale_rtts_factor);
|
||||
}
|
||||
}
|
||||
|
||||
RTT* rtts = new RTT(width, height, CVS->isDeferredEnabled() ?
|
||||
UserConfigParams::m_scale_rtts_factor : 1.0f,
|
||||
!CVS->isDeferredEnabled());
|
||||
|
@ -80,12 +80,13 @@ void override_default_params_for_mobile()
|
||||
else
|
||||
g_android_main_user_agent = " (Android)";
|
||||
|
||||
// Set multitouch device scale depending on actual screen size
|
||||
// Get some info about display
|
||||
const int SCREENLAYOUT_SIZE_SMALL = 1;
|
||||
const int SCREENLAYOUT_SIZE_NORMAL = 2;
|
||||
const int SCREENLAYOUT_SIZE_LARGE = 3;
|
||||
const int SCREENLAYOUT_SIZE_XLARGE = 4;
|
||||
int32_t screen_size = 0;
|
||||
int ddpi = 0;
|
||||
JNIEnv* env = (JNIEnv*)SDL_AndroidGetJNIEnv();
|
||||
assert(env);
|
||||
jobject activity = (jobject)SDL_AndroidGetActivity();
|
||||
@ -98,11 +99,30 @@ void override_default_params_for_mobile()
|
||||
"()I");
|
||||
if (method_id != NULL)
|
||||
screen_size = env->CallIntMethod(activity, method_id);
|
||||
env->DeleteLocalRef(clazz);
|
||||
}
|
||||
env->DeleteLocalRef(activity);
|
||||
|
||||
jmethodID display_dpi_id = env->GetStaticMethodID(clazz,
|
||||
"getDisplayDPI", "()Landroid/util/DisplayMetrics;");
|
||||
|
||||
if (display_dpi_id != NULL)
|
||||
{
|
||||
jobject display_dpi_obj = env->CallStaticObjectMethod(clazz,
|
||||
display_dpi_id);
|
||||
jclass display_dpi_class = env->GetObjectClass(display_dpi_obj);
|
||||
|
||||
jfieldID ddpi_field = env->GetFieldID(display_dpi_class,
|
||||
"densityDpi", "I");
|
||||
ddpi = env->GetIntField(display_dpi_obj, ddpi_field);
|
||||
|
||||
env->DeleteLocalRef(display_dpi_obj);
|
||||
env->DeleteLocalRef(display_dpi_class);
|
||||
}
|
||||
|
||||
env->DeleteLocalRef(activity);
|
||||
env->DeleteLocalRef(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
// Set multitouch device scale depending on actual screen size
|
||||
switch (screen_size)
|
||||
{
|
||||
case SCREENLAYOUT_SIZE_SMALL:
|
||||
@ -124,6 +144,30 @@ void override_default_params_for_mobile()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Update rtts scale based on display DPI
|
||||
if (ddpi < 1)
|
||||
{
|
||||
Log::warn("MainAndroid", "Failed to get display DPI.");
|
||||
UserConfigParams::m_scale_rtts_factor = 0.7f;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ddpi > 400)
|
||||
UserConfigParams::m_scale_rtts_factor = 0.6f;
|
||||
else if (ddpi > 300)
|
||||
UserConfigParams::m_scale_rtts_factor = 0.65f;
|
||||
else if (ddpi > 200)
|
||||
UserConfigParams::m_scale_rtts_factor = 0.7f;
|
||||
else if (ddpi > 150)
|
||||
UserConfigParams::m_scale_rtts_factor = 0.75f;
|
||||
else
|
||||
UserConfigParams::m_scale_rtts_factor = 0.8f;
|
||||
|
||||
Log::info("MainAndroid", "Display DPI: %i", ddpi);
|
||||
Log::info("MainAndroid", "Render scale: %f",
|
||||
(float)UserConfigParams::m_scale_rtts_factor);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Enable screen keyboard
|
||||
|
@ -278,10 +278,6 @@ void OptionsScreenVideo::init()
|
||||
scale_rtts->addLabel(_("95%%"));
|
||||
scale_rtts->addLabel(_("100%%"));
|
||||
|
||||
CheckBoxWidget* scale_rtts_custom = getWidget<CheckBoxWidget>("scale_rtts_custom");
|
||||
assert( scale_rtts_custom != NULL );
|
||||
scale_rtts_custom->setState( UserConfigParams::m_scale_rtts_custom );
|
||||
|
||||
// ---- video modes
|
||||
DynamicRibbonWidget* res = getWidget<DynamicRibbonWidget>("resolutions");
|
||||
assert(res != NULL);
|
||||
@ -448,8 +444,8 @@ void OptionsScreenVideo::init()
|
||||
applyBtn->setActive(!in_game);
|
||||
gfx->setActive(!in_game);
|
||||
getWidget<ButtonWidget>("custom")->setActive(!in_game);
|
||||
if (getWidget<SpinnerWidget>("scale_rtts")->isActivated())
|
||||
getWidget<SpinnerWidget>("scale_rtts")->setActive(!in_game);
|
||||
getWidget<CheckBoxWidget>("scale_rtts_custom")->setActive(!in_game);
|
||||
|
||||
#if defined(MOBILE_STK)
|
||||
applyBtn->setVisible(false);
|
||||
@ -539,8 +535,6 @@ void OptionsScreenVideo::updateGfxSlider()
|
||||
// Same with Render resolution slider
|
||||
getWidget<GUIEngine::SpinnerWidget>("scale_rtts")->
|
||||
setActive(UserConfigParams::m_dynamic_lights);
|
||||
getWidget<GUIEngine::CheckBoxWidget>("scale_rtts_custom")->
|
||||
setActive(UserConfigParams::m_dynamic_lights);
|
||||
|
||||
updateTooltip();
|
||||
} // updateGfxSlider
|
||||
@ -581,25 +575,6 @@ void OptionsScreenVideo::updateScaleRTTsSlider()
|
||||
getWidget<GUIEngine::SpinnerWidget>("scale_rtts");
|
||||
assert( scale_rtts_level != NULL );
|
||||
|
||||
if (UserConfigParams::m_scale_rtts_custom)
|
||||
{
|
||||
scale_rtts_level->clearLabels();
|
||||
scale_rtts_level->addLabel(_("30%%"));
|
||||
scale_rtts_level->addLabel(_("35%%"));
|
||||
scale_rtts_level->addLabel(_("40%%"));
|
||||
scale_rtts_level->addLabel(_("45%%"));
|
||||
scale_rtts_level->addLabel(_("50%%"));
|
||||
scale_rtts_level->addLabel(_("55%%"));
|
||||
scale_rtts_level->addLabel(_("60%%"));
|
||||
scale_rtts_level->addLabel(_("65%%"));
|
||||
scale_rtts_level->addLabel(_("70%%"));
|
||||
scale_rtts_level->addLabel(_("75%%"));
|
||||
scale_rtts_level->addLabel(_("80%%"));
|
||||
scale_rtts_level->addLabel(_("85%%"));
|
||||
scale_rtts_level->addLabel(_("90%%"));
|
||||
scale_rtts_level->addLabel(_("95%%"));
|
||||
scale_rtts_level->addLabel(_("100%%"));
|
||||
|
||||
bool found = false;
|
||||
for (unsigned int l = 0; l < m_scale_rtts_custom_presets.size(); l++)
|
||||
{
|
||||
@ -616,19 +591,6 @@ void OptionsScreenVideo::updateScaleRTTsSlider()
|
||||
//I18N: custom video settings
|
||||
scale_rtts_level->setCustomText( _("Custom") );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
scale_rtts_level->clearLabels();
|
||||
scale_rtts_level->addLabel(_("Max Performance"));
|
||||
scale_rtts_level->addLabel(_("Performance"));
|
||||
scale_rtts_level->addLabel(_("Balanced"));
|
||||
scale_rtts_level->addLabel(_("Quality"));
|
||||
scale_rtts_level->addLabel(_("High Quality"));
|
||||
scale_rtts_level->addLabel(_("Always Full"));
|
||||
|
||||
scale_rtts_level->setValue(UserConfigParams::m_scale_rtts_mode);
|
||||
}
|
||||
} // updateScaleRTTsSlider
|
||||
|
||||
// --------------------------------------------------------------------------------------------
|
||||
@ -809,8 +771,6 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
||||
// Same with Render resolution slider
|
||||
getWidget<GUIEngine::SpinnerWidget>("scale_rtts")->
|
||||
setActive(UserConfigParams::m_dynamic_lights);
|
||||
getWidget<GUIEngine::CheckBoxWidget>("scale_rtts_custom")->
|
||||
setActive(UserConfigParams::m_dynamic_lights);
|
||||
|
||||
UserConfigParams::m_animated_characters = m_presets[level].animatedCharacters;
|
||||
UserConfigParams::m_particles_effects = m_presets[level].particles;
|
||||
@ -859,21 +819,9 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
|
||||
assert( scale_rtts_level != NULL );
|
||||
|
||||
const int level = scale_rtts_level->getValue();
|
||||
assert(level < (int)m_scale_rtts_custom_presets.size());
|
||||
|
||||
if (UserConfigParams::m_scale_rtts_custom)
|
||||
UserConfigParams::m_scale_rtts_factor = m_scale_rtts_custom_presets[level].value;
|
||||
else
|
||||
UserConfigParams::m_scale_rtts_mode = level;
|
||||
|
||||
updateScaleRTTsSlider();
|
||||
}
|
||||
else if (name == "scale_rtts_custom")
|
||||
{
|
||||
GUIEngine::CheckBoxWidget* scale_rtts_custom =
|
||||
getWidget<GUIEngine::CheckBoxWidget>("scale_rtts_custom");
|
||||
assert( scale_rtts_custom != NULL );
|
||||
|
||||
UserConfigParams::m_scale_rtts_custom = scale_rtts_custom->getState();
|
||||
|
||||
updateScaleRTTsSlider();
|
||||
}
|
||||
|
@ -53,11 +53,6 @@ struct ScaleRttsCustomPreset
|
||||
float value;
|
||||
};
|
||||
|
||||
struct ScaleRttsAutoPreset
|
||||
{
|
||||
int preset;
|
||||
};
|
||||
|
||||
struct Resolution
|
||||
{
|
||||
int width;
|
||||
@ -101,7 +96,6 @@ private:
|
||||
std::vector<GFXPreset> m_presets;
|
||||
std::vector<BlurPreset> m_blur_presets;
|
||||
std::vector<ScaleRttsCustomPreset> m_scale_rtts_custom_presets;
|
||||
std::vector<ScaleRttsAutoPreset> m_scale_rtts_auto_presets;
|
||||
std::vector<Resolution> m_resolutions;
|
||||
|
||||
void updateTooltip();
|
||||
|
Loading…
Reference in New Issue
Block a user