History

Working on heightfield encoding.

Andrzej Kapolka committed 12 years ago

Commit 1ea9b0c1 parent 496f4a16 files · +112 −8Browse files

Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 6 files). Show all

Unified · Split

interface/src/MetavoxelSystem.cpp+8−5
@@ -255,11 +255,12 @@ void PointBuffer::render() { · 254 unmodified lines
255}255}
256 256
257HeightfieldBuffer::HeightfieldBuffer(const glm::vec3& translation, float scale,257HeightfieldBuffer::HeightfieldBuffer(const glm::vec3& translation, float scale,
258 const QByteArray& height, const QByteArray& color) :258 const QByteArray& height, const QByteArray& color, bool clearAfterLoading) :
259 _translation(translation),259 _translation(translation),
260 _scale(scale),260 _scale(scale),
261 _height(height),261 _height(height),
262 _color(color),262 _color(color),
263 _clearAfterLoading(clearAfterLoading),
263 _heightTexture(QOpenGLTexture::Target2D),264 _heightTexture(QOpenGLTexture::Target2D),
264 _colorTexture(QOpenGLTexture::Target2D) {265 _colorTexture(QOpenGLTexture::Target2D) {
265}266}
@@ -281,8 +282,9 @@ void HeightfieldBuffer::render() { · 15 unmodified lines
281 _heightTexture.setFormat(QOpenGLTexture::LuminanceFormat);282 _heightTexture.setFormat(QOpenGLTexture::LuminanceFormat);
282 _heightTexture.allocateStorage();283 _heightTexture.allocateStorage();
283 _heightTexture.setData(QOpenGLTexture::Luminance, QOpenGLTexture::UInt8, _height.data());284 _heightTexture.setData(QOpenGLTexture::Luminance, QOpenGLTexture::UInt8, _height.data());
284 _height.clear();285 if (_clearAfterLoading) {
285 286 _height.clear();
287 }
286 if (!_color.isEmpty()) {288 if (!_color.isEmpty()) {
287 int colorSize = glm::sqrt(_color.size() / 3);289 int colorSize = glm::sqrt(_color.size() / 3);
288 _colorTexture.setSize(colorSize, colorSize);290 _colorTexture.setSize(colorSize, colorSize);
@@ -294,8 +296,9 @@ void HeightfieldBuffer::render() { · 5 unmodified lines
294 _colorTexture.allocateStorage();296 _colorTexture.allocateStorage();
295 if (!_color.isEmpty()) {297 if (!_color.isEmpty()) {
296 _colorTexture.setData(QOpenGLTexture::RGB, QOpenGLTexture::UInt8, _color.data());298 _colorTexture.setData(QOpenGLTexture::RGB, QOpenGLTexture::UInt8, _color.data());
297 _color.clear();299 if (_clearAfterLoading) {
298 300 _color.clear();
301 }
299 } else {302 } else {
300 const quint8 WHITE_COLOR[] = { 255, 255, 255 };303 const quint8 WHITE_COLOR[] = { 255, 255, 255 };
301 _colorTexture.setData(QOpenGLTexture::RGB, QOpenGLTexture::UInt8, const_cast<quint8*>(WHITE_COLOR));304 _colorTexture.setData(QOpenGLTexture::RGB, QOpenGLTexture::UInt8, const_cast<quint8*>(WHITE_COLOR));