fix alpha blending issues
This commit is contained in:
parent
6fce78d519
commit
ba01909088
|
@ -17,7 +17,6 @@ Module
|
|||
dofile 'settings'
|
||||
dofile 'keyboard'
|
||||
dofile 'mouse'
|
||||
dofile 'string'
|
||||
|
||||
dofiles 'ui'
|
||||
dofiles 'widgets'
|
||||
|
|
|
@ -21,3 +21,25 @@ end
|
|||
function string.trim(s)
|
||||
return string.match(s, '^%s*(.*%S)') or ''
|
||||
end
|
||||
|
||||
function string.explode(str, sep, limit)
|
||||
if(type(sep) ~= 'string' or tostring(str):len() == 0 or sep:len() == 0) then
|
||||
return {}
|
||||
end
|
||||
|
||||
local i, pos, tmp, t = 0, 1, "", {}
|
||||
for s, e in function() return string.find(str, sep, pos) end do
|
||||
tmp = str:sub(pos, s - 1):trim()
|
||||
table.insert(t, tmp)
|
||||
pos = e + 1
|
||||
|
||||
i = i + 1
|
||||
if(limit ~= nil and i == limit) then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
tmp = str:sub(pos):trim()
|
||||
table.insert(t, tmp)
|
||||
return t
|
||||
end
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
string.explode = function (str, sep, limit)
|
||||
if(type(sep) ~= 'string' or tostring(str):len() == 0 or sep:len() == 0) then
|
||||
return {}
|
||||
end
|
||||
|
||||
local i, pos, tmp, t = 0, 1, "", {}
|
||||
for s, e in function() return string.find(str, sep, pos) end do
|
||||
tmp = str:sub(pos, s - 1):trim()
|
||||
table.insert(t, tmp)
|
||||
pos = e + 1
|
||||
|
||||
i = i + 1
|
||||
if(limit ~= nil and i == limit) then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
tmp = str:sub(pos):trim()
|
||||
table.insert(t, tmp)
|
||||
return t
|
||||
end
|
|
@ -157,6 +157,7 @@ void FrameBuffer::internalRelease()
|
|||
// restore screen original content
|
||||
g_painter->setCompositionMode(Painter::CompositionMode_Replace);
|
||||
g_painter->drawTexturedRect(screenRect, m_screenBackup, screenRect);
|
||||
g_painter->resetCompositionMode();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -330,3 +330,14 @@ bool Graphics::canUseClampToEdge()
|
|||
return m_useClampToEdge;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Graphics::canUseBlendFuncSeparate()
|
||||
{
|
||||
#ifdef OPENGL_ES
|
||||
return true;
|
||||
#else
|
||||
if(!GLEW_VERSION_1_4)
|
||||
return false;
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
bool canUseMipmaps();
|
||||
bool canUseHardwareMipmaps();
|
||||
bool canUseClampToEdge();
|
||||
bool canUseBlendFuncSeparate();
|
||||
|
||||
private:
|
||||
Size m_viewportSize;
|
||||
|
|
|
@ -132,7 +132,11 @@ void Painter::updateGlCompositionMode()
|
|||
{
|
||||
switch(m_compositionMode) {
|
||||
case CompositionMode_Normal:
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
if(g_graphics.canUseBlendFuncSeparate())
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
|
||||
else {
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
break;
|
||||
case CompositionMode_Multiply:
|
||||
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
|
|
@ -304,7 +304,7 @@ void WIN32Window::internalChooseGLVisual()
|
|||
PFD_TYPE_RGBA,
|
||||
32, // Select Our Color Depth
|
||||
0, 0, 0, 0, 0, 0, // Color Bits Ignored
|
||||
1, // Alpha Buffer Bits
|
||||
8, // Alpha Buffer Bits
|
||||
0, // Shift Bit Ignored
|
||||
0, // No Accumulation Buffer
|
||||
0, 0, 0, 0, // Accumulation Bits Ignored
|
||||
|
|
|
@ -77,13 +77,11 @@ void MapView::draw(const Rect& rect)
|
|||
Rect clearRect = Rect(0, 0, m_drawDimension * m_tileSize);
|
||||
|
||||
// drawing a black rect is actually faster than FrameBuffer::clear()
|
||||
/*
|
||||
g_painter->setColor(Color::black);
|
||||
g_painter->drawFilledRect(clearRect);
|
||||
g_painter->setColor(Color::white);
|
||||
*/
|
||||
|
||||
m_framebuffer->clear(Color::black);
|
||||
//m_framebuffer->clear(Color::black);
|
||||
}
|
||||
|
||||
auto it = m_cachedVisibleTiles.begin();
|
||||
|
@ -148,8 +146,8 @@ void MapView::draw(const Rect& rect)
|
|||
#else
|
||||
m_framebuffer->draw(rect, srcRect);
|
||||
#endif
|
||||
|
||||
g_painter->restoreSavedState();
|
||||
|
||||
//g_painter->resetShaderProgram();
|
||||
|
||||
// this could happen if the player position is not known yet
|
||||
|
|
Loading…
Reference in New Issue