mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 02:17:11 +02:00
Billboard overlays disply grey square while image is loading
This commit is contained in:
parent
a9ceec4627
commit
22bcb7d7e7
1 changed files with 47 additions and 38 deletions
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue