From e2ebcb769e6dffac4261d89a64d3db6531f929f7 Mon Sep 17 00:00:00 2001 From: krzys-h Date: Mon, 20 Jul 2015 16:29:09 +0200 Subject: [PATCH] Added MSAA to settings screen --- po/colobot.pot | 12 ++++++++++ po/de.po | 12 ++++++++++ po/fr.po | 12 ++++++++++ po/pl.po | 12 ++++++++++ po/ru.po | 12 ++++++++++ src/common/event.cpp | 8 +++++++ src/common/event.h | 2 +- src/common/restext.cpp | 1 + src/graphics/core/device.h | 3 +++ src/graphics/core/nulldevice.cpp | 5 +++++ src/graphics/core/nulldevice.h | 2 ++ src/graphics/engine/engine.cpp | 5 +++++ src/graphics/opengl/gl21device.cpp | 17 ++++++++++++++ src/graphics/opengl/gl21device.h | 4 ++++ src/graphics/opengl/gl33device.cpp | 17 ++++++++++++++ src/graphics/opengl/gl33device.h | 4 ++++ src/graphics/opengl/gldevice.cpp | 17 ++++++++++++++ src/graphics/opengl/gldevice.h | 4 ++++ src/ui/maindialog.cpp | 36 ++++++++++++++++++++++++++++-- 19 files changed, 182 insertions(+), 3 deletions(-) diff --git a/po/colobot.pot b/po/colobot.pot index d6e5e651..5b5d7694 100644 --- a/po/colobot.pot +++ b/po/colobot.pot @@ -420,6 +420,18 @@ msgstr "" msgid "Autosave slots\\How many autosave slots you'll have" msgstr "" +msgid "Texture filtering\\Texture filtering" +msgstr "" + +msgid "Mipmap level\\Mipmap level" +msgstr "" + +msgid "Anisotropy level\\Anisotropy level" +msgstr "" + +msgid "MSAA\\Multisample anti-aliasing" +msgstr "" + msgid "Standard controls\\Standard key functions" msgstr "" diff --git a/po/de.po b/po/de.po index 37f367fc..cbeea6b2 100644 --- a/po/de.po +++ b/po/de.po @@ -133,6 +133,9 @@ msgstr "Analyse vollendet" msgid "Analyzes only organic matter" msgstr "Analysiert nur Orgastoff" +msgid "Anisotropy level\\Anisotropy level" +msgstr "" + msgid "Ant" msgstr "Ameise" @@ -831,6 +834,9 @@ msgstr "Min.\\Minimale Qualität (großes Framerate)" msgid "Lunar Roving Vehicle" msgstr "Lunar Roving Vehicle" +msgid "MSAA\\Multisample anti-aliasing" +msgstr "" + msgid "Marks on the ground\\Marks on the ground" msgstr "Markierungen\\Markierungen auf dem Boden" @@ -840,6 +846,9 @@ msgstr "Großes Fenster" msgid "Minimize" msgstr "Reduzieren" +msgid "Mipmap level\\Mipmap level" +msgstr "" + msgid "Mission name" msgstr "Name der Mission" @@ -1464,6 +1473,9 @@ msgstr "Zielscheibe" msgid "Target bot" msgstr "Mobile Zielscheibe" +msgid "Texture filtering\\Texture filtering" +msgstr "" + msgid "The expression must return a boolean value" msgstr "Der Ausdruck muss einen boolschen Wert ergeben" diff --git a/po/fr.po b/po/fr.po index 9395fd41..3fd45455 100644 --- a/po/fr.po +++ b/po/fr.po @@ -128,6 +128,9 @@ msgstr "Analyse terminée" msgid "Analyzes only organic matter" msgstr "N'analyse que la matière organique" +msgid "Anisotropy level\\Anisotropy level" +msgstr "" + msgid "Ant" msgstr "Fourmi" @@ -825,6 +828,9 @@ msgstr "Mini\\Qualité minimale (+ rapide)" msgid "Lunar Roving Vehicle" msgstr "Lunar Roving Vehicle" +msgid "MSAA\\Multisample anti-aliasing" +msgstr "" + msgid "Marks on the ground\\Marks on the ground" msgstr "Marques sur le sol\\Marques dessinées sur le sol" @@ -834,6 +840,9 @@ msgstr "Taille maximale" msgid "Minimize" msgstr "Taille réduite" +msgid "Mipmap level\\Mipmap level" +msgstr "" + msgid "Mission name" msgstr "Nom de la mission" @@ -1460,6 +1469,9 @@ msgstr "Cible" msgid "Target bot" msgstr "Cible d'entraînement" +msgid "Texture filtering\\Texture filtering" +msgstr "" + msgid "The expression must return a boolean value" msgstr "L'expression doit ętre un boolean" diff --git a/po/pl.po b/po/pl.po index 7a05d16a..cc79743c 100644 --- a/po/pl.po +++ b/po/pl.po @@ -133,6 +133,9 @@ msgstr "Analiza wykonana" msgid "Analyzes only organic matter" msgstr "Analizuje jedynie materię organiczną" +msgid "Anisotropy level\\Anisotropy level" +msgstr "" + msgid "Ant" msgstr "Mrówka" @@ -833,6 +836,9 @@ msgstr "" msgid "Lunar Roving Vehicle" msgstr "Pojazd Księżycowy" +msgid "MSAA\\Multisample anti-aliasing" +msgstr "" + msgid "Marks on the ground\\Marks on the ground" msgstr "Znaki na ziemi\\Znaki na ziemi" @@ -842,6 +848,9 @@ msgstr "Powiększ" msgid "Minimize" msgstr "Pomniejsz" +msgid "Mipmap level\\Mipmap level" +msgstr "" + msgid "Mission name" msgstr "Nazwa misji" @@ -1461,6 +1470,9 @@ msgstr "Cel" msgid "Target bot" msgstr "Robot cel" +msgid "Texture filtering\\Texture filtering" +msgstr "" + msgid "The expression must return a boolean value" msgstr "Wyrażenie musi zwrócić wartość logiczną" diff --git a/po/ru.po b/po/ru.po index c17b1e36..1dc3cc44 100644 --- a/po/ru.po +++ b/po/ru.po @@ -128,6 +128,9 @@ msgstr "Анализ выполнен" msgid "Analyzes only organic matter" msgstr "Анализирую только органические вещества" +msgid "Anisotropy level\\Anisotropy level" +msgstr "" + msgid "Ant" msgstr "Муравей" @@ -824,6 +827,9 @@ msgstr "Низкое\\Минимальное качество графики (б msgid "Lunar Roving Vehicle" msgstr "Луноход" +msgid "MSAA\\Multisample anti-aliasing" +msgstr "" + msgid "Marks on the ground\\Marks on the ground" msgstr "Метки на земле\\Метки на земле" @@ -833,6 +839,9 @@ msgstr "Развернуть" msgid "Minimize" msgstr "Свернуть" +msgid "Mipmap level\\Mipmap level" +msgstr "" + msgid "Mission name" msgstr "Название миссии" @@ -1456,6 +1465,9 @@ msgstr "Цель" msgid "Target bot" msgstr "Целевой бот" +msgid "Texture filtering\\Texture filtering" +msgstr "" + msgid "The expression must return a boolean value" msgstr "Выражение должно возвращать логическое значение" diff --git a/src/common/event.cpp b/src/common/event.cpp index a64d2e94..c90d5d6d 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -218,6 +218,14 @@ void InitializeEventTypeTexts() EVENT_TYPE_TEXT[EVENT_INTERFACE_EDITMODE]= "EVENT_INTERFACE_EDITMODE"; EVENT_TYPE_TEXT[EVENT_INTERFACE_EDITVALUE]= "EVENT_INTERFACE_EDITVALUE"; EVENT_TYPE_TEXT[EVENT_INTERFACE_SOLUCE4] = "EVENT_INTERFACE_SOLUCE4"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_BLOOD] = "EVENT_INTERFACE_BLOOD"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_AUTOSAVE_ENABLE] = "EVENT_INTERFACE_AUTOSAVE_ENABLE"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_AUTOSAVE_INTERVAL] = "EVENT_INTERFACE_AUTOSAVE_INTERVAL"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_AUTOSAVE_SLOTS] = "EVENT_INTERFACE_AUTOSAVE_SLOTS"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_TEXTURE_FILTER] = "EVENT_INTERFACE_TEXTURE_FILTER"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_TEXTURE_MIPMAP] = "EVENT_INTERFACE_TEXTURE_MIPMAP"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_TEXTURE_ANISOTROPY] = "EVENT_INTERFACE_TEXTURE_ANISOTROPY"; + EVENT_TYPE_TEXT[EVENT_INTERFACE_MSAA] = "EVENT_INTERFACE_MSAA"; EVENT_TYPE_TEXT[EVENT_INTERFACE_KINFO1] = "EVENT_INTERFACE_KINFO1"; EVENT_TYPE_TEXT[EVENT_INTERFACE_KINFO2] = "EVENT_INTERFACE_KINFO2"; diff --git a/src/common/event.h b/src/common/event.h index b5533ba0..4e558450 100644 --- a/src/common/event.h +++ b/src/common/event.h @@ -243,10 +243,10 @@ enum EventType EVENT_INTERFACE_AUTOSAVE_ENABLE = 780, EVENT_INTERFACE_AUTOSAVE_INTERVAL = 781, EVENT_INTERFACE_AUTOSAVE_SLOTS = 782, - // new EVENT_INTERFACE_TEXTURE_FILTER = 783, EVENT_INTERFACE_TEXTURE_MIPMAP = 784, EVENT_INTERFACE_TEXTURE_ANISOTROPY = 785, + EVENT_INTERFACE_MSAA = 786, EVENT_INTERFACE_KINFO1 = 500, EVENT_INTERFACE_KINFO2 = 501, diff --git a/src/common/restext.cpp b/src/common/restext.cpp index 7a3ed74d..ab3c4860 100644 --- a/src/common/restext.cpp +++ b/src/common/restext.cpp @@ -216,6 +216,7 @@ void InitializeRestext() stringsEvent[EVENT_INTERFACE_TEXTURE_FILTER] = TR("Texture filtering\\Texture filtering"); stringsEvent[EVENT_INTERFACE_TEXTURE_MIPMAP] = TR("Mipmap level\\Mipmap level"); stringsEvent[EVENT_INTERFACE_TEXTURE_ANISOTROPY]= TR("Anisotropy level\\Anisotropy level"); + stringsEvent[EVENT_INTERFACE_MSAA] = TR("MSAA\\Multisample anti-aliasing"); stringsEvent[EVENT_INTERFACE_KDEF] = TR("Standard controls\\Standard key functions"); assert(INPUT_SLOT_MAX < EVENT_INTERFACE_KEY_END-EVENT_INTERFACE_KEY); diff --git a/src/graphics/core/device.h b/src/graphics/core/device.h index cad9efca..d5600038 100644 --- a/src/graphics/core/device.h +++ b/src/graphics/core/device.h @@ -441,6 +441,9 @@ public: //! Returns max anisotropy level supported virtual int GetMaxAnisotropyLevel() = 0; + + //! Returns max samples supported + virtual int GetMaxSamples() = 0; }; diff --git a/src/graphics/core/nulldevice.cpp b/src/graphics/core/nulldevice.cpp index 0db938cd..62171765 100644 --- a/src/graphics/core/nulldevice.cpp +++ b/src/graphics/core/nulldevice.cpp @@ -392,4 +392,9 @@ int CNullDevice::GetMaxAnisotropyLevel() return 1; } +int CNullDevice::GetMaxSamples() +{ + return 1; +} + } // namespace Gfx diff --git a/src/graphics/core/nulldevice.h b/src/graphics/core/nulldevice.h index af4210ac..61f6b145 100644 --- a/src/graphics/core/nulldevice.h +++ b/src/graphics/core/nulldevice.h @@ -155,6 +155,8 @@ public: virtual bool IsAnisotropySupported(); virtual int GetMaxAnisotropyLevel(); + virtual int GetMaxSamples(); + private: Math::Matrix m_matrix; Material m_material; diff --git a/src/graphics/engine/engine.cpp b/src/graphics/engine/engine.cpp index a7d56993..9a53dc9f 100644 --- a/src/graphics/engine/engine.cpp +++ b/src/graphics/engine/engine.cpp @@ -2584,7 +2584,12 @@ float CEngine::GetShadowRange() void CEngine::SetMultiSample(int value) { + bool changed = m_multisample != value; m_multisample = value; + if(changed) + { + m_device->DeleteFramebuffer("multisample"); + } } int CEngine::GetMultiSample() diff --git a/src/graphics/opengl/gl21device.cpp b/src/graphics/opengl/gl21device.cpp index 344c4ad6..eb576c77 100644 --- a/src/graphics/opengl/gl21device.cpp +++ b/src/graphics/opengl/gl21device.cpp @@ -46,6 +46,7 @@ CGL21Device::CGL21Device(const DeviceConfig &config) m_lastVboId = 0; m_anisotropyAvailable = false; m_maxAnisotropy = 1; + m_maxSamples = 1; m_glMajor = 1; m_glMinor = 1; @@ -211,6 +212,17 @@ bool CGL21Device::Create() { GetLogger()->Info("Anisotropic filtering not available\n"); } + + // Read maximum sample count for MSAA + if(glewIsSupported("GL_ARB_multisample")) + { + glGetIntegerv(GL_MAX_SAMPLES_EXT, &m_maxSamples); + GetLogger()->Info("Multisampling supported, max samples: %d\n", m_maxSamples); + } + else + { + GetLogger()->Info("Multisampling not supported\n"); + } } // This is mostly done in all modern hardware by default @@ -1771,4 +1783,9 @@ int CGL21Device::GetMaxAnisotropyLevel() return m_maxAnisotropy; } +int CGL21Device::GetMaxSamples() +{ + return m_maxSamples; +} + } // namespace Gfx diff --git a/src/graphics/opengl/gl21device.h b/src/graphics/opengl/gl21device.h index 5b517a4b..dd566f9e 100644 --- a/src/graphics/opengl/gl21device.h +++ b/src/graphics/opengl/gl21device.h @@ -150,6 +150,8 @@ public: virtual bool IsAnisotropySupported() override; virtual int GetMaxAnisotropyLevel() override; + virtual int GetMaxSamples() override; + private: //! Updates position for given light based on transformation matrices void UpdateLightPosition(int index); @@ -221,6 +223,8 @@ private: bool m_anisotropyAvailable; //! Maximum anisotropy level int m_maxAnisotropy; + //! Maximum samples + int m_maxSamples; //! Framebuffer support FramebufferSupport m_framebufferSupport; //! Map of saved VBO objects diff --git a/src/graphics/opengl/gl33device.cpp b/src/graphics/opengl/gl33device.cpp index c1271692..87161846 100644 --- a/src/graphics/opengl/gl33device.cpp +++ b/src/graphics/opengl/gl33device.cpp @@ -45,6 +45,7 @@ CGL33Device::CGL33Device(const DeviceConfig &config) m_lastVboId = 0; m_anisotropyAvailable = false; m_maxAnisotropy = 1; + m_maxSamples = 1; m_glMajor = 1; m_glMinor = 1; @@ -217,6 +218,17 @@ bool CGL33Device::Create() { GetLogger()->Info("Anisotropic filtering not available\n"); } + + // Read maximum sample count for MSAA + if(glewIsSupported("GL_ARB_multisample")) + { + glGetIntegerv(GL_MAX_SAMPLES_EXT, &m_maxSamples); + GetLogger()->Info("Multisampling supported, max samples: %d\n", m_maxSamples); + } + else + { + GetLogger()->Info("Multisampling not supported\n"); + } } // Set just to be sure @@ -1964,4 +1976,9 @@ int CGL33Device::GetMaxAnisotropyLevel() return m_maxAnisotropy; } +int CGL33Device::GetMaxSamples() +{ + return m_maxSamples; +} + } // namespace Gfx diff --git a/src/graphics/opengl/gl33device.h b/src/graphics/opengl/gl33device.h index 5cd62d36..8ef593fb 100644 --- a/src/graphics/opengl/gl33device.h +++ b/src/graphics/opengl/gl33device.h @@ -149,6 +149,8 @@ public: virtual bool IsAnisotropySupported() override; virtual int GetMaxAnisotropyLevel() override; + virtual int GetMaxSamples() override; + private: //! Updates position for given light based on transformation matrices void UpdateLightPosition(int index); @@ -221,6 +223,8 @@ private: bool m_anisotropyAvailable; //! Maximum anisotropy level int m_maxAnisotropy; + //! Maximum samples + int m_maxSamples; //! Map of saved VBO objects std::map m_vboObjects; //! Last ID of VBO object diff --git a/src/graphics/opengl/gldevice.cpp b/src/graphics/opengl/gldevice.cpp index 753f7d66..a2d66274 100644 --- a/src/graphics/opengl/gldevice.cpp +++ b/src/graphics/opengl/gldevice.cpp @@ -47,6 +47,7 @@ CGLDevice::CGLDevice(const DeviceConfig &config) m_vertexBufferType = VBT_DISPLAY_LIST; m_anisotropyAvailable = false; m_maxAnisotropy = 1; + m_maxSamples = 1; m_glMajor = 1; m_glMinor = 1; m_shadowMappingSupport = SMS_NONE; @@ -231,6 +232,17 @@ bool CGLDevice::Create() GetLogger()->Info("Anisotropic filtering not available\n"); } + // Read maximum sample count for MSAA + if(glewIsSupported("GL_ARB_multisample")) + { + glGetIntegerv(GL_MAX_SAMPLES_EXT, &m_maxSamples); + GetLogger()->Info("Multisampling supported, max samples: %d\n", m_maxSamples); + } + else + { + GetLogger()->Info("Multisampling not supported\n"); + } + GetLogger()->Info("Auto-detecting VBO support\n"); // detecting VBO ARB extension @@ -1903,4 +1915,9 @@ int CGLDevice::GetMaxAnisotropyLevel() return m_maxAnisotropy; } +int CGLDevice::GetMaxSamples() +{ + return m_maxSamples; +} + } // namespace Gfx diff --git a/src/graphics/opengl/gldevice.h b/src/graphics/opengl/gldevice.h index 5ebe927f..de75d280 100644 --- a/src/graphics/opengl/gldevice.h +++ b/src/graphics/opengl/gldevice.h @@ -169,6 +169,8 @@ public: virtual bool IsAnisotropySupported() override; virtual int GetMaxAnisotropyLevel() override; + virtual int GetMaxSamples() override; + private: //! Updates internal modelview matrix void UpdateModelviewMatrix(); @@ -245,6 +247,8 @@ private: bool m_anisotropyAvailable; //! Maximum anisotropy level int m_maxAnisotropy; + //! Maximum samples + int m_maxSamples; //! Framebuffer support FramebufferSupport m_framebufferSupport; //! Which vertex buffer type to use diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp index 357720dd..e1f765b4 100644 --- a/src/ui/maindialog.cpp +++ b/src/ui/maindialog.cpp @@ -214,6 +214,7 @@ void CMainDialog::ChangePhase(Phase phase) CCheck* pc; CScroll* ps; CSlider* psl; + CEnumSlider* pes; CButton* pb; CColor* pco; CGroup* pg; @@ -1090,6 +1091,25 @@ void CMainDialog::ChangePhase(Phase phase) pc->SetState(STATE_SHADOW); } + pos.x = ox+sx*3; + pos.y = 0.245f; + ddim.x = dim.x*2.2f; + ddim.y = 18.0f/480.0f; + pes = pw->CreateEnumSlider(pos, ddim, 0, EVENT_INTERFACE_MSAA); + pes->SetState(STATE_SHADOW); + std::vector msaaOptions; + for(int i = 1; i <= m_engine->GetDevice()->GetMaxSamples(); i *= 2) + msaaOptions.push_back(i); + pes->SetPossibleValues(msaaOptions); + if(m_engine->GetDevice()->GetMaxSamples() < 2) + pes->ClearState(STATE_ENABLE); + pos.y += ddim.y/2; + pos.x += 0.005f; + ddim.x = 0.40f; + GetResource(RES_EVENT, EVENT_INTERFACE_MSAA, name); + pl = pw->CreateLabel(pos, ddim, 0, EVENT_LABEL12, name); + pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); + pos.x = ox+sx*8.5f; pos.y = 0.65f; ddim.x = dim.x*2.2f; @@ -1153,8 +1173,6 @@ void CMainDialog::ChangePhase(Phase phase) pl->SetTextAlign(Gfx::TEXT_ALIGN_LEFT); } - CEnumSlider* pes; - pos.x = ox+sx*8.5f; pos.y = 0.385f; ddim.x = dim.x*2.2f; @@ -2465,6 +2483,7 @@ bool CMainDialog::EventProcess(const Event &event) case EVENT_INTERFACE_TEXTURE_FILTER: case EVENT_INTERFACE_TEXTURE_MIPMAP: case EVENT_INTERFACE_TEXTURE_ANISOTROPY: + case EVENT_INTERFACE_MSAA: ChangeSetupButtons(); UpdateSetupButtons(); break; @@ -4668,6 +4687,12 @@ void CMainDialog::UpdateSetupButtons() pes->SetVisibleValue(m_engine->GetTextureAnisotropyLevel()); } + pes = static_cast(pw->SearchControl(EVENT_INTERFACE_MSAA)); + if ( pes != 0 ) + { + pes->SetVisibleValue(m_engine->GetMultiSample()); + } + pc = static_cast(pw->SearchControl(EVENT_INTERFACE_SHADOW)); if ( pc != 0 ) { @@ -4855,6 +4880,13 @@ void CMainDialog::ChangeSetupButtons() value = pes->GetVisibleValue(); m_engine->SetTextureAnisotropyLevel(static_cast(value)); } + + pes = static_cast(pw->SearchControl(EVENT_INTERFACE_MSAA)); + if ( pes != 0 ) + { + value = pes->GetVisibleValue(); + m_engine->SetMultiSample(static_cast(value)); + } }