Friday, November 25, 2011

[android-developers] drawCrack

I wrote this code back in the day to draw a fake crack on a user's
phone:

static void drawCrack(GL10 gl) {
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glDisable(GL10.GL_DEPTH_TEST);
gl.glDisable(GL10.GL_CULL_FACE);


gl.glDisable(GL_LIGHTING);
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glColor4f(1, 1, 1, 1);

gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

float[] texcoords = new float[] { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f,
0.0f,
0.0f, 0.0f };

float[] vercoords = new float[] { -2, -2, 2, -2, 2, 2, -2, 2 };

FloatBuffer tfb = DirectWrap.wrap(texcoords);
FloatBuffer vfb = DirectWrap.wrap(vercoords);
gl.glBindTexture(GL10.GL_TEXTURE_2D, crackedImg);

gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);

gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, tfb);
gl.glVertexPointer(2, GL10.GL_FLOAT, 0, vfb);

gl.glPushMatrix();
gl.glScalef(1.7f, 1.7f, 1);

gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, 4);
gl.glPopMatrix();

gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

gl.glDisable(GL10.GL_TEXTURE_2D);
gl.glDisable(GL10.GL_BLEND);

gl.glMatrixMode(GL10.GL_TEXTURE);

gl.glLoadIdentity();
gl.glMatrixMode(GL10.GL_MODELVIEW);


}


It used to work, but for some reason, it stopped working. Any ideas
why?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate