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