I took the source from API demos (TriangleRenderer.java)

Here's the code on how textures are loaded in onSurfaceCreated():

////////////////////////////////////////////////////////////////
/*
         * Create our texture. This has to be done each time the
         * surface is created.
         */

        int[] textures = new int[1];
        gl.glGenTextures(1, textures, 0);

        mTextureID = textures[0];
        gl.glBindTexture(GL10.GL_TEXTURE_2D, mTextureID);

        gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_MIN_FILTER,
                GL10.GL_NEAREST);
        gl.glTexParameterf(GL10.GL_TEXTURE_2D,
                GL10.GL_TEXTURE_MAG_FILTER,
                GL10.GL_LINEAR);

        gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
                GL10.GL_CLAMP_TO_EDGE);
        gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,
                GL10.GL_CLAMP_TO_EDGE);

        gl.glTexEnvf(GL10.GL_TEXTURE_ENV, GL10.GL_TEXTURE_ENV_MODE,
                GL10.GL_REPLACE);

        InputStream is = mContext.getResources()
                .openRawResource(R.drawable.robot);
        Bitmap bitmap;
        try {
            bitmap = BitmapFactory.decodeStream(is);
        } finally {
            try {
                is.close();
            } catch(IOException e) {
                // Ignore.
            }
        }

        GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
        bitmap.recycle();

////////////////////////////////////////////////////////////////



And here's how I mapped my texture:

/////////////////////////////////////////////////////////////////
public void onDrawFrame(GL10 gl) {

        //Init
        gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
                gl.glMatrixMode(GL10.GL_MODELVIEW);
                gl.glLoadIdentity();

//Draw Cube
                gl.glPushMatrix();
                        gl.glTranslatef(0, 0, -2);
                        gl.glRotatef(azimuthZ, 0, 0, 1); //azimuthZ is
from the sensors
//texBuff and boxBuff are texture and box coordinates
                        gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, texBuff);
                        gl.glVertexPointer(3, GL10.GL_FLOAT, 0, boxBuff);

                        //top
                        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);
                        //bottom
                        gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4);
                        // followed by left, right, front and back
sides...
               gl.glPopMatrix();

/////////////////////////////////////////////////////////////////
Problem:
1. The box is rendering normally.
2. I press 'Call' button, the Dialer app comes up.
3. I press 'Back' button. My box app comes up.
4. The texture became corrupted...

- This does not happen if I press back while in the box app, and re-
launch the box app.

- This also does not happen in the Textured Triangle in API demos.

I've no idea what did I do wrong. -_-

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

Reply via email to