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