Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-08-18 09:24:15 +0000
committerStijn Buys <ingar@osirion.org>2009-08-18 09:24:15 +0000
commitf030154fe727e25a2afe1f78b3998c2d2dba95e4 (patch)
treecd92baf9e4fa8a136523b9eb570e9811846c9250 /src/ui/paint.cc
parent5636fad174f0bcff857c357c394c4cc8d424b302 (diff)
astyle cleanup, corrects not loading of material textures
Diffstat (limited to 'src/ui/paint.cc')
-rw-r--r--src/ui/paint.cc49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/ui/paint.cc b/src/ui/paint.cc
index 576484e..b3d6197 100644
--- a/src/ui/paint.cc
+++ b/src/ui/paint.cc
@@ -15,7 +15,8 @@ namespace ui
{
// contains the interface between the user interface and the render library
-namespace paint {
+namespace paint
+{
void assign_color(const char c, const math::Color &color)
{
@@ -40,7 +41,7 @@ void color_code(const char c)
void border(const math::Vector2f &location, const math::Vector2f &size)
{
using namespace gl;
-
+
begin(LineLoop);
vertex(location.x(), location.y());
vertex(location.x() + size.width(), location.y());
@@ -52,7 +53,7 @@ void border(const math::Vector2f &location, const math::Vector2f &size)
void rectangle(const math::Vector2f &location, const math::Vector2f &size)
{
using namespace gl;
-
+
begin(Quads);
vertex(location.x(), location.y());
vertex(location.x() + size.width(), location.y());
@@ -66,9 +67,9 @@ void bitmap(const math::Vector2f &location, const math::Vector2f &size, std::str
{
render::Textures::bind("bitmaps/" + texture);
gl::enable(GL_TEXTURE_2D);
-
+
gl::begin(gl::Quads);
-
+
glTexCoord2f(0.0f, 0.0f);
gl::vertex(location.x(), location.y());
@@ -82,7 +83,7 @@ void bitmap(const math::Vector2f &location, const math::Vector2f &size, std::str
gl::vertex(location.x(), location.y() + size.height());
gl::end();
-
+
gl::disable(GL_TEXTURE_2D);
}
@@ -92,25 +93,25 @@ void label(const math::Vector2f &location, const math::Vector2f &size, const Fon
unsigned int align_horizontal = (align & 0x000F);
if (!align_horizontal)
align_horizontal = AlignLeft;
-
+
unsigned int align_vertical = (align & 0x00F0);
if (!align_vertical)
align_vertical = AlignTop;
-
+
// apply text font
render::Text::setfont(font->name().c_str(), font->width(), font->height());
-
+
// enable OpenGL textures
gl::enable(GL_TEXTURE_2D);
-
+
// determine the width and height of the text
// FIXME support multiline text
float text_height = 1.0f * font->height();
float text_width = (float) aux::text_strip(text).size() * font->width();
-
+
// calculate drawing position
math::Vector2f v(location);
-
+
switch (align_horizontal) {
case AlignLeft:
v[0] += font->width();
@@ -122,36 +123,36 @@ void label(const math::Vector2f &location, const math::Vector2f &size, const Fon
v[0] += size.width() - text_width - font->width();
break;
}
-
+
switch (align_vertical) {
case AlignTop:
- v[1] += font->height()*0.5f;
+ v[1] += font->height() * 0.5f;
break;
case AlignVCenter:
v[1] += (size.height() - text_height) / 2.0f;
break;
case AlignBottom:
- v[1] += size.height() - text_height - font->height()*0.5f;
+ v[1] += size.height() - text_height - font->height() * 0.5f;
break;
}
-
+
render::Text::draw(v.x(), v.y(), text);
-
+
// disable OpenGL textures
gl::disable(GL_TEXTURE_2D);
-
+
}
// draw unaligned text
void text(const math::Vector2f &location, const math::Vector2f &size, const Font *font, const std::string &text)
{
render::Text::setfont(font->name().c_str(), font->width(), font->height());
-
+
// enable OpenGL textures
gl::enable(GL_TEXTURE_2D);
-
+
render::Text::draw(location.x(), location.y(), text);
-
+
// disable OpenGL textures
gl::disable(GL_TEXTURE_2D);
}
@@ -161,12 +162,12 @@ void text(const math::Vector2f &location, const math::Vector2f &size, const Font
{
render::Text::setfont(font->name().c_str(), font->width(), font->height());
-
+
// enable OpenGL textures
gl::enable(GL_TEXTURE_2D);
-
+
render::Text::draw(location.x(), location.y(), textstream);
-
+
// disable OpenGL textures
gl::disable(GL_TEXTURE_2D);
}