Android OpenGLES 1.0视口呈现错误的分辨率

时间:2013-09-13 01:49:38

标签: java android opengl-es viewport

我正在尝试在正交投影中创建一个OpenGLES 1.0 2D游戏。它应该在我的Nexus 7平板电脑上以1280x720运行。它似乎是屏幕兼容模式,使视口缩小到557x320,如附图所示。

http://i.stack.imgur.com/00Lw1.png

精灵看起来不稳定,我已经尝试了几个小时来解决它。我的代码是:

@Override
public void onSurfaceChanged(GL10 gl, int width, int height)
{
    gl.glViewport(0, 0, (int)width, (int)height);

    gl.glMatrixMode(GL10.GL_PROJECTION);
    gl.glLoadIdentity();

    gl.glOrthof(0.0f, (float)game_width, (float)game_height, 0.0f, 1.0f, -1.0f);

    gl.glMatrixMode(GL10.GL_MODELVIEW);
    gl.glLoadIdentity();

    gl10 = gl;
}

@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config)
{        
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glEnable(GL10.GL_ALPHA_TEST);
    gl.glAlphaFunc(GL10.GL_GREATER, 0.5f);
    gl.glEnable(GL10.GL_BLEND);
    gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    gl.glDisable(GL10.GL_DEPTH_TEST);

    gl10 = gl;

    scene = new SCN_scn_title();
    scene.mgp = this;

}

我的清单是:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="net.website.packagenamehere" android:versionCode="1" android:versionName="1.0">
    <application android:label="Block Party" android:icon="@drawable/ic_launcher" allowBackup="true" hardwareAccelerated="true" theme="@android:style/Theme.NoTitleBar.Fullscreen">
        <activity android:name="MainActivity" android:label="Block Party">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-permission name="android.permission.VIBRATE" />
    <supports-screens xlargeScreens="true" largeScreens="true" normalScreens="true" smallScreens="true" anyDensity="true" resizeable="false" />
    <uses-sdk minSdkVersion="10" targetSdkVersion="15" />
</manifest>

我似乎无法解决这个问题,我的问题是我应该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

屏幕属性, largeScreens, normalScreens, smallScreens, anyDensity, resizeable等需要android:前缀。