Merge pull request from ey6es/master

Fix for distorted replaced textures.
This commit is contained in:
Philip Rosedale 2014-12-13 23:15:28 -08:00
commit fddd67d5f7

View file

@ -2188,13 +2188,15 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g
bufferPair.second.release();
}
if (_heightTextureID == 0) {
// we use non-aligned data for the various layers
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &_heightTextureID);
glBindTexture(GL_TEXTURE_2D, _heightTextureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
const QVector<quint16>& heightContents = node->getHeight()->getContents();
glTexImage2D(GL_TEXTURE_2D, 0, GL_R16, width, height, 0,
GL_RED, GL_UNSIGNED_SHORT, heightContents.constData());
@ -2241,6 +2243,9 @@ void HeightfieldNodeRenderer::render(const HeightfieldNodePointer& node, const g
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, 1, 1, 0, GL_RED, GL_UNSIGNED_BYTE, &ZERO_VALUE);
}
glBindTexture(GL_TEXTURE_2D, 0);
// restore the default alignment; it's what Qt uses for image storage
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
}
if (cursor) {