I've read your post. It is great, if I've found it several days before it could save a lot of time for me....but never the less, I've got some question, that you've omit in your post :
probably could write a bit more about the attribute bindings - this is exactly what I need...
I want to organize gl gradient... I've extended from QuadShader , override createColorExtras method to provide possibility manage color...also override vertexShader() method (add attribute : "attribute vec4 aVertexColor;" and swipe "v_Color = vec4(red / 255.0, green / 255.0, blue / 255.0, alpha / 255.0);" to ""v_Color = aVertexColor;\n" ). In the constructor of my ColorExtras, I've added next rows :
this.aVertexColor = prog.getAttrib("aVertexColor", 4, GL20.GL_FLOAT);
this.color = LinerGradient.this.ctx.createFloatBuffer(4 * 4);
Also I've override prepare and willFlsuh methdos :
@Override
public void prepare(int tex, boolean justActivated) {
float[] colors = {
1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f,
1.0f, 0.0f, 0.0f, 1.0f
};
if(this.color.position()!=0){
this.color.expand(colors.length);
}
this.color.add(colors, this.color.position(), colors.length);
// ANTS_TAG : something very, very strange appear here!!!
this.color.bind(GL20.GL_ARRAY_BUFFER);
this.aVertexColor.bind(4, 0);
}
@Override
public void willFlush() {
PlayN.log().warn("GradientExtras::willFlush");
this.color.bind(GL20.GL_ARRAY_BUFFER);
this.color.send(GL20.GL_ARRAY_BUFFER, GL20.GL_STATIC_DRAW);
}
I've created SurfaceLayer and setting my shader to render surface based on it...
I couldn't proper define semantics of binding exactly attribute variable (I can easy manager uniform, but not attribute ).....My source code has been changed several times, but I am still haven't clear vision of attribute binding.... As you've realized I want to add color attribute (vec4 as argb) to each vertices. I've done this in proper openGL, but...this binding not so clean for me... I will be very glad to hear any advice from your...