Skip to content

Commit

Permalink
ensure correct blending in other gui elements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziusudra authored and robn committed Apr 7, 2012
1 parent 6df9456 commit 7cb12b7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/gui/GuiContainer.cpp
Expand Up @@ -163,15 +163,21 @@ void Container::Draw()
float size[2];
GetSize(size);
if (!m_transparent) {
if (m_bgcol[3] < 1.0) glEnable(GL_BLEND);
if (m_bgcol[3] < 1.0) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
glBegin(GL_QUADS);
glColor4fv(m_bgcol);
glVertex2f(0, size[1]);
glVertex2f(size[0], size[1]);
glVertex2f(size[0], 0);
glVertex2f(0, 0);
glEnd();
glDisable(GL_BLEND);
if (m_bgcol[3] < 1.0) {
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
}
}
#ifdef GUI_DEBUG_CONTAINER
glBegin(GL_LINE_LOOP);
Expand Down
2 changes: 2 additions & 0 deletions src/gui/GuiToolTip.cpp
Expand Up @@ -51,6 +51,7 @@ void ToolTip::Draw()
int age = SDL_GetTicks() - m_createdTime;
float alpha = age/float(FADE_TIME_MS); alpha = std::min(alpha, 0.75f);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GetSize(size);
glColor4f(.2f,.2f,.6f,alpha);
glBegin(GL_QUADS);
Expand All @@ -71,6 +72,7 @@ void ToolTip::Draw()
glColor4f(1,1,1,alpha);
m_layout->Render(size[0]-2*TOOLTIP_PADDING);
glPopMatrix();
glBlendFunc(GL_ONE, GL_ZERO);
glDisable(GL_BLEND);
}

Expand Down

0 comments on commit 7cb12b7

Please sign in to comment.