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 = 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;

View File

@ -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) {