在一个只运行在肖像模式下的游戏中,我尝试通过清单强制sensorPortrait:
android:configChanges="locale|orientation|keyboardHidden|screenSize|screenLayout"
android:screenOrientation="sensorPortrait"但是当我把设备锁在肖像上,把它旋转成风景,然后解锁它

这就是肖像里的样子:

我认为这是因为onSurfaceChanged被调用了两次,但是AFAIK对此我无能为力。
在我使用的渲染器中:
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
if (b_GameRunning) {
// mark the fact that textures need reloading
b_SurfaceWasChanged = true;
}
}
public void onSurfaceChanged(GL10 gl, int w, int h) {
gl.glMatrixMode( GL_PROJECTION );
gl.glLoadIdentity();
n_width = w;
n_height = h;
gl.glOrthof(0.f, (float)m_width, (float)m_height, 0.f, -1.f, 1.0f);
}
public void onDrawFrame(GL10 gl) {
if (m_bGameRunning) {
if (b_SurfaceWasChanged) {
b_SurfaceWasChanged = false;
ReloadTextures();
}
GameRender();
}
}发布于 2015-02-20 12:00:14
非常感谢harism。
我将onSurfaceChanged改为:
public void onSurfaceChanged(GL10 gl, int w, int h) {
n_width = w;
n_height = h;
gl.glViewport(0, 0, n_width, n_height);
gl.glMatrixMode( GL_PROJECTION );
gl.glLoadIdentity();
gl.glOrthof(0.f, (float)m_width, (float)m_height, 0.f, -1.f, 1.0f);
}https://stackoverflow.com/questions/28628007
复制相似问题