2

我想将.PVR图像用于纹理目的。
为此,我在 drawables-mdpi 中使用PVRtextool并加载了我的图像。 现在,当我在我的项目中使用它时,应用程序就会崩溃。 pvr

我错过了一些步骤吗?
请指导。

这是我遇到问题的加载纹理代码。 resource包含.pvr格式的图像。

static void loadTexture(GL10 gl, Context context, int[] resource)
   {  
       gl.glGenTextures(n, textureIDs, 0);
       BitmapFactory.Options opts = new BitmapFactory.Options();
       opts.inScaled = false;
       for (int face = 0; face < n; face++)
       {

           gl.glBindTexture(GL10.GL_TEXTURE_2D, textureIDs[face]);

           bitmap[face] = BitmapFactory.decodeResource(
            context.getResources(), resource[face],opts); 


           gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
           gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);


           GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap[face], 0);
                  bitmap[face].recycle();
}
]
4

1 回答 1

1

您不能使用BitmapFactory.decodeResource()该格式。您必须使用该openRawResource()函数并将InputStream它的返回值传递给该ETC1Util.loadTexture()函数。

示例实现应该在/sdk/platforms/<version>/samples/CompressedTextureActivity.java,或者在线版本在这里。

于 2012-06-26T19:37:46.223 回答