Textures are not displayed on the sphere for Samsung Galaxy SL

一世执手 提交于 2019-12-08 14:00:28

问题


I am studying the Rajawali framework for Android. I tried their first basic tutorial which is as follows:

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);
}

}

All I am doing is creating a Sphere and adding an Earth image as a texture to it. The size of the image is 1024x512.

When I run this code on my Samsung Galaxy SL, the sphere is not having this texture instead it is in a dark grey color. But when I run this code on other devices (Nexus 7 and Sony Xperia), the texture is displayed correctly. Also if I use a texture like 512x512, the texture is displayed correctly on Samsung Galaxy SL.

I found a hint but dont know how to proceed: OpenGL ES 2.0 texture not showing on some device


回答1:


The min filters provided by opengl are

GLES20.GL_LINEAR_MIPMAP_LINEAR, GLES20.GL_NEAREST_MIPMAP_NEAREST, GLES20.GL_LINEAR, GLES20.GL_NEAREST

The texture seems to be rendering for the following line of code GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);

I came to the conclusion that the device does not render texture when the Mipmapping is on.



来源:https://stackoverflow.com/questions/14761154/textures-are-not-displayed-on-the-sphere-for-samsung-galaxy-sl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!