View not being drawn on top of GLSurfaceView

I'm trying to make a pause menu come up when the user presses the menu button (pauses the game). The game does successfully pause, but nothing draws...maybe it's drawing underneath my GLSurfaceView? Here's my code.

public class GameActivity extends Activity {

private GLSurfaceView mGLSurfaceView;
private static final String TAG = "Game";
private MainGamePanel mGame;

private View mPauseMessage = null;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SharedPreferences prefs = getSharedPreferences("GameSettings", MODE_PRIVATE);

    setContentView(R.layout.main);
    mGLSurfaceView = (GLSurfaceView) findViewById(R.id.glsurfaceview);
    mPauseMessage = findViewById(R.id.pausedMessage);

    mGLSurfaceView.setEGLConfigChooser(false); // 16 bit, no z-buffer

    mGame = new MainGamePanel();
    mGame.setSurfaceView(mGLSurfaceView);

    ....
    mGLSurfaceView.setRenderer(mGame.getRenderer());

}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean result = true;
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        if (mGame.isPaused()) {
            this.resume();
            if (mPauseMessage != null) {
                mPauseMessage.setVisibility(View.GONE);
            }
        } else {
            this.pause();
            if (mPauseMessage != null) {
                mPauseMessage.setVisibility(View.VISIBLE);
            }
        }
    }
    return result;
}

protected void pause() {
    super.onPause();

    mGame.onPause();
    mGLSurfaceView.onPause();
}


protected void resume() {
    super.onResume();

    mGame.onResume();
    mGLSurfaceView.onResume();
}

And from my XML:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<android.opengl.GLSurfaceView xmlns:android="http://schemas.android.com/apk/res/android" 
            android:id="@+id/glsurfaceview"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
    />
    <LinearLayout
        android:id="@+id/pauseMenu"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:visibility="gone">
    <ImageView 
    android:id="@+id/pausedMessage"
    android:src="@drawable/pause"
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:layout_gravity="center"/>
</LinearLayout>
</FrameLayout>

Answers


Maybe you have a line somewhere saying:

    mGLSurfaceView.setZOrderOnTop(true);

Which overrides OpenGL to draw above anything, even if you have other views on top of it in your RelativeLayout. Try commenting this out if you have one.


I have had a similar problem. But in my case pauseMenu was INVISIBLE, but not GONE. When I changed it to GONE, all worked fine. But that happend only on some devices. Maybe try View.bringToFront()


Need Your Help

Transfer files between 2 servers with feedback

php ftp

I need to implement Wordpress (or some other CMS) web site on Server_1 that when user upload files, they are transferred to another Server_2, there processed by some application and returned to Ser...

How to get variable from url for .js file?

php javascript url variables get

Example: Suppose the current page url(window.location.href) is http://example.com/page.html

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.