Note that there are some explanatory texts on larger screens.

plurals
  1. POBug in Canvas.drawVertices? (with repro code and logcat)
    primarykey
    data
    text
    <p>Simply paste this code into a simple skeleton Android project.</p> <pre><code>public final class DrawableView extends View { private float[] mVertices = {0, 0, 255, 0, 255, 255, 0, 255}; private float[] mTexCoords = {0, 0, 255, 0, 255, 255, 0, 255}; private short[] mIndices = {0, 2, 3, 0, 1, 2}; private int[] mColors = {Color.RED, Color.GREEN, Color.BLUE, Color.MAGENTA}; Context mContext; BitmapShader mShader; public DrawableView(Context context) { super(context); mContext = context; mShader = new BitmapShader(BitmapFactory.decodeResource(getResources(), R.drawable.icon), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); } @Override protected void onDraw(Canvas canvas) { Paint paint = new Paint(); paint.setColor(Color.RED); paint.setShader(mShader); canvas.drawVertices(Canvas.VertexMode.TRIANGLES, 8, mVertices, 0, mTexCoords, 0, mColors, 0, mIndices, 0, 6, paint); invalidate(); } } </code></pre> <p>And then set this as the main view in the onCreate of the main activity.</p> <pre><code>@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new DrawableView(this)); } </code></pre> <p>This should make the application exit, with no error or even a "force close" dialog. Logcat gives me nothing useful (http://pastebin.com/c67NJnBz), either!</p> <p>Both the following drawVertices calls produce the desired effect, though.</p> <pre><code>canvas.drawVertices(Canvas.VertexMode.TRIANGLES, 8, mVertices, 0, mTexCoords, 0, null, 0, mIndices, 0, 6, paint); // Works! </code></pre> <p>and</p> <pre><code>paint.setColor(Color.RED); // paint.setShader(mShader); canvas.drawVertices(Canvas.VertexMode.TRIANGLES, 8, mVertices, 0, mTexCoords, 0, mColors, 0, mIndices, 0, 6, paint); // Renders wireframe </code></pre> <p>Am I doing something wrong? Please help me determine if this an Android API bug.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload