more opengl graphics fixes

master
Eduardo Bart 12 years ago
parent cde81666b8
commit 257f652bb7

@ -181,8 +181,6 @@ function Terminal.addLine(text, color)
local numLines = terminalBuffer:getChildCount() + 1 local numLines = terminalBuffer:getChildCount() + 1
if numLines > MaxLogLines then if numLines > MaxLogLines then
terminalBuffer:getChildByIndex(1):destroy() terminalBuffer:getChildByIndex(1):destroy()
else
terminalBuffer:setHeight(terminalBuffer:getHeight() + LabelHeight)
end end
-- create new line label -- create new line label

@ -14,7 +14,7 @@ UIWindow
id: terminalBuffer id: terminalBuffer
layout: layout:
type: verticalBox type: verticalBox
align-bottom: true fit-children: true
focusable: false focusable: false
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right

@ -70,8 +70,8 @@ TopPanel
anchors.right: parent.right anchors.right: parent.right
UILabel UILabel
size: 68 16
text-align: right text-align: right
text-auto-resize: true
color: white color: white
id: frameCounter id: frameCounter
anchors.top: parent.top anchors.top: parent.top

@ -201,6 +201,9 @@ void Application::run()
if(redraw) { if(redraw) {
g_graphics.beginRender(); g_graphics.beginRender();
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
Rect viewportRect(0, 0, g_graphics.getViewportSize()); Rect viewportRect(0, 0, g_graphics.getViewportSize());
// draw the foreground into a texture // draw the foreground into a texture
@ -214,8 +217,8 @@ void Application::run()
m_foreground->copyFromScreen(viewportRect); m_foreground->copyFromScreen(viewportRect);
} }
//glClearColor(0,0,0,0); glClearColor(0,0,0,0);
//glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
// draw background (animated stuff) // draw background (animated stuff)
m_backgroundFrameCounter.processNextFrame(); m_backgroundFrameCounter.processNextFrame();
@ -223,6 +226,7 @@ void Application::run()
// draw the foreground (steady stuff) // draw the foreground (steady stuff)
g_painter->setColor(Color::white); g_painter->setColor(Color::white);
g_painter->setOpacity(1.0);
g_painter->drawTexturedRect(viewportRect, m_foreground, viewportRect); g_painter->drawTexturedRect(viewportRect, m_foreground, viewportRect);
g_graphics.endRender(); g_graphics.endRender();

@ -80,8 +80,9 @@ void Logger::fireOldMessages()
{ {
if(m_onLog) { if(m_onLog) {
auto backup = m_logMessages; auto backup = m_logMessages;
for(const LogMessage& logMessage : backup) for(const LogMessage& logMessage : backup) {
m_onLog(logMessage.level, logMessage.message, logMessage.when); m_onLog(logMessage.level, logMessage.message, logMessage.when);
}
} }
} }

@ -48,7 +48,7 @@ public:
void info(const std::string& what) { log(Fw::LogInfo, what); } void info(const std::string& what) { log(Fw::LogInfo, what); }
void warning(const std::string& what) { log(Fw::LogWarning, what); } void warning(const std::string& what) { log(Fw::LogWarning, what); }
void error(const std::string& what) { log(Fw::LogError, what); } void error(const std::string& what) { log(Fw::LogError, what); }
void fatal(const std::string& what) { log(Fw::LogError, what); } void fatal(const std::string& what) { log(Fw::LogFatal, what); }
void fireOldMessages(); void fireOldMessages();
void setLogFile(const std::string& file); void setLogFile(const std::string& file);

@ -87,12 +87,17 @@ void Graphics::init()
*/ */
// determine max texture size // determine max texture size
static GLint maxTextureSize = -1; GLint maxTextureSize = 0;
if(maxTextureSize == -1) glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
if(m_maxTextureSize == -1 || m_maxTextureSize > maxTextureSize) if(m_maxTextureSize == -1 || m_maxTextureSize > maxTextureSize)
m_maxTextureSize = maxTextureSize; m_maxTextureSize = maxTextureSize;
// check if we have alpha channel in the color buffer, because we need alpha channel for glCopyTexSubImage2D
GLint alphaBits = 0;
glGetIntegerv(GL_ALPHA_BITS, &alphaBits);
if(alphaBits <= 0)
g_logger.fatal("OpenGL visual doesn't have an alpha buffer");
selectPainterEngine(m_prefferedPainterEngine); selectPainterEngine(m_prefferedPainterEngine);
m_emptyTexture = TexturePtr(new Texture); m_emptyTexture = TexturePtr(new Texture);
} }

@ -34,7 +34,7 @@ static const std::string glslMainWithTexCoordsVertexShader = "\n\
void main()\n\ void main()\n\
{\n\ {\n\
gl_Position = calculatePosition();\n\ gl_Position = calculatePosition();\n\
texCoord = textureMatrix * vec3(a_texCoord,1);\n\ texCoord = (textureMatrix * vec3(a_texCoord,1)).xy;\n\
}\n"; }\n";
static std::string glslPositionOnlyVertexShader = "\n\ static std::string glslPositionOnlyVertexShader = "\n\

@ -302,7 +302,7 @@ void WIN32Window::internalChooseGLVisual()
1, 1,
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA, PFD_TYPE_RGBA,
24, // Select Our Color Depth 32, // Select Our Color Depth
8, 0, 8, 0, 8, 0, // Color Bits Ignored 8, 0, 8, 0, 8, 0, // Color Bits Ignored
8, // Alpha Buffer Bits 8, // Alpha Buffer Bits
0, // Shift Bit Ignored 0, // Shift Bit Ignored

@ -387,7 +387,10 @@ void X11Window::internalChooseGLVisual()
static int attrList[] = { static int attrList[] = {
GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_DOUBLEBUFFER, True, GLX_DOUBLEBUFFER, True,
GLX_ALPHA_SIZE, 1, GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_ALPHA_SIZE, 8,
None None
}; };

@ -26,6 +26,7 @@
#include <framework/platform/platformwindow.h> #include <framework/platform/platformwindow.h>
#include <framework/core/clock.h> #include <framework/core/clock.h>
#include <framework/otml/otmlnode.h> #include <framework/otml/otmlnode.h>
#include <framework/application.h>
UITextEdit::UITextEdit() UITextEdit::UITextEdit()
{ {
@ -252,6 +253,7 @@ void UITextEdit::setCursorPos(int pos)
else else
m_cursorPos = pos; m_cursorPos = pos;
update(); update();
g_app->repaint();
} }
} }
@ -514,4 +516,5 @@ bool UITextEdit::onMousePress(const Point& mousePos, Fw::MouseButton button)
void UITextEdit::blinkCursor() void UITextEdit::blinkCursor()
{ {
m_cursorTicks = g_clock.millis(); m_cursorTicks = g_clock.millis();
g_app->repaint();
} }

@ -811,7 +811,6 @@ bool UIWidget::setRect(const Rect& rect)
if(rect == oldRect) if(rect == oldRect)
return false; return false;
g_app->repaint();
m_rect = rect; m_rect = rect;
// updates own layout // updates own layout
@ -1353,6 +1352,8 @@ void UIWidget::onStyleApply(const std::string& styleName, const OTMLNodePtr& sty
parseBaseStyle(styleNode); parseBaseStyle(styleNode);
parseImageStyle(styleNode); parseImageStyle(styleNode);
parseTextStyle(styleNode); parseTextStyle(styleNode);
g_app->repaint();
} }
void UIWidget::onGeometryChange(const Rect& oldRect, const Rect& newRect) void UIWidget::onGeometryChange(const Rect& oldRect, const Rect& newRect)
@ -1367,6 +1368,8 @@ void UIWidget::onGeometryChange(const Rect& oldRect, const Rect& newRect)
} }
callLuaField("onGeometryChange", oldRect, newRect); callLuaField("onGeometryChange", oldRect, newRect);
g_app->repaint();
} }
void UIWidget::onLayoutUpdate() void UIWidget::onLayoutUpdate()

@ -25,6 +25,7 @@
#include <framework/graphics/fontmanager.h> #include <framework/graphics/fontmanager.h>
#include <framework/graphics/painter.h> #include <framework/graphics/painter.h>
#include <framework/graphics/framebuffer.h> #include <framework/graphics/framebuffer.h>
#include <framework/application.h>
void UIWidget::initText() void UIWidget::initText()
{ {
@ -93,6 +94,7 @@ void UIWidget::drawText(const Rect& screenCoords)
void UIWidget::onTextChange(const std::string& text, const std::string& oldText) void UIWidget::onTextChange(const std::string& text, const std::string& oldText)
{ {
g_app->repaint();
callLuaField("onTextChange", text, oldText); callLuaField("onTextChange", text, oldText);
} }

Loading…
Cancel
Save