Skip to content

Commit

Permalink
Merge branch 'redundant2' of https://github.com/ruslansennov/playn
Browse files Browse the repository at this point in the history
  • Loading branch information
samskivert committed Mar 10, 2015
2 parents 0a1a77a + ba91198 commit f29f2b5
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
37 changes: 37 additions & 0 deletions core/src/playn/core/gl/GL20Program.java
Expand Up @@ -71,7 +71,12 @@ public GL20Program(GLContext ctx, GL20 gl, String vertexSource, String fragmentS
public GLShader.Uniform1f getUniform1f(String name) {
final int loc = gl.glGetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform1f() {
private float aCached = 0;
public void bind(float a) {
if(aCached == a) {
return;
}
aCached = a;
gl.glUniform1f(loc, a);
}
};
Expand All @@ -80,7 +85,13 @@ public void bind(float a) {
public GLShader.Uniform2f getUniform2f(String name) {
final int loc = gl.glGetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform2f() {
private float aCached = 0, bCached = 0;
public void bind(float a, float b) {
if(aCached == a && bCached == b) {
return;
}
aCached = a;
bCached = b;
gl.glUniform2f(loc, a, b);
}
};
Expand All @@ -89,7 +100,14 @@ public void bind(float a, float b) {
public GLShader.Uniform3f getUniform3f(String name) {
final int loc = gl.glGetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform3f() {
private float aCached = 0, bCached = 0, cCached = 0;
public void bind(float a, float b, float c) {
if(aCached == a && bCached == b && cCached == c) {
return;
}
aCached = a;
bCached = b;
cCached = c;
gl.glUniform3f(loc, a, b, c);
}
};
Expand All @@ -98,7 +116,15 @@ public void bind(float a, float b, float c) {
public GLShader.Uniform4f getUniform4f(String name) {
final int loc = gl.glGetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform4f() {
private float aCached = 0, bCached = 0, cCached = 0, dCached = 0;
public void bind(float a, float b, float c, float d) {
if(aCached == a && bCached == b && cCached == c && dCached == d) {
return;
}
aCached = a;
bCached = b;
cCached = c;
dCached = d;
gl.glUniform4f(loc, a, b, c, d);
}
};
Expand All @@ -108,7 +134,12 @@ public void bind(float a, float b, float c, float d) {
public GLShader.Uniform1i getUniform1i(String name) {
final int loc = gl.glGetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform1i() {
private int aCached = 0;
public void bind(int a) {
if(aCached == a) {
return;
}
aCached = a;
gl.glUniform1i(loc, a);
}
};
Expand All @@ -117,7 +148,13 @@ public void bind(int a) {
public GLShader.Uniform2i getUniform2i(String name) {
final int loc = gl.glGetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform2i() {
private int aCached = 0, bCached = 0;
public void bind(int a, int b) {
if(aCached == a && bCached == b) {
return;
}
aCached = a;
bCached = b;
gl.glUniform2i(loc, a, b);
}
};
Expand Down
37 changes: 37 additions & 0 deletions ios/src/playn/ios/IOSGLProgram.java
Expand Up @@ -77,7 +77,12 @@ public IOSGLProgram(IOSGLContext ctx, String vertexSource, String fragmentSource
public GLShader.Uniform1f getUniform1f(String name) {
final int loc = GL.GetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform1f() {
private float aCached = 0;
public void bind(float a) {
if(aCached == a) {
return;
}
aCached = a;
GL.Uniform1(loc, a);
}
};
Expand All @@ -86,7 +91,13 @@ public void bind(float a) {
public GLShader.Uniform2f getUniform2f(String name) {
final int loc = GL.GetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform2f() {
private float aCached = 0, bCached = 0;
public void bind(float a, float b) {
if(aCached == a && bCached == b) {
return;
}
aCached = a;
bCached = b;
GL.Uniform2(loc, a, b);
}
};
Expand All @@ -95,7 +106,14 @@ public void bind(float a, float b) {
public GLShader.Uniform3f getUniform3f(String name) {
final int loc = GL.GetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform3f() {
private float aCached = 0, bCached = 0, cCached = 0;
public void bind(float a, float b, float c) {
if(aCached == a && bCached == b && cCached == c) {
return;
}
aCached = a;
bCached = b;
cCached = c;
GL.Uniform3(loc, a, b, c);
}
};
Expand All @@ -104,7 +122,15 @@ public void bind(float a, float b, float c) {
public GLShader.Uniform4f getUniform4f(String name) {
final int loc = GL.GetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform4f() {
private float aCached = 0, bCached = 0, cCached = 0, dCached = 0;
public void bind(float a, float b, float c, float d) {
if(aCached == a && bCached == b && cCached == c && dCached == d) {
return;
}
aCached = a;
bCached = b;
cCached = c;
dCached = d;
GL.Uniform4(loc, a, b, c, d);
}
};
Expand All @@ -113,7 +139,12 @@ public void bind(float a, float b, float c, float d) {
public GLShader.Uniform1i getUniform1i(String name) {
final int loc = GL.GetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform1i() {
private int aCached = 0;
public void bind(int a) {
if(aCached == a) {
return;
}
aCached = a;
GL.Uniform1(loc, a);
}
};
Expand All @@ -122,7 +153,13 @@ public void bind(int a) {
public GLShader.Uniform2i getUniform2i(String name) {
final int loc = GL.GetUniformLocation(program, name);
return (loc < 0) ? null : new GLShader.Uniform2i() {
private int aCached = 0, bCached = 0;
public void bind(int a, int b) {
if(aCached == a && bCached == b) {
return;
}
aCached = a;
bCached = b;
GL.Uniform2(loc, a, b);
}
};
Expand Down

0 comments on commit f29f2b5

Please sign in to comment.