use GLSL shaders

This commit is contained in:
Eduardo Bart
2011-12-06 22:31:55 -02:00
parent cf0aab6d4d
commit 7eead50806
64 changed files with 1219 additions and 630 deletions

View File

@@ -40,9 +40,9 @@ void UIButton::render()
if(m_icon) {
Rect iconRect;
iconRect.setSize(m_icon->getSize());
iconRect.resize(m_icon->getSize());
iconRect.moveCenter(m_rect.center());
g_graphics.drawTexturedRect(iconRect, m_icon);
g_painter.drawTexturedRect(iconRect, m_icon);
}
Rect textRect = m_rect;

View File

@@ -38,10 +38,10 @@ void UICheckBox::render()
{
if(m_image) {
Rect boxRect;
boxRect.setSize(m_boxSize);
boxRect.resize(m_boxSize);
boxRect.moveLeft(m_rect.left());
boxRect.moveVerticalCenter(m_rect.verticalCenter());
g_graphics.bindColor(m_backgroundColor);
g_painter.setColor(m_backgroundColor);
m_image->draw(boxRect);
}

View File

@@ -47,9 +47,9 @@ void UILineEdit::render()
int textLength = m_text.length();
const TexturePtr& texture = m_font->getTexture();
g_graphics.bindColor(m_foregroundColor);
g_painter.setColor(m_foregroundColor);
for(int i=0;i<textLength;++i)
g_graphics.drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]);
g_painter.drawTexturedRect(m_glyphsCoords[i], texture, m_glyphsTexCoords[i]);
// render cursor
if(isExplicitlyEnabled() && (isActive() || m_alwaysActive) && m_cursorPos >= 0) {
@@ -63,7 +63,7 @@ void UILineEdit::render()
cursorRect = Rect(m_drawArea.left()-1, m_drawArea.top(), 1, m_font->getGlyphHeight());
else
cursorRect = Rect(m_glyphsCoords[m_cursorPos-1].right(), m_glyphsCoords[m_cursorPos-1].top(), 1, m_font->getGlyphHeight());
g_graphics.drawFilledRect(cursorRect);
g_painter.drawFilledRect(cursorRect);
} else if(g_clock.ticksElapsed(m_cursorTicks) >= 2*delay) {
m_cursorTicks = g_clock.ticks();
}

View File

@@ -25,6 +25,7 @@
#include <framework/otml/otml.h>
#include <framework/graphics/graphics.h>
#include <framework/platform/platformwindow.h>
UIManager g_ui;
@@ -33,7 +34,7 @@ void UIManager::init()
// creates root widget
m_rootWidget = UIWidget::create<UIWidget>();
m_rootWidget->setId("root");
m_rootWidget->resize(g_graphics.getScreenSize());
m_rootWidget->resize(g_window.getSize());
}
void UIManager::terminate()
@@ -50,7 +51,7 @@ void UIManager::render()
void UIManager::resize(const Size& size)
{
m_rootWidget->resize(g_graphics.getScreenSize());
m_rootWidget->resize(g_window.getSize());
}
void UIManager::inputEvent(const InputEvent& event)
@@ -174,12 +175,15 @@ UIWidgetPtr UIManager::loadWidgetFromOTML(const OTMLNodePtr& widgetNode, const U
if(parent)
parent->addChild(widget);
widget->setStyleFromNode(styleNode);
if(widget) {
widget->setStyleFromNode(styleNode);
for(const OTMLNodePtr& childNode : widgetNode->children()) {
if(!childNode->isUnique())
loadWidgetFromOTML(childNode, widget);
}
for(const OTMLNodePtr& childNode : widgetNode->children()) {
if(!childNode->isUnique())
loadWidgetFromOTML(childNode, widget);
}
} else
logError("Unable to create widget of type '", widgetType, "'");
return widget;
}

View File

@@ -35,14 +35,14 @@ void UIProgressBar::render()
{
UIWidget::render();
g_graphics.bindColor(m_foregroundColor);
g_graphics.drawBoundingRect(m_rect, 1);
g_painter.setColor(m_foregroundColor);
g_painter.drawBoundingRect(m_rect, 1);
Rect fillRect = m_rect.expanded(-1);
fillRect.setWidth(fillRect.width() * m_percent / 100.0);
g_graphics.bindColor(m_backgroundColor);
g_graphics.drawFilledRect(fillRect);
g_painter.setColor(m_backgroundColor);
g_painter.drawFilledRect(fillRect);
}
void UIProgressBar::setPercent(double percent)

View File

@@ -69,7 +69,7 @@ void UIWidget::renderSelf()
{
// draw background
if(m_image) {
g_graphics.bindColor(m_backgroundColor);
g_painter.setColor(m_backgroundColor);
m_image->draw(m_rect);
}
}
@@ -81,20 +81,20 @@ void UIWidget::renderChildren()
// render only visible children with a valid rect inside our rect
if(child->isExplicitlyVisible() && child->getRect().isValid() && child->getRect().intersects(m_rect)) {
// store current graphics opacity
int oldOpacity = g_graphics.getOpacity();
int oldOpacity = g_painter.getOpacity();
// decrease to self opacity
if(child->getOpacity() < oldOpacity)
g_graphics.setOpacity(child->getOpacity());
g_painter.setOpacity(child->getOpacity());
child->render();
// debug draw box
//g_graphics.bindColor(Fw::green);
//g_graphics.drawBoundingRect(child->getRect());
//g_painter.setColor(Fw::green);
//g_painter.drawBoundingRect(child->getRect());
//g_fonts.getDefaultFont()->renderText(child->getId(), child->getPosition() + Point(2, 0), Fw::red);
g_graphics.setOpacity(oldOpacity);
g_painter.setOpacity(oldOpacity);
}
}
}