@Override public void set(GLES20ShaderParameter parameter, Float2 value, int location) { if (parameter.getType() == Type.ATTRIBUTE) GLES20.glVertexAttrib2f(location, value.x, value.y); else GLES20.glUniform2f(location, value.x, value.y); GLES20Utils.glCheckError(); }
public void setUniformf (int location, Float2 vector) { setUniformf(location, vector.x, vector.y); }
public void init(RenderScriptGL rs, Resources res, int width, int height) { mRS = rs; mRes = res; ProgramFragmentFixedFunction.Builder pfb = new ProgramFragmentFixedFunction.Builder(rs); pfb.setPointSpriteTexCoordinateReplacement(true); pfb.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.MODULATE, ProgramFragmentFixedFunction.Builder.Format.RGBA, 0); pfb.setVaryingColor(true); mPFPoints = pfb.create(); pfb = new ProgramFragmentFixedFunction.Builder(rs); pfb.setVaryingColor(true); mPFLines = pfb.create(); android.util.Log.e("rs", "Load texture"); mPFPoints.bindTexture(loadTexture(R.drawable.flares), 0); mPoints = new ScriptField_Point(mRS, PART_COUNT, Allocation.USAGE_SCRIPT); Mesh.AllocationBuilder smb = new Mesh.AllocationBuilder(mRS); smb.addVertexAllocation(mPoints.getAllocation()); smb.addIndexSetType(Mesh.Primitive.POINT); Mesh smP = smb.create(); mPhysicsScript = new ScriptC_ball_physics(mRS, mRes, R.raw.ball_physics); mScript = new ScriptC_balls(mRS, mRes, R.raw.balls); mScript.set_partMesh(smP); mScript.set_physics_script(mPhysicsScript); mScript.bind_point(mPoints); mScript.bind_balls1(new ScriptField_Ball(mRS, PART_COUNT, Allocation.USAGE_SCRIPT)); mScript.bind_balls2(new ScriptField_Ball(mRS, PART_COUNT, Allocation.USAGE_SCRIPT)); mScript.set_gPFLines(mPFLines); mScript.set_gPFPoints(mPFPoints); createProgramVertex(); mRS.bindProgramStore(BLEND_ADD_DEPTH_NONE(mRS)); mPhysicsScript.set_gMinPos(new Float2(5, 5)); mPhysicsScript.set_gMaxPos(new Float2(width - 5, height - 5)); mScript.invoke_initParts(width, height); mRS.bindRootScript(mScript); }
public void setAccel(float x, float y) { mPhysicsScript.set_gGravityVector(new Float2(x, y)); }
/** Sets the uniform with the given name. * * @param name the name of the uniform * @param vector x and y as the first and second values respectively */ public void setUniformf (String name, Float2 vector) { setUniformf(name, vector.x, vector.y); }