put drawButton in its class, and not in main loop
This commit is contained in:
@@ -45,4 +45,25 @@ TextButtonInstance::TextButtonInstance(void)
|
||||
|
||||
TextButtonInstance::~TextButtonInstance(void)
|
||||
{
|
||||
}
|
||||
|
||||
void TextButtonInstance::drawObj(RenderDevice* rd)
|
||||
{
|
||||
Vector3 point1;
|
||||
Vector3 point2;
|
||||
if(floatBottom)
|
||||
{
|
||||
point1 = Vector3(boxBegin.x, rd->getHeight() + boxBegin.y,0);
|
||||
point2 = Vector3(boxEnd.x, rd->getHeight() + boxEnd.y,0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
point1 = Vector3(boxBegin.x, boxBegin.y,0);
|
||||
point2 = Vector3(boxEnd.x, boxEnd.y,0);
|
||||
}
|
||||
Draw::box(Box(point1, point2), rd, boxColor, boxOutlineColor);
|
||||
Vector2 RelativeTo = Vector2(point1.x + fontLocationRelativeTo.x, point1.y + fontLocationRelativeTo.y);
|
||||
font->draw2D(rd, title, RelativeTo, textSize, textColor, textOutlineColor);
|
||||
|
||||
}
|
||||
@@ -29,5 +29,6 @@ public:
|
||||
bool floatRight;
|
||||
bool visible;
|
||||
int textSize;
|
||||
|
||||
};
|
||||
void drawObj(G3D::RenderDevice*);
|
||||
|
||||
};
|
||||
22
main.cpp
22
main.cpp
@@ -519,23 +519,7 @@ void drawButtons(RenderDevice* rd)
|
||||
if(instance->className == "TextButton" && instance->parent == dataModel)
|
||||
{
|
||||
TextButtonInstance* tbi = (TextButtonInstance*)instance;
|
||||
Vector3 point1;
|
||||
Vector3 point2;
|
||||
if(tbi->floatBottom)
|
||||
{
|
||||
point1 = Vector3(tbi->boxBegin.x, rd->getHeight() + tbi->boxBegin.y,0);
|
||||
point2 = Vector3(tbi->boxEnd.x, rd->getHeight() + tbi->boxEnd.y,0);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
point1 = Vector3(tbi->boxBegin.x, tbi->boxBegin.y,0);
|
||||
point2 = Vector3(tbi->boxEnd.x, tbi->boxEnd.y,0);
|
||||
}
|
||||
Draw::box(Box(point1, point2), rd, tbi->boxColor, tbi->boxOutlineColor);
|
||||
Vector2 RelativeTo = Vector2(point1.x + tbi->fontLocationRelativeTo.x, point1.y + tbi->fontLocationRelativeTo.y);
|
||||
tbi->font->draw2D(rd, tbi->title, RelativeTo, tbi->textSize, tbi->textColor, tbi->textOutlineColor);
|
||||
|
||||
tbi->drawObj(rd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -666,9 +650,9 @@ void Demo::onGraphics(RenderDevice* rd) {
|
||||
glTexCoord2d( 1.0,0.0 );
|
||||
glVertex2f( 70, 0+offset );
|
||||
glTexCoord2d( 1.0,1.0 );
|
||||
glVertex2f( 70, 65+offset );
|
||||
glVertex2f( 70, 60+offset );
|
||||
glTexCoord2d( 0.0,1.0 );
|
||||
glVertex2f( 10, 65+offset );
|
||||
glVertex2f( 10, 60+offset );
|
||||
glEnd();
|
||||
|
||||
glDisable( GL_TEXTURE_2D );
|
||||
|
||||
Reference in New Issue
Block a user