button is draw by menu

This commit is contained in:
Remco
2016-06-20 12:11:24 +02:00
parent ced3ff4462
commit 6cf9437620
6 changed files with 17 additions and 12 deletions
+7 -5
View File
@@ -3,7 +3,7 @@
#include "Util.h"
#include "Vector.h"
Button::Button(std::string & text, Vec2f position, float width, float height) : MenuElement(position)
Button::Button(const std::string & text, Vec2f position, float width, float height) : MenuElement(position)
{
this->width = width;
this->height = height;
@@ -19,17 +19,19 @@ Button::~Button()
void Button::draw(void)
{
glColor4f(background.x, background.y, background.z, 1.0f);
glColor4f(background.x/255.0f, background.y / 255.0f, background.z / 255.0f, 1.0f);
glBegin(GL_QUADS);
glVertex2f(position.x, position.y);
glVertex2f(position.x, position.y + height);
glVertex2f(position.x + width, position.y + height);
glVertex2f(position.x + width, position.y);
glEnd();
glEnd();
glColor4f(foreground.x / 255.0f, foreground.y / 255.0f, foreground.z / 255.0f, 1.0f);
Util::glutBitmapString(text, position.x, position.y+height/2+18/2);
glColor4f(foreground.x, foreground.y, foreground.z, 1.0f);
Util::glutBitmapString(text, position.x + (width / 2), position.y + (height / 2));
}
void Button::update(int x, int y)