mirror of https://github.com/buggins/dlangui.git
platform initialization/deinitialization refactoring
This commit is contained in:
parent
d096aa3083
commit
c54da25549
|
|
@ -70,7 +70,7 @@
|
||||||
<doXGeneration>1</doXGeneration>
|
<doXGeneration>1</doXGeneration>
|
||||||
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
|
<xfilename>$(IntDir)\$(TargetName).json</xfilename>
|
||||||
<debuglevel>0</debuglevel>
|
<debuglevel>0</debuglevel>
|
||||||
<debugids>DebugFocus</debugids>
|
<debugids>DebugFocus FontResources</debugids>
|
||||||
<versionlevel>0</versionlevel>
|
<versionlevel>0</versionlevel>
|
||||||
<versionids>EmbedStandardResources Unicode USE_FREETYPE USE_OPENGL</versionids>
|
<versionids>EmbedStandardResources Unicode USE_FREETYPE USE_OPENGL</versionids>
|
||||||
<dump_source>0</dump_source>
|
<dump_source>0</dump_source>
|
||||||
|
|
|
||||||
|
|
@ -1532,6 +1532,12 @@ void releaseResourcesOnAppExit() {
|
||||||
//
|
//
|
||||||
debug setAppShuttingDownFlag();
|
debug setAppShuttingDownFlag();
|
||||||
|
|
||||||
|
debug {
|
||||||
|
if (Widget.instanceCount() > 0) {
|
||||||
|
Log.e("Non-zero Widget instance count when exiting: ", Widget.instanceCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
currentTheme = null;
|
currentTheme = null;
|
||||||
drawableCache = null;
|
drawableCache = null;
|
||||||
imageCache = null;
|
imageCache = null;
|
||||||
|
|
@ -1544,9 +1550,6 @@ void releaseResourcesOnAppExit() {
|
||||||
if (Style.instanceCount > 0) {
|
if (Style.instanceCount > 0) {
|
||||||
Log.e("Non-zero Style instance count when exiting: ", Style.instanceCount);
|
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) {
|
if (ImageDrawable.instanceCount > 0) {
|
||||||
Log.e("Non-zero ImageDrawable instance count when exiting: ", ImageDrawable.instanceCount);
|
Log.e("Non-zero ImageDrawable instance count when exiting: ", ImageDrawable.instanceCount);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ class Win32Window : Window {
|
||||||
version (USE_OPENGL) {
|
version (USE_OPENGL) {
|
||||||
HGLRC _hGLRC; // opengl context
|
HGLRC _hGLRC; // opengl context
|
||||||
HPALETTE _hPalette;
|
HPALETTE _hPalette;
|
||||||
GLSupport _gl;
|
//GLSupport _gl;
|
||||||
}
|
}
|
||||||
dstring _caption;
|
dstring _caption;
|
||||||
Win32ColorDrawBuf _drawbuf;
|
Win32ColorDrawBuf _drawbuf;
|
||||||
|
|
@ -178,7 +178,9 @@ class Win32Window : Window {
|
||||||
_dy = 400;
|
_dy = 400;
|
||||||
_platform = platform;
|
_platform = platform;
|
||||||
version (USE_OPENGL) {
|
version (USE_OPENGL) {
|
||||||
_gl = new GLSupport();
|
//_gl = new GLSupport();
|
||||||
|
if (!_glSupport)
|
||||||
|
_glSupport = new GLSupport();
|
||||||
}
|
}
|
||||||
_caption = windowCaption;
|
_caption = windowCaption;
|
||||||
_flags = flags;
|
_flags = flags;
|
||||||
|
|
@ -213,7 +215,7 @@ class Win32Window : Window {
|
||||||
if (_hGLRC) {
|
if (_hGLRC) {
|
||||||
|
|
||||||
wglMakeCurrent(hDC, _hGLRC);
|
wglMakeCurrent(hDC, _hGLRC);
|
||||||
_glSupport = _gl;
|
//_glSupport = _gl;
|
||||||
|
|
||||||
if (!DERELICT_GL3_RELOADED) {
|
if (!DERELICT_GL3_RELOADED) {
|
||||||
// run this code only once
|
// run this code only once
|
||||||
|
|
@ -221,24 +223,29 @@ class Win32Window : Window {
|
||||||
try {
|
try {
|
||||||
import derelict.opengl3.gl3;
|
import derelict.opengl3.gl3;
|
||||||
DerelictGL3.reload();
|
DerelictGL3.reload();
|
||||||
|
|
||||||
// successful
|
// successful
|
||||||
if (glSupport.initShaders()) {
|
if (glSupport.valid || glSupport.initShaders()) {
|
||||||
setOpenglEnabled();
|
setOpenglEnabled();
|
||||||
useOpengl = true;
|
useOpengl = true;
|
||||||
} else {
|
} else {
|
||||||
Log.e("Failed to compile shaders");
|
Log.e("Failed to compile shaders");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
destroy(_glSupport);
|
||||||
|
_glSupport = null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e("Derelict exception", e);
|
Log.e("Derelict exception", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (glSupport.initShaders()) {
|
if (glSupport.valid || glSupport.initShaders()) {
|
||||||
setOpenglEnabled();
|
setOpenglEnabled();
|
||||||
useOpengl = true;
|
useOpengl = true;
|
||||||
} else {
|
} else {
|
||||||
Log.e("Failed to compile shaders");
|
Log.e("Failed to compile shaders");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
wglMakeCurrent(hDC, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.e("Pixelformat failed");
|
Log.e("Pixelformat failed");
|
||||||
|
|
@ -266,7 +273,7 @@ class Win32Window : Window {
|
||||||
//scope(exit) EndPaint(_hwnd, &ps);
|
//scope(exit) EndPaint(_hwnd, &ps);
|
||||||
HDC hdc = GetDC(_hwnd);
|
HDC hdc = GetDC(_hwnd);
|
||||||
wglMakeCurrent(hdc, _hGLRC);
|
wglMakeCurrent(hdc, _hGLRC);
|
||||||
_glSupport = _gl;
|
//_glSupport = _gl;
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
glViewport(0, 0, _dx, _dy);
|
glViewport(0, 0, _dx, _dy);
|
||||||
float a = 1.0f;
|
float a = 1.0f;
|
||||||
|
|
@ -303,10 +310,10 @@ class Win32Window : Window {
|
||||||
version (USE_OPENGL) {
|
version (USE_OPENGL) {
|
||||||
import derelict.opengl3.wgl;
|
import derelict.opengl3.wgl;
|
||||||
if (_hGLRC) {
|
if (_hGLRC) {
|
||||||
glSupport.uninitShaders();
|
//glSupport.uninitShaders();
|
||||||
destroy(_glSupport);
|
//destroy(_glSupport);
|
||||||
_glSupport = null;
|
//_glSupport = null;
|
||||||
_gl = null;
|
//_gl = null;
|
||||||
wglMakeCurrent (null, null) ;
|
wglMakeCurrent (null, null) ;
|
||||||
wglDeleteContext(_hGLRC);
|
wglDeleteContext(_hGLRC);
|
||||||
_hGLRC = null;
|
_hGLRC = null;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue