public CCScalarField2D(int w, int h) { _myMesh = new CCVBOMesh(CCDrawMode.TRIANGLE_STRIP, w * h * 3); for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { _myMesh.addVertex(x, y, 0); _myMesh.addVertex(x, y + 1, 0); _myMesh.addVertex(x + 1, y + 1, 0); } } _myShader = new CCGLSLShader( CCIOUtil.classPath(this, "shader/scalarField2Points_vp.glsl"), CCIOUtil.classPath(this, "shader/scalarField2Points_fp.glsl")); _myShader.load(); }
public void draw(CCGraphics g, CCTexture2D field) { g.texture(0, field); _myShader.start(); _myShader.uniform1i("field", 0); _myShader.uniform1f("scale", 1f); _myShader.uniform1f("downscale", 1f); _myMesh.draw(g); _myShader.end(); g.noTexture(); }