mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:23:53 +00:00
shader mode button in settingswindow
This commit is contained in:
parent
865bfc6f47
commit
485adc8bdc
6 changed files with 178 additions and 1 deletions
|
@ -74,6 +74,14 @@ namespace
|
|||
return "16 : 10";
|
||||
return boost::lexical_cast<std::string>(xaspect) + " : " + boost::lexical_cast<std::string>(yaspect);
|
||||
}
|
||||
|
||||
std::string hlslGlsl ()
|
||||
{
|
||||
if (Ogre::Root::getSingleton ().getRenderSystem ()->getName ().find("OpenGL") == std::string::npos)
|
||||
return "hlsl";
|
||||
else
|
||||
return "glsl";
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWGui
|
||||
|
@ -103,8 +111,10 @@ namespace MWGui
|
|||
getWidget(mReflectObjectsButton, "ReflectObjectsButton");
|
||||
getWidget(mReflectActorsButton, "ReflectActorsButton");
|
||||
getWidget(mReflectTerrainButton, "ReflectTerrainButton");
|
||||
getWidget(mShadersButton, "ShadersButton");
|
||||
|
||||
mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onOkButtonClicked);
|
||||
mShadersButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onShadersToggled);
|
||||
mFullscreenButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mWaterShaderButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
mReflectObjectsButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SettingsWindow::onButtonToggled);
|
||||
|
@ -189,6 +199,15 @@ namespace MWGui
|
|||
mReflectActorsButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect actors", "Water") ? "#{sOn}" : "#{sOff}");
|
||||
mReflectTerrainButton->setCaptionWithReplacing(Settings::Manager::getBool("reflect terrain", "Water") ? "#{sOn}" : "#{sOff}");
|
||||
|
||||
std::string shaders;
|
||||
if (!Settings::Manager::getBool("shaders", "Objects"))
|
||||
shaders = "off";
|
||||
else
|
||||
{
|
||||
shaders = Settings::Manager::getString("shader mode", "General");
|
||||
}
|
||||
mShadersButton->setCaption (shaders);
|
||||
|
||||
if (!MWRender::RenderingManager::waterShaderSupported())
|
||||
{
|
||||
mWaterShaderButton->setEnabled(false);
|
||||
|
@ -280,6 +299,10 @@ namespace MWGui
|
|||
Settings::Manager::setBool("fullscreen", "Video", newState);
|
||||
apply();
|
||||
}
|
||||
}
|
||||
else if (_sender == mShadersButton)
|
||||
{
|
||||
|
||||
}
|
||||
else if (_sender == mVSyncButton)
|
||||
{
|
||||
|
@ -306,6 +329,45 @@ namespace MWGui
|
|||
}
|
||||
}
|
||||
|
||||
void SettingsWindow::onShadersToggled(MyGUI::Widget* _sender)
|
||||
{
|
||||
std::string val = static_cast<MyGUI::Button*>(_sender)->getCaption();
|
||||
if (val == "off")
|
||||
val = hlslGlsl();
|
||||
else if (val == hlslGlsl())
|
||||
val = "cg";
|
||||
else
|
||||
val = "off";
|
||||
|
||||
static_cast<MyGUI::Button*>(_sender)->setCaption(val);
|
||||
|
||||
if (val == "off")
|
||||
{
|
||||
Settings::Manager::setBool("shaders", "Objects", false);
|
||||
|
||||
// water shader not supported with object shaders off
|
||||
mWaterShaderButton->setCaptionWithReplacing("#{sOff}");
|
||||
mWaterShaderButton->setEnabled(false);
|
||||
mReflectObjectsButton->setEnabled(false);
|
||||
mReflectActorsButton->setEnabled(false);
|
||||
mReflectTerrainButton->setEnabled(false);
|
||||
Settings::Manager::setBool("shader", "Water", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// re-enable
|
||||
mWaterShaderButton->setEnabled(true);
|
||||
mReflectObjectsButton->setEnabled(true);
|
||||
mReflectActorsButton->setEnabled(true);
|
||||
mReflectTerrainButton->setEnabled(true);
|
||||
|
||||
Settings::Manager::setBool("shaders", "Objects", true);
|
||||
Settings::Manager::setString("shader mode", "General", val);
|
||||
}
|
||||
|
||||
apply();
|
||||
}
|
||||
|
||||
void SettingsWindow::onFpsToggled(MyGUI::Widget* _sender)
|
||||
{
|
||||
int newLevel = (Settings::Manager::getInt("fps", "HUD") + 1) % 3;
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace MWGui
|
|||
MyGUI::Button* mReflectObjectsButton;
|
||||
MyGUI::Button* mReflectActorsButton;
|
||||
MyGUI::Button* mReflectTerrainButton;
|
||||
MyGUI::Button* mShadersButton;
|
||||
|
||||
// audio
|
||||
MyGUI::ScrollBar* mMasterVolumeSlider;
|
||||
|
@ -59,6 +60,8 @@ namespace MWGui
|
|||
void onResolutionAccept();
|
||||
void onResolutionCancel();
|
||||
|
||||
void onShadersToggled(MyGUI::Widget* _sender);
|
||||
|
||||
void apply();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -42,6 +42,15 @@ namespace MWRender {
|
|||
RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const boost::filesystem::path& resDir, OEngine::Physic::PhysicEngine* engine)
|
||||
:mRendering(_rend), mObjects(mRendering), mActors(mRendering), mAmbientMode(0), mSunEnabled(0)
|
||||
{
|
||||
// select best shader mode
|
||||
if (Settings::Manager::getString("shader mode", "General") == "")
|
||||
{
|
||||
if (Ogre::Root::getSingleton ().getRenderSystem ()->getName().find("OpenGL") == std::string::npos)
|
||||
Settings::Manager::setString("shader mode", "General", "hlsl");
|
||||
else
|
||||
Settings::Manager::setString("shader mode", "General", "glsl");
|
||||
}
|
||||
|
||||
mRendering.createScene("PlayerCam", Settings::Manager::getFloat("field of view", "General"), 5);
|
||||
mRendering.setWindowEventListener(this);
|
||||
|
||||
|
@ -619,6 +628,24 @@ void RenderingManager::processChangedSettings(const Settings::CategorySettingVec
|
|||
sh::Factory::getInstance ().setGlobalSetting ("mrt_output", useMRT() ? "true" : "false");
|
||||
mObjects.rebuildStaticGeometry ();
|
||||
}
|
||||
else if (it->second == "shaders" && it->first == "Objects")
|
||||
{
|
||||
sh::Factory::getInstance ().setShadersEnabled (Settings::Manager::getBool("shaders", "Objects"));
|
||||
mObjects.rebuildStaticGeometry ();
|
||||
}
|
||||
else if (it->second == "shader mode" && it->first == "General")
|
||||
{
|
||||
sh::Language lang;
|
||||
std::string l = Settings::Manager::getString("shader mode", "General");
|
||||
if (l == "glsl")
|
||||
lang = sh::Language_GLSL;
|
||||
else if (l == "hlsl")
|
||||
lang = sh::Language_HLSL;
|
||||
else
|
||||
lang = sh::Language_CG;
|
||||
sh::Factory::getInstance ().setCurrentLanguage (lang);
|
||||
mObjects.rebuildStaticGeometry ();
|
||||
}
|
||||
}
|
||||
|
||||
if (changeRes)
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<MyGUI type="Layout">
|
||||
<Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 390 390" name="_Main">
|
||||
<Widget type="Window" skin="MW_Window_NoCaption" layer="Windows" position="0 0 400 414" name="_Main">
|
||||
|
||||
<Property key="MinSize" value="400 414"/>
|
||||
<Property key="MaxSize" value="400 414"/>
|
||||
|
||||
<Widget type="TabControl" skin="TabControl" position="8 8 368 340" align="Left Top" name="SettingsTab">
|
||||
<Property key="ButtonAutoWidth" value="true"/>
|
||||
|
@ -100,6 +103,12 @@
|
|||
</Widget>
|
||||
<Widget type="Button" skin="MW_Button" position="212 34 34 24" align="Left Top" name="VSyncButton"/>
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="262 104 120 24" align="Left Top">
|
||||
<Property key="Caption" value="Shaders"/>
|
||||
</Widget>
|
||||
<Widget type="Button" skin="MW_Button" position="212 104 44 24" align="Left Top" name="ShadersButton"/>
|
||||
|
||||
|
||||
<Widget type="TextBox" skin="SandText" position="74 163 250 24" align="Left Top">
|
||||
<Property key="Caption" value="Show frames per second"/>
|
||||
</Widget>
|
||||
|
|
|
@ -322,6 +322,80 @@
|
|||
</Child>
|
||||
</Skin>
|
||||
|
||||
<Skin name = "MW_Window_NoCaption" size = "256 54">
|
||||
<Property key="FontName" value = "Default" />
|
||||
<Property key="TextAlign" value = "ALIGN_CENTER" />
|
||||
<Property key="TextColour" value = "0.8 0.8 0.8" />
|
||||
<Property key="Snap" value = "true" />
|
||||
<Property key="MinSize" value="64 64"/>
|
||||
|
||||
<Child type="Widget" skin="BlackBG" offset = "8 28 240 18" align = "ALIGN_STRETCH" name = "Client"/>
|
||||
|
||||
<!-- Outer borders -->
|
||||
<Child type="Widget" skin="TB_T" offset="4 0 248 4" align="ALIGN_TOP ALIGN_HSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "0 1 0 -1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_L" offset="0 4 4 46" align="ALIGN_LEFT ALIGN_VSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "1 0 -1 0"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_B" offset="4 50 248 4" align="ALIGN_BOTTOM ALIGN_HSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "0 0 0 1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_R" offset="252 4 4 46" align="ALIGN_RIGHT ALIGN_VSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "0 0 1 0"/>
|
||||
</Child>
|
||||
|
||||
<Child type="Widget" skin="TB_BR" offset="252 50 4 4" align="ALIGN_RIGHT ALIGN_BOTTOM" name="Action">
|
||||
<Property key="Scale" value = "0 0 1 1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_BL" offset="0 50 4 4" align="ALIGN_LEFT ALIGN_BOTTOM" name="Action">
|
||||
<Property key="Scale" value = "1 0 -1 1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_TR" offset="252 0 4 4" align="ALIGN_RIGHT ALIGN_TOP" name="Action">
|
||||
<Property key="Scale" value = "0 1 1 -1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_TL" offset="0 0 4 4" align="ALIGN_LEFT ALIGN_TOP" name="Action">
|
||||
<Property key="Scale" value = "1 1 -1 -1"/>
|
||||
</Child>
|
||||
|
||||
<!-- Inner borders -->
|
||||
<Child type="Widget" skin="TB_T" offset="8 24 240 4" align="ALIGN_TOP ALIGN_HSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "0 1 0 -1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_L" offset="4 28 4 18" align="ALIGN_LEFT ALIGN_VSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "1 0 -1 0"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_B" offset="8 46 240 4" align="ALIGN_BOTTOM ALIGN_HSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "0 0 0 1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_R" offset="248 28 4 18" align="ALIGN_RIGHT ALIGN_VSTRETCH" name="Action">
|
||||
<Property key="Scale" value = "0 0 1 0"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_BR" offset="248 46 4 4" align="ALIGN_BOTTOM ALIGN_RIGHT" name="Action">
|
||||
<Property key="Scale" value = "0 0 1 1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_BL" offset="4 46 4 4" align="ALIGN_BOTTOM ALIGN_LEFT" name="Action">
|
||||
<Property key="Scale" value = "1 0 -1 1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_TR" offset="248 24 4 4" align="ALIGN_TOP ALIGN_RIGHT" name="Action">
|
||||
<Property key="Scale" value = "0 1 1 -1"/>
|
||||
</Child>
|
||||
<Child type="Widget" skin="TB_TL" offset="4 24 4 4" align="ALIGN_TOP ALIGN_LEFT" name="Action">
|
||||
<Property key="Scale" value = "1 1 -1 -1"/>
|
||||
</Child>
|
||||
|
||||
<!-- Caption -->
|
||||
<Child type="Widget" skin="HB_ALL" offset="4 4 248 20" align = "ALIGN_TOP ALIGN_HSTRETCH">
|
||||
<Property key="Scale" value = "1 1 0 0"/>
|
||||
</Child>
|
||||
|
||||
<!-- This invisible button makes it possible to move the
|
||||
window by dragging the caption. -->
|
||||
<Child type="Button" offset="4 4 248 20" align="ALIGN_HSTRETCH ALIGN_TOP" name="Action">
|
||||
<Property key="Scale" value = "1 1 0 0"/>
|
||||
</Child>
|
||||
</Skin>
|
||||
|
||||
<Skin name = "MW_Window_Pinnable" size = "256 54">
|
||||
<Property key="FontName" value = "Default" />
|
||||
<Property key="TextAlign" value = "ALIGN_CENTER" />
|
||||
|
|
|
@ -48,6 +48,8 @@ anisotropy = 4
|
|||
# Number of texture mipmaps to generate
|
||||
num mipmaps = 5
|
||||
|
||||
shader mode =
|
||||
|
||||
[Shadows]
|
||||
# Shadows are only supported when object shaders are on!
|
||||
enabled = false
|
||||
|
|
Loading…
Reference in a new issue