diff --git a/modules/client/client.lua b/modules/client/client.lua index acf2800d..cf9aae22 100644 --- a/modules/client/client.lua +++ b/modules/client/client.lua @@ -40,10 +40,10 @@ function Client.init() scheduleEvent(function() g_window.show() - -- play startup music - --g_sounds.playMusic("startup.ogg", 3) - --connect(g_game, { onGameStart = function() g_sounds.stopMusic(3) end }) - --connect(g_game, { onGameEnd= function() g_sounds.playMusic("startup.ogg", 3) end }) + -- Play startup music (The Silver Tree, by Mattias Westlund) + g_sounds.playMusic("startup.ogg", 3) + connect(g_game, { onGameStart = function() g_sounds.stopMusic(3) end }) + connect(g_game, { onGameEnd= function() g_sounds.playMusic("startup.ogg", 3) end }) end, 0) end, 0) end diff --git a/modules/client_skins/skins/example.lua b/modules/client_skins/skins/example.lua index 3f8fd1b2..3f43ecea 100644 --- a/modules/client_skins/skins/example.lua +++ b/modules/client_skins/skins/example.lua @@ -1,6 +1,6 @@ local skin = { name = 'Example', - + styles = { 'topmenu.otui' } diff --git a/modules/game_shaders/shaders.lua b/modules/game_shaders/shaders.lua index b88a740c..124bb589 100644 --- a/modules/game_shaders/shaders.lua +++ b/modules/game_shaders/shaders.lua @@ -25,7 +25,6 @@ local shadersPanel function Shaders.init() importStyle 'shaders.otui' - Keyboard.bindKeyDown(HOTKEY, Shaders.toggle) shadersPanel = createWidget('ShadersPanel', GameInterface.getMapPanel()) @@ -37,6 +36,8 @@ function Shaders.init() map:setMapShader(g_shaders.getShader(option)) end + if not g_graphics.canUseShaders() then return end + for _i,opts in pairs(MAP_SHADERS) do local shader = g_shaders.createFragmentShader(opts.name, opts.frag) diff --git a/modules/game_shaders/shaders/radialblur.frag b/modules/game_shaders/shaders/radialblur.frag index c3b3e8c9..fe359aeb 100644 --- a/modules/game_shaders/shaders/radialblur.frag +++ b/modules/game_shaders/shaders/radialblur.frag @@ -7,9 +7,6 @@ const float sampleStrength = 2.2; void main(void) { - // some sample positions - float samples[] = { -0.08,-0.05,-0.03,-0.02,-0.01,0.01,0.02,0.03,0.05,0.08 }; - // 0.5,0.5 is the center of the screen // so substracting v_TexCoord from it will result in // a vector pointing to the middle of the screen @@ -29,8 +26,16 @@ void main(void) // take 10 additional blur samples in the direction towards // the center of the screen - for(int i = 0; i < 10; i++) - sum += texture2D(u_Tex0, v_TexCoord + dir * samples[i] * sampleDist); + sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist); + sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist); + sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist); + sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist); + sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist); + sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist); + sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist); + sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist); + sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist); + sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist); // we have taken eleven samples sum *= 1.0/11.0; @@ -42,4 +47,4 @@ void main(void) //Blend the original color with the averaged pixels gl_FragColor = mix(color, sum, t); -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/framework/graphics/painter.cpp b/src/framework/graphics/painter.cpp index 9b9bd449..4d4f2139 100644 --- a/src/framework/graphics/painter.cpp +++ b/src/framework/graphics/painter.cpp @@ -23,6 +23,8 @@ #include "painter.h" #include "graphics.h" +#include + Painter *g_painter = nullptr; Painter::Painter() @@ -35,6 +37,7 @@ Painter::Painter() m_shaderProgram = nullptr; m_texture = nullptr; m_alphaWriting = false; + setResolution(g_window.getSize()); } void Painter::resetState() @@ -50,11 +53,11 @@ void Painter::resetState() void Painter::refreshState() { + updateGlViewport(); updateGlCompositionMode(); updateGlClipRect(); updateGlTexture(); updateGlAlphaWriting(); - updateGlViewport(); } void Painter::saveState() diff --git a/src/framework/graphics/painterogl1.cpp b/src/framework/graphics/painterogl1.cpp index 573319eb..f05acee0 100644 --- a/src/framework/graphics/painterogl1.cpp +++ b/src/framework/graphics/painterogl1.cpp @@ -20,7 +20,7 @@ * THE SOFTWARE. */ -#ifndef OPENGL_ES +#if !defined(OPENGL_ES) || OPENGL_ES==1 #include "painterogl1.h" #include "graphics.h" diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index de1874b1..8228c62e 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -562,6 +562,7 @@ void Application::registerLuaFunctions() g_lua.bindSingletonFunction("g_graphics", "isPainterEngineAvailable", &Graphics::isPainterEngineAvailable, &g_graphics); g_lua.bindSingletonFunction("g_graphics", "selectPainterEngine", &Graphics::selectPainterEngine, &g_graphics); g_lua.bindSingletonFunction("g_graphics", "canCacheBackbuffer", &Graphics::canCacheBackbuffer, &g_graphics); + g_lua.bindSingletonFunction("g_graphics", "canUseShaders", &Graphics::canUseShaders, &g_graphics); g_lua.bindSingletonFunction("g_graphics", "getPainterEngine", &Graphics::getPainterEngine, &g_graphics); g_lua.bindSingletonFunction("g_graphics", "getViewportSize", &Graphics::getViewportSize, &g_graphics); g_lua.bindSingletonFunction("g_graphics", "getVendor", &Graphics::getVendor, &g_graphics);