mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 19:55:07 +02:00
Don't display anything if overlays not loaded
This commit is contained in:
parent
f2dbaaf65c
commit
28d4efbad6
5 changed files with 16 additions and 12 deletions
|
@ -17,10 +17,11 @@ BillboardOverlay::BillboardOverlay()
|
|||
: _fromImage(-1,-1,-1,-1),
|
||||
_scale(1.0f),
|
||||
_isFacingAvatar(true) {
|
||||
_isLoaded = false;
|
||||
}
|
||||
|
||||
void BillboardOverlay::render() {
|
||||
if (!_visible) {
|
||||
if (!_visible || !_isLoaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -85,16 +86,7 @@ void BillboardOverlay::render() {
|
|||
((float)_fromImage.y() + (float)_fromImage.height()) / (float)_size.height());
|
||||
glVertex2f(-x, y);
|
||||
} glEnd();
|
||||
} else {
|
||||
glColor4f(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
glBegin(GL_QUADS); {
|
||||
glVertex2f(-1.0f, -1.0f);
|
||||
glVertex2f(1.0f, -1.0f);
|
||||
glVertex2f(1.0f, 1.0f);
|
||||
glVertex2f(-1.0f, 1.0f);
|
||||
} glEnd();
|
||||
}
|
||||
|
||||
} glPopMatrix();
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
@ -167,6 +159,7 @@ void BillboardOverlay::setProperties(const QScriptValue &properties) {
|
|||
}
|
||||
|
||||
void BillboardOverlay::setBillboardURL(const QUrl url) {
|
||||
_isLoaded = false;
|
||||
QNetworkReply* reply = NetworkAccessManager::getInstance().get(QNetworkRequest(url));
|
||||
connect(reply, &QNetworkReply::finished, this, &BillboardOverlay::replyFinished);
|
||||
}
|
||||
|
@ -175,4 +168,5 @@ void BillboardOverlay::replyFinished() {
|
|||
// replace our byte array with the downloaded data
|
||||
QNetworkReply* reply = static_cast<QNetworkReply*>(sender());
|
||||
_billboard = reply->readAll();
|
||||
_isLoaded = true;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ ImageOverlay::ImageOverlay() :
|
|||
_textureBound(false),
|
||||
_wantClipFromImage(false)
|
||||
{
|
||||
_isLoaded = false;
|
||||
}
|
||||
|
||||
ImageOverlay::~ImageOverlay() {
|
||||
|
@ -35,6 +36,7 @@ ImageOverlay::~ImageOverlay() {
|
|||
|
||||
// TODO: handle setting image multiple times, how do we manage releasing the bound texture?
|
||||
void ImageOverlay::setImageURL(const QUrl& url) {
|
||||
_isLoaded = false;
|
||||
NetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
QNetworkReply* reply = networkAccessManager.get(QNetworkRequest(url));
|
||||
connect(reply, &QNetworkReply::finished, this, &ImageOverlay::replyFinished);
|
||||
|
@ -47,10 +49,11 @@ void ImageOverlay::replyFinished() {
|
|||
QByteArray rawData = reply->readAll();
|
||||
_textureImage.loadFromData(rawData);
|
||||
_renderImage = true;
|
||||
_isLoaded = true;
|
||||
}
|
||||
|
||||
void ImageOverlay::render() {
|
||||
if (!_visible) {
|
||||
if (!_visible || !_isLoaded) {
|
||||
return; // do nothing if we're not visible
|
||||
}
|
||||
if (_renderImage && !_textureBound) {
|
||||
|
|
|
@ -15,8 +15,10 @@
|
|||
ModelOverlay::ModelOverlay()
|
||||
: _model(),
|
||||
_scale(1.0f),
|
||||
_updateModel(false) {
|
||||
_updateModel(false)
|
||||
{
|
||||
_model.init();
|
||||
_isLoaded = false;
|
||||
}
|
||||
|
||||
void ModelOverlay::update(float deltatime) {
|
||||
|
@ -32,6 +34,7 @@ void ModelOverlay::update(float deltatime) {
|
|||
} else {
|
||||
_model.simulate(deltatime);
|
||||
}
|
||||
_isLoaded = _model.isActive();
|
||||
}
|
||||
|
||||
void ModelOverlay::render() {
|
||||
|
@ -90,6 +93,7 @@ void ModelOverlay::setProperties(const QScriptValue &properties) {
|
|||
if (urlValue.isValid()) {
|
||||
_url = urlValue.toVariant().toString();
|
||||
_updateModel = true;
|
||||
_isLoaded = false;
|
||||
}
|
||||
|
||||
QScriptValue scaleValue = properties.property("scale");
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
Overlay::Overlay() :
|
||||
_parent(NULL),
|
||||
_isLoaded(true),
|
||||
_alpha(DEFAULT_ALPHA),
|
||||
_color(DEFAULT_OVERLAY_COLOR),
|
||||
_visible(true),
|
||||
|
|
|
@ -40,6 +40,7 @@ public:
|
|||
virtual void render() = 0;
|
||||
|
||||
// getters
|
||||
bool isLoaded() { return _isLoaded; }
|
||||
bool getVisible() const { return _visible; }
|
||||
const xColor& getColor() const { return _color; }
|
||||
float getAlpha() const { return _alpha; }
|
||||
|
@ -55,6 +56,7 @@ public:
|
|||
|
||||
protected:
|
||||
QGLWidget* _parent;
|
||||
bool _isLoaded;
|
||||
float _alpha;
|
||||
xColor _color;
|
||||
bool _visible; // should the overlay be drawn at all
|
||||
|
|
Loading…
Reference in a new issue