diff --git a/SMILEBASIC/graphic.d b/SMILEBASIC/graphic.d index f60d8ff..89cab86 100644 --- a/SMILEBASIC/graphic.d +++ b/SMILEBASIC/graphic.d @@ -90,6 +90,10 @@ class Graphic } void initGraphicPages() { + if (GRP.length != 0 && GRP[0].glTexture/*TODO:gl texture 0?*/) + { + oldGRP = GRP; + } GRP = new GraphicPage[6]; for(int i = 0; i < 4; i++) { @@ -204,6 +208,7 @@ class Graphic } uint gcolor = -1; GraphicPage[] GRP; + GraphicPage[] oldGRP; class Paint { uint[] buffer; @@ -424,6 +429,13 @@ class Graphic { if (!GRP[0].glTexture) { + if (oldGRP.length) + { + foreach (i; oldGRP) + { + i.deleteGL; + } + } initGLGraphicPages(); } if(!drawMessageLength) return; diff --git a/SMILEBASIC/petitcomputer.d b/SMILEBASIC/petitcomputer.d index 554e416..13dce1c 100644 --- a/SMILEBASIC/petitcomputer.d +++ b/SMILEBASIC/petitcomputer.d @@ -132,6 +132,13 @@ class GraphicPage } glBindFramebufferEXT(GL_FRAMEBUFFER, old); } + void deleteGL() + { + glDeleteFramebuffersEXT(1, &buffer); + glDeleteRenderbuffersEXT(1, &render); + glDeleteTextures(1, &glTexture); + buffer = render = glTexture = 0; + } } version(Windows)