platform initialization/deinitialization refactoring

This commit is contained in:
Vadim Lopatin 2015-03-27 11:25:42 +03:00
parent d096aa3083
commit c54da25549
3 changed files with 24 additions and 14 deletions

View File

@ -70,7 +70,7 @@
<doXGeneration>1</doXGeneration>
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
<debuglevel>0</debuglevel>
<debugids>DebugFocus</debugids>
<debugids>DebugFocus FontResources</debugids>
<versionlevel>0</versionlevel>
<versionids>EmbedStandardResources Unicode USE_FREETYPE USE_OPENGL</versionids>
<dump_source>0</dump_source>

View File

@ -1532,6 +1532,12 @@ void releaseResourcesOnAppExit() {
//
debug setAppShuttingDownFlag();
debug {
if (Widget.instanceCount() > 0) {
Log.e("Non-zero Widget instance count when exiting: ", Widget.instanceCount);
}
}
currentTheme = null;
drawableCache = null;
imageCache = null;
@ -1544,9 +1550,6 @@ void releaseResourcesOnAppExit() {
if (Style.instanceCount > 0) {
Log.e("Non-zero Style instance count when exiting: ", Style.instanceCount);
}
if (Widget.instanceCount() > 0) {
Log.e("Non-zero Widget instance count when exiting: ", Widget.instanceCount);
}
if (ImageDrawable.instanceCount > 0) {
Log.e("Non-zero ImageDrawable instance count when exiting: ", ImageDrawable.instanceCount);
}

View File

@ -161,7 +161,7 @@ class Win32Window : Window {
version (USE_OPENGL) {
HGLRC _hGLRC; // opengl context
HPALETTE _hPalette;
GLSupport _gl;
//GLSupport _gl;
}
dstring _caption;
Win32ColorDrawBuf _drawbuf;
@ -178,7 +178,9 @@ class Win32Window : Window {
_dy = 400;
_platform = platform;
version (USE_OPENGL) {
_gl = new GLSupport();
//_gl = new GLSupport();
if (!_glSupport)
_glSupport = new GLSupport();
}
_caption = windowCaption;
_flags = flags;
@ -213,7 +215,7 @@ class Win32Window : Window {
if (_hGLRC) {
wglMakeCurrent(hDC, _hGLRC);
_glSupport = _gl;
//_glSupport = _gl;
if (!DERELICT_GL3_RELOADED) {
// run this code only once
@ -221,24 +223,29 @@ class Win32Window : Window {
try {
import derelict.opengl3.gl3;
DerelictGL3.reload();
// successful
if (glSupport.initShaders()) {
if (glSupport.valid || glSupport.initShaders()) {
setOpenglEnabled();
useOpengl = true;
} else {
Log.e("Failed to compile shaders");
}
destroy(_glSupport);
_glSupport = null;
} catch (Exception e) {
Log.e("Derelict exception", e);
}
} else {
if (glSupport.initShaders()) {
if (glSupport.valid || glSupport.initShaders()) {
setOpenglEnabled();
useOpengl = true;
} else {
Log.e("Failed to compile shaders");
}
}
wglMakeCurrent(hDC, null);
}
} else {
Log.e("Pixelformat failed");
@ -266,7 +273,7 @@ class Win32Window : Window {
//scope(exit) EndPaint(_hwnd, &ps);
HDC hdc = GetDC(_hwnd);
wglMakeCurrent(hdc, _hGLRC);
_glSupport = _gl;
//_glSupport = _gl;
glDisable(GL_DEPTH_TEST);
glViewport(0, 0, _dx, _dy);
float a = 1.0f;
@ -303,10 +310,10 @@ class Win32Window : Window {
version (USE_OPENGL) {
import derelict.opengl3.wgl;
if (_hGLRC) {
glSupport.uninitShaders();
destroy(_glSupport);
_glSupport = null;
_gl = null;
//glSupport.uninitShaders();
//destroy(_glSupport);
//_glSupport = null;
//_gl = null;
wglMakeCurrent (null, null) ;
wglDeleteContext(_hGLRC);
_hGLRC = null;