From e35a2e4c79758eb0f20c45bbf471720f4af9ebbb Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Sun, 30 Oct 2011 21:13:22 -0200 Subject: [PATCH] fix some graphics issues on Windows virtualbox --- src/framework/graphics/framebuffer.cpp | 6 +++--- src/framework/graphics/graphics.cpp | 14 +++++++------- src/framework/graphics/texture.cpp | 13 ++++++------- src/framework/platform/win32platform.cpp | 8 +++++--- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/framework/graphics/framebuffer.cpp b/src/framework/graphics/framebuffer.cpp index 3294b760..a1eb2d09 100644 --- a/src/framework/graphics/framebuffer.cpp +++ b/src/framework/graphics/framebuffer.cpp @@ -45,7 +45,7 @@ FrameBuffer::FrameBuffer(int width, int height) m_texture->enableBilinearFilter(); // use FBO ext only if supported - if(false && g_graphics.isExtensionSupported("GL_ARB_framebuffer_object")) { + if(g_graphics.isExtensionSupported("GL_ARB_framebuffer_object")) { m_fallbackOldImp = false; if(!oglGenFramebuffers) { oglGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)g_platform.getExtensionProcAddress("glGenFramebuffers"); @@ -106,7 +106,7 @@ void FrameBuffer::bind() glLoadIdentity(); // clear framebuffer - glClearColor(0.0, 0.0, 0.0, 0.0); + glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); } @@ -136,5 +136,5 @@ void FrameBuffer::unbind() void FrameBuffer::draw(const Rect& screenCoords, const Rect& framebufferCoords) { - g_graphics.drawTexturedRect(screenCoords, m_texture ,framebufferCoords); + g_graphics.drawTexturedRect(screenCoords, m_texture, framebufferCoords); } diff --git a/src/framework/graphics/graphics.cpp b/src/framework/graphics/graphics.cpp index 3ab0c6bb..cadb10b5 100644 --- a/src/framework/graphics/graphics.cpp +++ b/src/framework/graphics/graphics.cpp @@ -148,18 +148,18 @@ void Graphics::drawTexturedRect(const Rect& screenCoords, float textureBottom; float textureTop; float textureLeft; + const Size& textureSize = texture->getGlSize(); if(textureCoords.isEmpty()) { - textureRight = 1.0f; - textureBottom = 1.0f; + textureRight = texture->getWidth() / (float)textureSize.width(); + textureBottom = texture->getHeight() / (float)textureSize.height(); textureTop = 0.0f; textureLeft = 0.0f; } else { - const Size& textureSize = texture->getGlSize(); - textureRight = (float)(textureCoords.right() + 1) / textureSize.width(); - textureBottom = (float)(textureCoords.bottom() + 1) / textureSize.height(); - textureTop = (float)textureCoords.top() / textureSize.height(); - textureLeft = (float)textureCoords.left() / textureSize.width(); + textureRight = (textureCoords.right() + 1) / (float)textureSize.width(); + textureBottom = (textureCoords.bottom() + 1) / (float)textureSize.height(); + textureTop = textureCoords.top() / (float)textureSize.height(); + textureLeft = textureCoords.left() / (float)textureSize.width(); } if(!m_drawing) { diff --git a/src/framework/graphics/texture.cpp b/src/framework/graphics/texture.cpp index 0bc5d038..e16cdd82 100644 --- a/src/framework/graphics/texture.cpp +++ b/src/framework/graphics/texture.cpp @@ -72,7 +72,7 @@ uint Texture::internalLoadGLTexture(uchar *pixels, int channels, int width, int std::vector tmp; // old opengl drivers only accept power of two dimensions - if(!g_graphics.isExtensionSupported("GL_ARB_texture_non_power_of_two") && pixels) { + if(!g_graphics.isExtensionSupported("GL_ARB_texture_non_power_of_two")) { int glWidth = 1; while(glWidth < width) glWidth = glWidth << 1; @@ -81,13 +81,12 @@ uint Texture::internalLoadGLTexture(uchar *pixels, int channels, int width, int while(glHeight < height) glHeight = glHeight << 1; - if(m_size != m_glSize) { + if(m_size != m_glSize && pixels) { tmp.resize(glHeight*glWidth*channels, 0); - if(pixels) - for(int y=0; y