Make Liquid effect work without NPOT textures as well.
svn path=/branches/work/kwin_composite/; revision=659161
This commit is contained in:
parent
49a56dc905
commit
91f795922d
2 changed files with 18 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
uniform sampler2D sceneTex;
|
||||
uniform float displayWidth;
|
||||
uniform float displayHeight;
|
||||
uniform float textureWidth;
|
||||
uniform float textureHeight;
|
||||
uniform float time;
|
||||
|
||||
varying vec2 pos;
|
||||
|
@ -12,7 +12,7 @@ varying vec2 pos;
|
|||
// Converts pixel coordinates to texture coordinates
|
||||
vec2 pix2tex(vec2 pix)
|
||||
{
|
||||
return vec2(pix.x / displayWidth, 1.0 - pix.y / displayHeight);
|
||||
return vec2(pix.x / textureWidth, 1.0 - pix.y / textureHeight);
|
||||
}
|
||||
|
||||
float wave(vec2 pos, vec2 wave_dir, float wave_length, float wave_speed)
|
||||
|
|
|
@ -45,8 +45,19 @@ LiquidEffect::~LiquidEffect()
|
|||
|
||||
bool LiquidEffect::loadData()
|
||||
{
|
||||
// If NPOT textures are not supported, use nearest power-of-two sized
|
||||
// texture. It wastes memory, but it's possible to support systems without
|
||||
// NPOT textures that way
|
||||
int texw = displayWidth();
|
||||
int texh = displayHeight();
|
||||
if( !GLTexture::NPOTTextureSupported() )
|
||||
{
|
||||
kWarning( 1212 ) << k_funcinfo << "NPOT textures not supported, wasting some memory" << endl;
|
||||
texw = nearestPowerOfTwo(texw);
|
||||
texh = nearestPowerOfTwo(texh);
|
||||
}
|
||||
// Create texture and render target
|
||||
mTexture = new GLTexture(displayWidth(), displayHeight());
|
||||
mTexture = new GLTexture(texw, texh);
|
||||
mTexture->setFilter(GL_LINEAR_MIPMAP_LINEAR);
|
||||
mTexture->setWrapMode(GL_CLAMP);
|
||||
|
||||
|
@ -69,8 +80,8 @@ bool LiquidEffect::loadData()
|
|||
}
|
||||
mShader->bind();
|
||||
mShader->setUniform("sceneTex", 0);
|
||||
mShader->setUniform("displayWidth", (float)displayWidth());
|
||||
mShader->setUniform("displayHeight", (float)displayHeight());
|
||||
mShader->setUniform("textureWidth", (float)texw);
|
||||
mShader->setUniform("textureHeight", (float)texh);
|
||||
mShader->unbind();
|
||||
|
||||
return true;
|
||||
|
@ -78,7 +89,7 @@ bool LiquidEffect::loadData()
|
|||
|
||||
bool LiquidEffect::supported()
|
||||
{
|
||||
return GLRenderTarget::supported() && GLTexture::NPOTTextureSupported() &&
|
||||
return GLRenderTarget::supported() &&
|
||||
GLShader::fragmentShaderSupported() &&
|
||||
(effects->compositingType() == OpenGLCompositing);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue