Add container background texture

master
Peter Nelson 2013-02-03 13:40:18 +00:00
parent 3009f08a76
commit 971d432963
2 changed files with 29 additions and 11 deletions

View File

@ -11,7 +11,25 @@ Container::~Container()
void Container::OnPaint() const
{
if (this->colour.a) {
if (this->back) {
float tw = (float)w / tex->w[TEX_BACK];
float th = (float)h / tex->h[TEX_BACK];
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tex->tex[TEX_BACK]);
glBegin(GL_QUADS);
glColor4f(colour.r, colour.g, colour.b, colour.a);
glTexCoord2f(.0, .0);
glVertex2f( x, y);
glTexCoord2f(.0, th);
glVertex2f( x, h + y);
glTexCoord2f(tw, th);
glVertex2f(w + x, h + y);
glTexCoord2f(tw, .0);
glVertex2f(w + x, y);
glEnd();
glDisable(GL_TEXTURE_2D);
} else if (this->colour.a) {
glBegin(GL_QUADS);
glColor4f(colour.r, colour.g, colour.b, colour.a);
glVertex2f( x, y);
@ -20,16 +38,15 @@ void Container::OnPaint() const
glVertex2f(w + x, y);
glEnd();
}
/*
glBegin(GL_LINE_LOOP);
glColor3f(0.0, 0.0, 0.0);
glVertex2f( x, y);
glVertex2f( x, h + y);
glVertex2f(w + x, h + y);
glVertex2f(w + x, y);
// glVertex2f( x, y);
glEnd();
*/
/* glBegin(GL_LINE_LOOP);
glColor4f(1, 1, 1, 0.25f);
glVertex2f( x + .5f, y + .5f);
glVertex2f( x + .5f, h + y - .5f);
glVertex2f(w + x - .5f, h + y - .5f);
glVertex2f(w + x - .5f, y + .5f);
glEnd();*/
std::list<Widget *>::const_iterator it;
for (it = children.begin(); it != children.end(); ++it) {
(*it)->OnPaint();

View File

@ -6,6 +6,7 @@
struct Container : Widget {
std::list<Widget *> children;
Colour colour;
bool back;
~Container();