From 9446401bb4e50045970339cccd400dcdc879745d Mon Sep 17 00:00:00 2001 From: gazer Date: Fri, 29 Jan 2016 06:07:19 +0300 Subject: [PATCH] fix nvidia problem --- src/dlangui/graphics/gldrawbuf.d | 2 +- src/dlangui/graphics/glsupport.d | 32 +++++++++++++++----------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/dlangui/graphics/gldrawbuf.d b/src/dlangui/graphics/gldrawbuf.d index 36bd70d5..c8b02136 100644 --- a/src/dlangui/graphics/gldrawbuf.d +++ b/src/dlangui/graphics/gldrawbuf.d @@ -71,7 +71,6 @@ class GLDrawBuf : DrawBuf, GLConfigCallback { _scene.reset(); } _scene = new Scene(this); - glSupport.prepareShaders(); } /// reserved for hardware-accelerated drawing - ends drawing batch @@ -79,6 +78,7 @@ class GLDrawBuf : DrawBuf, GLConfigCallback { glSupport.setOrthoProjection(Rect(0, 0, _dx, _dy), Rect(0, 0, _dx, _dy)); _scene.draw(); GLProgram.unbind(); + glSupport.destroyBuffers(); glSupport.flushGL(); destroy(_scene); _scene = null; diff --git a/src/dlangui/graphics/glsupport.d b/src/dlangui/graphics/glsupport.d index 496ccc1d..338d5ee9 100644 --- a/src/dlangui/graphics/glsupport.d +++ b/src/dlangui/graphics/glsupport.d @@ -292,13 +292,8 @@ class SolidFillProgram : GLProgram { VAO vao; VBO vbo; bool needToCreateVAO = true; - void createVAO(float[] vertices, float[] colors) { - if(vao) - destroy(vao); + protected void createVAO(float[] vertices, float[] colors) { vao = new VAO; - - if(vbo) - destroy(vbo); vbo = new VBO; glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, 0, cast(void*) 0); @@ -310,7 +305,7 @@ class SolidFillProgram : GLProgram { needToCreateVAO = false; } - void beforeExecute() { + protected void beforeExecute() { glEnable(GL_BLEND); checkgl!glDisable(GL_CULL_FACE); checkgl!glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -334,6 +329,14 @@ class SolidFillProgram : GLProgram { vao.unbind(); return true; } + + void destroyBuffers() { + destroy(vao); + destroy(vbo); + vao = null; + vbo = null; + needToCreateVAO = true; + } } class LineProgram : SolidFillProgram { @@ -392,13 +395,8 @@ class TextureProgram : SolidFillProgram { return res && texCoordLocation >= 0; } - void createVAO(float[] vertices, float[] colors, float[] texcoords) { - if(vao) - destroy(vao); + protected void createVAO(float[] vertices, float[] colors, float[] texcoords) { vao = new VAO; - - if(vbo) - destroy(vbo); vbo = new VBO; glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, 0, cast(void*) 0); @@ -598,10 +596,10 @@ final class GLSupport { return true; } - void prepareShaders() { - _solidFillProgram.needToCreateVAO = true; - _lineProgram.needToCreateVAO = true; - _textureProgram.needToCreateVAO = true; + void destroyBuffers() { + _solidFillProgram.destroyBuffers(); + _lineProgram.destroyBuffers(); + _textureProgram.destroyBuffers(); } void setRotation(int x, int y, int rotationAngle) {