android sync

This commit is contained in:
codeanticode
2012-09-03 01:48:59 +00:00
parent 3fa1dcfc06
commit 45930bda63
7 changed files with 1694 additions and 1661 deletions

View File

@@ -75,6 +75,7 @@ public class PShader {
protected HashMap<Integer, Texture> textures;
protected int firstTexUnit;
protected int lastTexUnit;
public PShader() {
@@ -473,6 +474,12 @@ public class PShader {
}
protected void setUniformTex(int loc, Texture tex) {
// get unit from last value in bindTextures ...
// pgl.activeTexture(PGL.TEXTURE0 + unit);
tex.bind();
}
/*
// The individual attribute setters are not really needed, read this:
@@ -523,7 +530,7 @@ public class PShader {
protected void consumeUniforms() {
if (uniformValues != null && 0 < uniformValues.size()) {
int texUnit = firstTexUnit;
lastTexUnit = firstTexUnit;
for (Integer loc: uniformValues.keySet()) {
UniformValue val = uniformValues.get(loc);
if (val.type == UniformValue.INT1) {
@@ -586,12 +593,12 @@ public class PShader {
} else if (val.type == UniformValue.SAMPLER2D) {
PImage img = (PImage)val.value;
Texture tex = pgMain.getTexture(img);
pgl.uniform1i(loc, texUnit);
pgl.uniform1i(loc, lastTexUnit);
if (textures == null) {
textures = new HashMap<Integer, Texture>();
}
textures.put(texUnit, tex);
texUnit++;
textures.put(lastTexUnit, tex);
lastTexUnit++;
}
}
uniformValues.clear();