begin implementing OpenGL 1.0 engine

* option to pass -opengl1 or -opengl2 as argument
* note that with this commit there are a lot of graphics regressions and the master will remaing unstable for a while
* shaders disabled for a while
This commit is contained in:
Eduardo Bart
2012-04-18 20:03:43 -03:00
parent a4a00a49fe
commit 58d76e255d
46 changed files with 1303 additions and 510 deletions

View File

@@ -47,7 +47,7 @@ void UIFrameCounter::drawSelf()
}
m_frameCount++;
g_painter.setColor(Color::white);
g_painter->setColor(Color::white);
m_font->drawText(m_fpsText, m_rect, m_align);
}

View File

@@ -53,9 +53,9 @@ void UITextEdit::drawSelf()
int textLength = m_text.length();
const TexturePtr& texture = m_font->getTexture();
g_painter.setColor(m_color);
g_painter->setColor(m_color);
for(int i=0;i<textLength;++i)
g_painter.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) {
@@ -69,7 +69,7 @@ void UITextEdit::drawSelf()
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_painter.drawFilledRect(cursorRect);
g_painter->drawFilledRect(cursorRect);
} else if(g_clock.ticksElapsed(m_cursorTicks) >= 2*delay) {
m_cursorTicks = g_clock.ticks();
}

View File

@@ -54,19 +54,19 @@ UIWidget::~UIWidget()
void UIWidget::draw(const Rect& visibleRect)
{
if(m_clipping)
g_painter.setClipRect(visibleRect);
g_painter->setClipRect(visibleRect);
drawSelf();
if(m_children.size() > 0) {
if(m_clipping)
g_painter.setClipRect(visibleRect.intersection(getClippingRect()));
g_painter->setClipRect(visibleRect.intersection(getClippingRect()));
drawChildren(visibleRect);
}
if(m_clipping)
g_painter.resetClipRect();
g_painter->resetClipRect();
}
void UIWidget::drawSelf()
@@ -97,22 +97,22 @@ void UIWidget::drawChildren(const Rect& visibleRect)
continue;
// store current graphics opacity
float oldOpacity = g_painter.getOpacity();
float oldOpacity = g_painter->getOpacity();
// decrease to self opacity
if(child->getOpacity() < oldOpacity)
g_painter.setOpacity(child->getOpacity());
g_painter->setOpacity(child->getOpacity());
child->draw(childVisibleRect);
// debug draw box
if(g_ui.isDrawingDebugBoxes()) {
g_painter.setColor(Color::green);
g_painter.drawBoundingRect(child->getRect());
g_painter->setColor(Color::green);
g_painter->drawBoundingRect(child->getRect());
}
//g_fonts.getDefaultFont()->renderText(child->getId(), child->getPosition() + Point(2, 0), Color::red);
g_painter.setOpacity(oldOpacity);
g_painter->setOpacity(oldOpacity);
}
}

View File

@@ -323,8 +323,8 @@ void UIWidget::drawBackground(const Rect& screenCoords)
drawRect.translate(m_backgroundRect.topLeft());
if(m_backgroundRect.isValid())
drawRect.resize(m_backgroundRect.size());
g_painter.setColor(m_backgroundColor);
g_painter.drawFilledRect(drawRect);
g_painter->setColor(m_backgroundColor);
g_painter->drawFilledRect(drawRect);
}
}
@@ -332,31 +332,31 @@ void UIWidget::drawBorder(const Rect& screenCoords)
{
// top
if(m_borderWidth.top > 0) {
g_painter.setColor(m_borderColor.top);
g_painter->setColor(m_borderColor.top);
Rect borderRect(screenCoords.topLeft(), screenCoords.width(), m_borderWidth.top);
g_painter.drawFilledRect(borderRect);
g_painter->drawFilledRect(borderRect);
}
// right
if(m_borderWidth.right > 0) {
g_painter.setColor(m_borderColor.right);
g_painter->setColor(m_borderColor.right);
Rect borderRect(screenCoords.topRight() - Point(m_borderWidth.right - 1, 0), m_borderWidth.right, screenCoords.height());
g_painter.drawFilledRect(borderRect);
g_painter->drawFilledRect(borderRect);
}
// bottom
if(m_borderWidth.bottom > 0) {
g_painter.setColor(m_borderColor.bottom);
g_painter->setColor(m_borderColor.bottom);
Rect borderRect(screenCoords.bottomLeft() - Point(0, m_borderWidth.bottom - 1), screenCoords.width(), m_borderWidth.bottom);
g_painter.drawFilledRect(borderRect);
g_painter->drawFilledRect(borderRect);
}
// left
if(m_borderWidth.left > 0) {
g_painter.setColor(m_borderColor.left);
g_painter->setColor(m_borderColor.left);
Rect borderRect(screenCoords.topLeft(), m_borderWidth.left, screenCoords.height());
g_painter.drawFilledRect(borderRect);
g_painter->drawFilledRect(borderRect);
}
}
@@ -372,8 +372,8 @@ void UIWidget::drawIcon(const Rect& screenCoords)
drawRect.resize(m_icon->getSize());
drawRect.moveCenter(screenCoords.center());
}
g_painter.setColor(m_iconColor);
g_painter.drawTexturedRect(drawRect, m_icon);
g_painter->setColor(m_iconColor);
g_painter->drawTexturedRect(drawRect, m_icon);
}
}

View File

@@ -167,8 +167,8 @@ void UIWidget::drawImage(const Rect& screenCoords)
m_imageTexture->setSmooth(m_imageSmooth);
g_painter.setColor(m_imageColor);
g_painter.drawTextureCoords(m_imageCoordsBuffer, m_imageTexture);
g_painter->setColor(m_imageColor);
g_painter->drawTextureCoords(m_imageCoordsBuffer, m_imageTexture);
}
void UIWidget::setImageSource(const std::string& source)

View File

@@ -87,8 +87,8 @@ void UIWidget::drawText(const Rect& screenCoords)
m_font->calculateDrawTextCoords(m_textCoordsBuffer, m_drawText, screenCoords.translated(m_textOffset), m_textAlign);
}
g_painter.setColor(m_color);
g_painter.drawTextureCoords(m_textCoordsBuffer, m_font->getTexture());
g_painter->setColor(m_color);
g_painter->drawTextureCoords(m_textCoordsBuffer, m_font->getTexture());
}
void UIWidget::onTextChange(const std::string& text, const std::string& oldText)