2012-07-25 122 views
1

我开始使用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就是纹理被装载的类。

这里是代码的meaningfull部分:

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库。这是错误的原因还是我的代码中有错误?另外,有没有AndEngine支持的设备列表?

此外: 我检查了测试的手机规格 - 它有Adreno 200支持OpenGLES 2.0。所以,它一定需要库,但它不需要。有什么建议么?

回答

2

你可以试试这个方法:AndEngine.isDeviceSupported()

+0

这就是我需要的! – 2012-07-26 12:12:16

4

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

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

Eclipse将不会让您部署的设备上的应用程序,不支持OpenGL ES 2.0。此外,这还会阻止拥有旧设备的用户从Google Play下载您的应用。希望这可以帮助。

+0

谢谢,补充说,但仍然有同样的错误。 – 2012-07-25 16:00:03

+0

我已经在另一部手机上运行该应用程序 - 完美工作。所以,这是关于不可接受的设备,并且没有帮助禁止运行我的设备。 – 2012-07-25 16:51:40