possible fix for issue #72 - GUI is blurry when using retina displays

This commit is contained in:
Vadim Lopatin 2015-03-11 09:12:36 +03:00
parent 3e75395861
commit 0b126d6c4e
1 changed files with 15 additions and 6 deletions

View File

@ -153,6 +153,7 @@ class SDLWindow : Window {
_gl3Reloaded = true; _gl3Reloaded = true;
if (!glSupport.valid && !glSupport.initShaders()) if (!glSupport.valid && !glSupport.initShaders())
_enableOpengl = false; _enableOpengl = false;
fixSize();
} }
} }
} }
@ -162,11 +163,19 @@ class SDLWindow : Window {
Log.e("SDL2: Failed to create renderer"); Log.e("SDL2: Failed to create renderer");
return false; return false;
} }
fixSize();
} }
windowCaption = _caption; windowCaption = _caption;
return true; return true;
} }
void fixSize() {
int w = 0;
int h = 0;
SDL_GetWindowSize(_win, &w, &h);
doResize(w, h);
}
void doResize(int width, int height) { void doResize(int width, int height) {
int w = 0; int w = 0;
int h = 0; int h = 0;
@ -174,7 +183,10 @@ class SDLWindow : Window {
if (w != width || h != height) { if (w != width || h != height) {
Log.d("SDL_GL_GetDrawableSize returned ", w, "x", h, " while resize event reports ", width, "x", height); Log.d("SDL_GL_GetDrawableSize returned ", w, "x", h, " while resize event reports ", width, "x", height);
} }
onResize(w, h); if (w && h)
onResize(w, h);
else
onResize(width, height);
} }
@property uint windowId() { @property uint windowId() {
@ -193,10 +205,7 @@ class SDLWindow : Window {
SDL_ShowWindow(_win); SDL_ShowWindow(_win);
if (_mainWidget) if (_mainWidget)
_mainWidget.setFocus(); _mainWidget.setFocus();
int w = 0; fixSize();
int h = 0;
SDL_GL_GetWindowSize(_win, &w, &h);
doResize(w, h);
} }
/// close window /// close window