delete unnecessary line shader program

This commit is contained in:
gazer 2017-06-05 19:55:36 +03:00
parent e2d03ebe93
commit 6970eb3120
1 changed files with 5 additions and 31 deletions

View File

@ -515,14 +515,14 @@ class SolidFillProgram : GLProgram {
glEnableVertexAttribArray(colAttrLocation);
}
bool drawBatch(int length, int start) {
bool drawBatch(int length, int start, bool areLines = false) {
if(!check())
return false;
beforeExecute();
vao.bind();
checkgl!glDrawElements(GL_TRIANGLES, cast(int)length, GL_UNSIGNED_INT, cast(void*)(start * 4));
checkgl!glDrawElements(areLines ? GL_LINES : GL_TRIANGLES, cast(int)length, GL_UNSIGNED_INT, cast(void*)(start * 4));
return true;
}
@ -533,20 +533,6 @@ class SolidFillProgram : GLProgram {
}
}
class LineProgram : SolidFillProgram {
override bool drawBatch(int length, int start) {
if(!check())
return false;
beforeExecute();
vao.bind();
checkgl!glDrawElements(GL_LINES, cast(int)length, GL_UNSIGNED_INT, cast(void*)(start * 4));
return true;
}
}
class TextureProgram : SolidFillProgram {
@property override string vertexSource() {
return q{
@ -772,11 +758,10 @@ final class GLSupport {
OpenGLQueue _queue;
SolidFillProgram _solidFillProgram;
LineProgram _lineProgram;
TextureProgram _textureProgram;
@property bool valid() {
return _legacyMode || _textureProgram && _solidFillProgram && _lineProgram;
return _legacyMode || _textureProgram && _solidFillProgram;
}
bool initShaders() {
@ -787,12 +772,6 @@ final class GLSupport {
if (!_solidFillProgram.compile())
return false;
}
if (_lineProgram is null) {
Log.v("Compiling line program");
_lineProgram = new LineProgram();
if (!_lineProgram.compile())
return false;
}
if (_textureProgram is null) {
Log.v("Compiling texture program");
_textureProgram = new TextureProgram();
@ -809,10 +788,6 @@ final class GLSupport {
destroy(_solidFillProgram);
_solidFillProgram = null;
}
if (_lineProgram !is null) {
destroy(_lineProgram);
_lineProgram = null;
}
if (_textureProgram !is null) {
destroy(_textureProgram);
_textureProgram = null;
@ -843,7 +818,6 @@ final class GLSupport {
_solidFillProgram.createVAO(vertices.length);
vbo.bind();
ebo.bind();
_lineProgram.vao = _solidFillProgram.vao;
_textureProgram.createVAO(vertices.length, colors.length);
vbo.bind();
ebo.bind();
@ -883,8 +857,8 @@ final class GLSupport {
glDisable(GL_BLEND);
}
} else {
if (_lineProgram !is null) {
_lineProgram.drawBatch(length, start);
if (_solidFillProgram !is null) {
_solidFillProgram.drawBatch(length, start, true);
} else
Log.e("No program");
}