check() shader; fixes

This commit is contained in:
gazer 2015-12-12 00:59:52 +03:00
parent 96461c2f1b
commit 2ae058e1f7
1 changed files with 43 additions and 55 deletions

View File

@ -260,6 +260,16 @@ class SolidFillProgram : GLProgram {
};
}
bool check()
{
if (error)
return false;
if (!initialized)
if (!compile())
return false;
return true;
}
void beforeExecute() {
glEnable(GL_BLEND);
glDisable(GL_CULL_FACE);
@ -281,18 +291,9 @@ class SolidFillProgram : GLProgram {
protected GLint matrixLocation;
protected GLint vertexLocation;
protected GLint colAttrLocation;
protected GLuint vertexBuffer;
protected GLuint colAttrBuffer;
override bool initLocations() {
bool res = super.initLocations();
//glGenBuffers(1, &vertexBuffer);
//glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
//glBufferData(GL_ARRAY_BUFFER, float.sizeof * 3 * 6, null, GL_DYNAMIC_DRAW);
//glGenBuffers(1, &colAttrBuffer);
//glBindBuffer(GL_ARRAY_BUFFER, colAttrBuffer);
//glBufferData(GL_ARRAY_BUFFER, float.sizeof * 4 * 6, null, GL_DYNAMIC_DRAW);
matrixLocation = glGetUniformLocation(program, "matrix");
checkError("glGetUniformLocation matrix");
if (matrixLocation == -1)
@ -309,10 +310,7 @@ class SolidFillProgram : GLProgram {
}
bool execute(float[] vertices, float[] colors) {
if (error)
return false;
if (!initialized)
if (!compile())
if(!check())
return false;
beforeExecute();
@ -369,10 +367,7 @@ class SolidFillProgram : GLProgram {
class LineProgram : SolidFillProgram {
override bool execute(float[] vertices, float[] colors) {
if (error)
return false;
if (!initialized)
if (!compile())
if(!check())
return false;
beforeExecute();
@ -467,10 +462,7 @@ class TextureProgram : SolidFillProgram {
}
bool execute(float[] vertices, float[] texcoords, float[] colors, uint textureId, bool linear) {
if (error)
return false;
if (!initialized)
if (!compile())
if(!check())
return false;
beforeExecute();
glActiveTexture(GL_TEXTURE0);
@ -600,10 +592,7 @@ class FontProgram : SolidFillProgram {
}
bool execute(float[] vertices, float[] texcoords, float[] colors, uint textureId, bool linear) {
if (error)
return false;
if (!initialized)
if (!compile())
if(!check())
return false;
beforeExecute();
glActiveTexture(GL_TEXTURE0);
@ -1121,10 +1110,9 @@ class GLSupport {
private uint currentFramebufferId;
/// returns texture ID for buffer, 0 if failed
bool createFramebuffer(ref uint textureId, ref uint framebufferId, int dx, int dy) {
bool createFramebuffer(out uint textureId, out uint framebufferId, int dx, int dy) {
checkError("before createFramebuffer");
bool res = true;
textureId = framebufferId = 0;
textureId = genTexture();
if (!textureId)
return false;