getHolder().setType(android.view.SurfaceHolder.SURFACE_TYPE_NORMAL);
on a real device, however, you may get a blank screen, or very slow redraws, so you should use this:
getHolder().setType(android.view.SurfaceHolder.
SURFACE_TYPE_GPU
);
or even this:
getHolder().setType(android.view.SurfaceHolder.
SURFACE_TYPE_HARDWARE
);
So i came up with this solution for the SurfaceView initialization:
public GameSurfaceView(Context context,GameOverlay overlay,Sound soundManager)
{
super(context);
this.soundManager = soundManager;
this.context = context;
this.overlay = overlay;
this.viewType = GLThread.VIEW_INTRO;
this.gameType = Game.GAME_MONOLITH;
getHolder().addCallback(this);
try
{
getHolder().setType(android.view.SurfaceHolder.
SURFACE_TYPE_GPU
);
}
catch(Exception e)
{
try
{
getHolder().setType(android.view.SurfaceHolder.
SURFACE_TYPE_HARDWARE
);
}
catch(Exception e2)
{
try
{
getHolder().setType(android.view.SurfaceHolder.SURFACE_TYPE_NORMAL);
}
catch(Exception e3)
{
}
}
}
}
So in the code above, we first try to get a hardware accelerated surface (fastest), if that fails a gpu memory surface(still fast) and if that fails a normal software surface.
2 comments:
The source version doesn't run on a G1. The OpenGL surface never gets initialized. This is not the case for downloadable APK you have posted, which works. Did you do something different?
I think that this particular blog entry is wrong. The apk 1.0.4 beta, uses the line getHolder.setType(SURFACE_TYPE_GPU); only. This works on the G1 and on most emulator setups and should be used. However, it did not work correctly in an ubuntu linux emulator setup. It works fine on windows and macosx setups though. I will update the post when I have more information on the matter.
Post a Comment