Merge pull request #165 from g4z3r/gl

fix nvidia problem
This commit is contained in:
Vadim Lopatin 2016-01-29 07:01:24 +03:00
commit 692d9e7c12
2 changed files with 16 additions and 18 deletions

View File

@ -71,7 +71,6 @@ class GLDrawBuf : DrawBuf, GLConfigCallback {
_scene.reset(); _scene.reset();
} }
_scene = new Scene(this); _scene = new Scene(this);
glSupport.prepareShaders();
} }
/// reserved for hardware-accelerated drawing - ends drawing batch /// 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)); glSupport.setOrthoProjection(Rect(0, 0, _dx, _dy), Rect(0, 0, _dx, _dy));
_scene.draw(); _scene.draw();
GLProgram.unbind(); GLProgram.unbind();
glSupport.destroyBuffers();
glSupport.flushGL(); glSupport.flushGL();
destroy(_scene); destroy(_scene);
_scene = null; _scene = null;

View File

@ -292,13 +292,8 @@ class SolidFillProgram : GLProgram {
VAO vao; VAO vao;
VBO vbo; VBO vbo;
bool needToCreateVAO = true; bool needToCreateVAO = true;
void createVAO(float[] vertices, float[] colors) { protected void createVAO(float[] vertices, float[] colors) {
if(vao)
destroy(vao);
vao = new VAO; vao = new VAO;
if(vbo)
destroy(vbo);
vbo = new VBO; vbo = new VBO;
glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, 0, cast(void*) 0); glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, 0, cast(void*) 0);
@ -310,7 +305,7 @@ class SolidFillProgram : GLProgram {
needToCreateVAO = false; needToCreateVAO = false;
} }
void beforeExecute() { protected void beforeExecute() {
glEnable(GL_BLEND); glEnable(GL_BLEND);
checkgl!glDisable(GL_CULL_FACE); checkgl!glDisable(GL_CULL_FACE);
checkgl!glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); checkgl!glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -334,6 +329,14 @@ class SolidFillProgram : GLProgram {
vao.unbind(); vao.unbind();
return true; return true;
} }
void destroyBuffers() {
destroy(vao);
destroy(vbo);
vao = null;
vbo = null;
needToCreateVAO = true;
}
} }
class LineProgram : SolidFillProgram { class LineProgram : SolidFillProgram {
@ -392,13 +395,8 @@ class TextureProgram : SolidFillProgram {
return res && texCoordLocation >= 0; return res && texCoordLocation >= 0;
} }
void createVAO(float[] vertices, float[] colors, float[] texcoords) { protected void createVAO(float[] vertices, float[] colors, float[] texcoords) {
if(vao)
destroy(vao);
vao = new VAO; vao = new VAO;
if(vbo)
destroy(vbo);
vbo = new VBO; vbo = new VBO;
glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, 0, cast(void*) 0); glVertexAttribPointer(vertexLocation, 3, GL_FLOAT, GL_FALSE, 0, cast(void*) 0);
@ -598,10 +596,10 @@ final class GLSupport {
return true; return true;
} }
void prepareShaders() { void destroyBuffers() {
_solidFillProgram.needToCreateVAO = true; _solidFillProgram.destroyBuffers();
_lineProgram.needToCreateVAO = true; _lineProgram.destroyBuffers();
_textureProgram.needToCreateVAO = true; _textureProgram.destroyBuffers();
} }
void setRotation(int x, int y, int rotationAngle) { void setRotation(int x, int y, int rotationAngle) {