Billboard overlays disply grey square while image is loading

This commit is contained in:
Atlante45 2014-07-11 11:22:06 -07:00
parent a9ceec4627
commit 22bcb7d7e7

View file

@ -20,9 +20,7 @@ BillboardOverlay::BillboardOverlay()
}
void BillboardOverlay::render() {
if (_billboard.isEmpty()) {
return;
}
if (!_billboard.isEmpty()) {
if (!_billboardTexture) {
QImage image = QImage::fromData(_billboard);
if (image.format() != QImage::Format_ARGB32) {
@ -41,6 +39,7 @@ void BillboardOverlay::render() {
} else {
glBindTexture(GL_TEXTURE_2D, _billboardTexture->getID());
}
}
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5f);
@ -62,6 +61,7 @@ void BillboardOverlay::render() {
}
glScalef(_scale, _scale, _scale);
if (_billboardTexture) {
float maxSize = glm::max(_fromImage.width(), _fromImage.height());
float x = _fromImage.width() / (2.0f * maxSize);
float y = -_fromImage.height() / (2.0f * maxSize);
@ -81,6 +81,15 @@ 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();