I am trying to combine 2D and 3D views. My app initially starts in 2D.
When the user presses a button, I want to temporarily switch to 3D,
draw some fancy transition effects, and switch back to 2D. However, I
am getting stuck because the 3D view will come out black. It's
reproducible on both the 1.0 SDK and G1 phone.

I have reduced the problem to the following. You can drop the file
into ApiDemo:

1: when "GLSurfaceView2" is launched, initially it shows a blue screen
(2D View).
2: when user presses DPAD_DENTER, I create the 3D view and set it to
current view. However, the screen is completely black.
3: now, press PHONE button to start the dialer, then press the BACK
button, the rotating cubes is rendered on the screen

Is this a bug?

Thanks
-----------------------------Add to ApiDemo/
AndroidManifest.xml---------------------
        <activity android:name=".graphics.GLSurfaceViewActivity2"
                android:label="Graphics/OpenGL ES/GLSurfaceView2"
                android:theme="@android:style/Theme.NoTitleBar"
                android:configChanges="orientation|keyboardHidden">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category
android:name="android.intent.category.SAMPLE_CODE" />
            </intent-filter>
        </activity>
-------------------------------------------------
new---------------------------------------------
package com.example.android.apis.graphics;

import android.app.Activity;
import android.os.Bundle;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;

public class GLSurfaceViewActivity2 extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        normalView = new NormalView(this);
        setContentView(normalView);
    }

    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
            if (isNormal) {
                mGLSurfaceView = new GLSurfaceView(this);
                mGLSurfaceView.setRenderer(new CubeRenderer(false));
                setContentView(mGLSurfaceView);
                isNormal = false;
            }
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    protected void onResume() {
        super.onResume();
        if (mGLSurfaceView != null) {
            mGLSurfaceView.onResume();
        }
    }

    protected void onPause() {
        super.onPause();
        if (mGLSurfaceView != null) {
            mGLSurfaceView.onPause();
        }
    }

    private GLSurfaceView mGLSurfaceView;
    private View normalView;
    boolean isNormal = true;
}

class NormalView extends View {
    public NormalView(Context context) {
        super(context);
    }

    public void onDraw(Canvas canvas) {
        Rect rect = canvas.getClipBounds();
        Paint paint = new Paint();
        paint.setAntiAlias(true);
        canvas.drawColor(Color.BLUE);
    }
}
-------------------------------------------------
end-------------------------------------------
--~--~---------~--~----~------------~-------~--~----~
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-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to