fix some graphics issues on Windows virtualbox
This commit is contained in:
parent
4c5d1d0ca5
commit
e35a2e4c79
|
@ -45,7 +45,7 @@ FrameBuffer::FrameBuffer(int width, int height)
|
||||||
m_texture->enableBilinearFilter();
|
m_texture->enableBilinearFilter();
|
||||||
|
|
||||||
// use FBO ext only if supported
|
// 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;
|
m_fallbackOldImp = false;
|
||||||
if(!oglGenFramebuffers) {
|
if(!oglGenFramebuffers) {
|
||||||
oglGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)g_platform.getExtensionProcAddress("glGenFramebuffers");
|
oglGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)g_platform.getExtensionProcAddress("glGenFramebuffers");
|
||||||
|
@ -106,7 +106,7 @@ void FrameBuffer::bind()
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
// clear framebuffer
|
// 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);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,5 +136,5 @@ void FrameBuffer::unbind()
|
||||||
|
|
||||||
void FrameBuffer::draw(const Rect& screenCoords, const Rect& framebufferCoords)
|
void FrameBuffer::draw(const Rect& screenCoords, const Rect& framebufferCoords)
|
||||||
{
|
{
|
||||||
g_graphics.drawTexturedRect(screenCoords, m_texture ,framebufferCoords);
|
g_graphics.drawTexturedRect(screenCoords, m_texture, framebufferCoords);
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,18 +148,18 @@ void Graphics::drawTexturedRect(const Rect& screenCoords,
|
||||||
float textureBottom;
|
float textureBottom;
|
||||||
float textureTop;
|
float textureTop;
|
||||||
float textureLeft;
|
float textureLeft;
|
||||||
|
const Size& textureSize = texture->getGlSize();
|
||||||
|
|
||||||
if(textureCoords.isEmpty()) {
|
if(textureCoords.isEmpty()) {
|
||||||
textureRight = 1.0f;
|
textureRight = texture->getWidth() / (float)textureSize.width();
|
||||||
textureBottom = 1.0f;
|
textureBottom = texture->getHeight() / (float)textureSize.height();
|
||||||
textureTop = 0.0f;
|
textureTop = 0.0f;
|
||||||
textureLeft = 0.0f;
|
textureLeft = 0.0f;
|
||||||
} else {
|
} else {
|
||||||
const Size& textureSize = texture->getGlSize();
|
textureRight = (textureCoords.right() + 1) / (float)textureSize.width();
|
||||||
textureRight = (float)(textureCoords.right() + 1) / textureSize.width();
|
textureBottom = (textureCoords.bottom() + 1) / (float)textureSize.height();
|
||||||
textureBottom = (float)(textureCoords.bottom() + 1) / textureSize.height();
|
textureTop = textureCoords.top() / (float)textureSize.height();
|
||||||
textureTop = (float)textureCoords.top() / textureSize.height();
|
textureLeft = textureCoords.left() / (float)textureSize.width();
|
||||||
textureLeft = (float)textureCoords.left() / textureSize.width();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!m_drawing) {
|
if(!m_drawing) {
|
||||||
|
|
|
@ -72,7 +72,7 @@ uint Texture::internalLoadGLTexture(uchar *pixels, int channels, int width, int
|
||||||
std::vector<uint8> tmp;
|
std::vector<uint8> tmp;
|
||||||
|
|
||||||
// old opengl drivers only accept power of two dimensions
|
// 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;
|
int glWidth = 1;
|
||||||
while(glWidth < width)
|
while(glWidth < width)
|
||||||
glWidth = glWidth << 1;
|
glWidth = glWidth << 1;
|
||||||
|
@ -81,13 +81,12 @@ uint Texture::internalLoadGLTexture(uchar *pixels, int channels, int width, int
|
||||||
while(glHeight < height)
|
while(glHeight < height)
|
||||||
glHeight = glHeight << 1;
|
glHeight = glHeight << 1;
|
||||||
|
|
||||||
if(m_size != m_glSize) {
|
if(m_size != m_glSize && pixels) {
|
||||||
tmp.resize(glHeight*glWidth*channels, 0);
|
tmp.resize(glHeight*glWidth*channels, 0);
|
||||||
if(pixels)
|
for(int y=0; y<height; ++y)
|
||||||
for(int y=0; y<height; ++y)
|
for(int x=0; x<width; ++x)
|
||||||
for(int x=0; x<width; ++x)
|
for(int i=0; i<channels; ++i)
|
||||||
for(int i=0; i<channels; ++i)
|
tmp[y*glWidth*channels+x*channels+i] = pixels[y*width*channels+x*channels+i];
|
||||||
tmp[y*glWidth*channels+x*channels+i] = pixels[y*width*channels+x*channels+i];
|
|
||||||
pixels = &tmp[0];
|
pixels = &tmp[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -419,9 +419,11 @@ bool Platform::isExtensionSupported(const char *ext)
|
||||||
typedef const char* _wglGetExtensionsStringARB(HDC hdc);
|
typedef const char* _wglGetExtensionsStringARB(HDC hdc);
|
||||||
_wglGetExtensionsStringARB *wglGetExtensionsStringARB = (_wglGetExtensionsStringARB*)getExtensionProcAddress("wglGetExtensionsStringARB");
|
_wglGetExtensionsStringARB *wglGetExtensionsStringARB = (_wglGetExtensionsStringARB*)getExtensionProcAddress("wglGetExtensionsStringARB");
|
||||||
|
|
||||||
const char *exts = wglGetExtensionsStringARB(win32.hdc);
|
if(wglGetExtensionsStringARB) {
|
||||||
if(strstr(exts, ext))
|
const char *exts = wglGetExtensionsStringARB(win32.hdc);
|
||||||
return true;
|
if(strstr(exts, ext))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue