我正在研究Android的Rajawali框架。我想他们的第一个基本教程,如下:纹理不显示在三星Galaxy SL的球体上
public class RRenderer extends RajawaliRenderer {
private DirectionalLight mLight;
private BaseObject3D mSphere;
public RRenderer(Context context) {
super(context);
setFrameRate(60);
}
protected void initScene() {
mLight = new DirectionalLight(1f, 0.2f, 1.0f); // set the direction
mLight.setColor(1.0f, 1.0f, 1.0f);
mLight.setPower(2);
Bitmap bg = BitmapFactory.decodeResource(mContext.getResources(), R.drawable.earthtruecolor_nasa_big);
DiffuseMaterial material = new DiffuseMaterial();
mSphere = new Sphere(1, 18, 18);
mSphere.setMaterial(material);
mSphere.addLight(mLight);
mSphere.addTexture(mTextureManager.addTexture(bg));
addChild(mSphere);
mCamera.setZ(-4.2f);
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
super.onSurfaceCreated(gl, config);
}
public void onDrawFrame(GL10 glUnused) {
super.onDrawFrame(glUnused);
mSphere.setRotY(mSphere.getRotY() + 1);
}
}
所有我做的是创造一个球,并添加地球图像的纹理。 图像的大小是1024x512。
当我在Samsung Galaxy SL上运行此代码时,球体没有这种纹理,而是呈深灰色。但是当我在其他设备(Nexus 7和Sony Xperia)上运行此代码时,纹理显示正确。 另外,如果我使用像512x512这样的纹理,纹理将在Samsung Galaxy SL上正确显示。
我发现一个提示,但不知道如何着手:OpenGL ES 2.0 texture not showing on some device