AndEngine支持的设备

时间:2012-07-25 14:50:48

标签: android opengl-es andengine

我开始使用AndEngine并尝试加载纹理以在屏幕中制作精灵。 在我的活动课中我有

public EngineOptions onCreateEngineOptions() {

     DisplayMetrics dm = new DisplayMetrics();
     getWindowManager().getDefaultDisplay().getMetrics(dm);

     CAMERA_WIDTH = dm.widthPixels;
     CAMERA_HEIGHT =  dm.heightPixels;

     float screenResolutionRatio = ((float)CAMERA_WIDTH/(float)CAMERA_HEIGHT);

    this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
    final EngineOptions options = new EngineOptions(true,
                                                    ScreenOrientation.PORTRAIT_FIXED, 
                                                    new RatioResolutionPolicy(screenResolutionRatio),
                                                    this.mCamera);
        return options;
    }


public void onCreateResources(OnCreateResourcesCallback arg0)
            throws Exception {
      mTextures = new NTTextures(this);     

    }

NTTexture是一个加载纹理的类。

以下是代码中有意义的部分:

public NTTextures(final BaseGameActivity activity) {
    try
    {
        BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
          this.spritesheetTexturePack = new TexturePackLoader(activity.getAssets(), activity.getTextureManager()).loadFromAsset("gfx/baseAtlas.xml", "gfx/");
        this.mSpritesheetTexture = spritesheetTexturePack.getTexture();
        this.mSpritesheetTexturePackTextureRegionLibrary = spritesheetTexturePack.getTexturePackTextureRegionLibrary();
        this.ping= this.mSpritesheetTexturePackTextureRegionLibrary.get(baseAtlas.PING_ID);

       activity.getEngine().getTextureManager().loadTexture(this.mSpritesheetTexture);


    } catch (final TexturePackParseException e) {
            Log.e("Error", String.valueOf(e));
        }

      }

所以,所有这一切都完成了,我有一个错误日志和崩溃。

07-25 18:44:23.880: D/AndEngine(32659): NTGameActivity.onCreate @(Thread: 'main')
07-25 18:44:23.930: W/dalvikvm(32659): VFY: unable to resolve static method 391: Landroid/opengl/GLES20;.glVertexAttribPointer (IIIZII)V
07-25 18:44:24.100: D/AndEngine(32659): NTGameActivity.onResume @(Thread: 'main')
07-25 18:44:24.290: D/AndEngine(32659): VERSION: OpenGL ES 2.0 1309647
07-25 18:44:24.290: D/AndEngine(32659): RENDERER: Adreno 200
07-25 18:44:24.290: D/AndEngine(32659): EGLCONFIG: EGLConfig(Red=5, Green=6, Blue=5, Alpha=0, Depth=0, Stencil=0)
07-25 18:44:24.290: D/AndEngine(32659): EXTENSIONS: GL_AMD_compressed_3DC_texture GL_AMD_compressed_ATC_texture GL_AMD_performance_monitor GL_AMD_program_binary_Z400 GL_EXT_texture_filter_anisotropic GL_EXT_texture_format_BGRA8888 GL_EXT_texture_type_2_10_10_10_REV GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_depth24 GL_OES_EGL_image GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_fragment_precision_high GL_OES_get_program_binary GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_3D GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_texture_npot GL_OES_vertex_half_float GL_OES_vertex_type_10_10_10_2 GL_NV_fence GL_QCOM_driver_control GL_QCOM_perfmon_global_mode GL_QCOM_extended_get GL_QCOM_extended_get2 GL_QCOM_tiled_rendering GL_QCOM_writeonly_rendering GL_QCOM_memory_monitor 
07-25 18:44:24.290: D/AndEngine(32659): MAX_VERTEX_ATTRIBS: 16
07-25 18:44:24.290: D/AndEngine(32659): MAX_VERTEX_UNIFORM_VECTORS: 251
07-25 18:44:24.290: D/AndEngine(32659): MAX_FRAGMENT_UNIFORM_VECTORS: 222
07-25 18:44:24.300: D/AndEngine(32659): MAX_TEXTURE_IMAGE_UNITS: 16
07-25 18:44:24.300: D/AndEngine(32659): MAX_TEXTURE_SIZE: 4096
07-25 18:44:24.300: D/AndEngine(32659): NTGameActivity.onSurfaceCreated @(Thread: 'GLThread 9')
07-25 18:44:24.300: D/AndEngine(32659): NTGameActivity.onCreateGame @(Thread: 'GLThread 9')
07-25 18:44:24.310: D/AndEngine(32659): NTGameActivity.onCreateResources @(Thread: 'GLThread 9')
07-25 18:44:30.310: I/global(32659): Default buffer size used in BufferedInputStream constructor. It would be better to be explicit if an 8k buffer is required.
07-25 18:44:30.420: D/AndEngine(32659): NTGameActivity.onSurfaceChanged(Width=320,  Height=480) @(Thread: 'GLThread 9')
07-25 18:44:31.000: W/dalvikvm(32659): VFY: unable to resolve static method 353: Landroid/opengl/GLES20;.glDrawElements (IIII)V
07-25 18:44:31.000: W/dalvikvm(32659): VFY: unable to resolve static method 391: Landroid/opengl/GLES20;.glVertexAttribPointer (IIIZII)V
07-25 18:44:31.030: W/dalvikvm(32659): Exception Lorg/andengine/util/exception/AndEngineRuntimeException; thrown during Lorg/andengine/opengl/GLES20Fix;.<clinit>

我用于测试LG Optimus One和Android 2.2,所以我认为我的设备没有需要GLES lib。这是错误的原因还是我的代码中有错误?另外,AndEngine是否有任何支持的设备列表?

增加: 我检查了测试的手机规格 - 它有Adreno 200支持OpenGLES 2.0。所以,它必须有必要的库,但事实并非如此。有什么建议吗?

2 个答案:

答案 0 :(得分:4)

要确保部署因设备上的OpenGL版本错误而失败,您可以在清单文件中插入以下行:

<uses-feature android:glEsVersion="0x00020000" />

Eclipse不允许您在不支持OpenGL ES 2.0的设备上部署应用程序。此外,这也会阻止使用旧设备的用户从Google Play下载您的应用程序。希望这会有所帮助。

答案 1 :(得分:2)

您可以尝试以下方法:AndEngine.isDeviceSupported()