mirror of
https://github.com/overte-org/overte.git
synced 2025-04-05 21:12:25 +02:00
Canvas frame update experiment
This commit is contained in:
parent
e97ded844b
commit
addd65a160
3 changed files with 33 additions and 1 deletions
|
@ -14,7 +14,7 @@ using namespace render::entities;
|
|||
CanvasEntityRenderer::CanvasEntityRenderer(const EntityItemPointer& entity) : Parent(entity) {
|
||||
gpu::Byte pixels[256 * 256 * 4];
|
||||
|
||||
// grayscale XOR placeholder texture
|
||||
// dummy placeholder texture to make sure the per-frame thing works
|
||||
for (int x = 0; x < 256; x++) {
|
||||
for (int y = 0; y < 256; y++) {
|
||||
pixels[(y * 256 * 4) + (x * 4) + 0] = 255;
|
||||
|
@ -28,6 +28,29 @@ CanvasEntityRenderer::CanvasEntityRenderer(const EntityItemPointer& entity) : Pa
|
|||
_texture->setStoredMipFormat(gpu::Element::COLOR_SRGBA_32);
|
||||
_texture->assignStoredMip(0, 256 * 256 * 4, pixels);
|
||||
_texture->setSource(__FUNCTION__);
|
||||
|
||||
_testTimer.setInterval(33);
|
||||
connect(&_testTimer, &QTimer::timeout, this, &CanvasEntityRenderer::onTimeout);
|
||||
_testTimer.start();
|
||||
}
|
||||
|
||||
CanvasEntityRenderer::~CanvasEntityRenderer() { }
|
||||
|
||||
void CanvasEntityRenderer::onTimeout() {
|
||||
gpu::Byte pixels[256 * 256 * 4];
|
||||
|
||||
// XOR placeholder texture
|
||||
for (int x = 0; x < 256; x++) {
|
||||
for (int y = 0; y < 256; y++) {
|
||||
pixels[(y * 256 * 4) + (x * 4) + 0] = ((x + _ticks) ^ (y + _ticks));
|
||||
pixels[(y * 256 * 4) + (x * 4) + 1] = ((x + _ticks) ^ (y + _ticks));
|
||||
pixels[(y * 256 * 4) + (x * 4) + 2] = ((x + _ticks) ^ (y + _ticks));
|
||||
pixels[(y * 256 * 4) + (x * 4) + 3] = 255;
|
||||
}
|
||||
}
|
||||
|
||||
_texture->assignStoredMip(0, 256 * 256 * 4, pixels);
|
||||
|
||||
_ticks += 1;
|
||||
qDebug("onTimeout: _ticks = %d", _ticks);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,10 @@ protected:
|
|||
|
||||
private:
|
||||
gpu::TexturePointer _texture;
|
||||
|
||||
int _ticks = 0;
|
||||
QTimer _testTimer;
|
||||
void onTimeout();
|
||||
};
|
||||
|
||||
} }
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "RenderableLightEntityItem.h"
|
||||
#include "RenderableZoneEntityItem.h"
|
||||
#include "RenderableMaterialEntityItem.h"
|
||||
#include "RenderableCanvasEntityItem.h"
|
||||
|
||||
#include "RenderPipelines.h"
|
||||
|
||||
|
@ -433,6 +434,10 @@ EntityRenderer::Pointer EntityRenderer::addToScene(EntityTreeRenderer& renderer,
|
|||
result = make_renderer<MaterialEntityRenderer>(entity);
|
||||
break;
|
||||
|
||||
case Type::Canvas:
|
||||
result = make_renderer<CanvasEntityRenderer>(entity);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue