问题描述
我学习的为Android框架。我想他们的第一个基本教程,如下:
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);
}
}
所有我做的是创建一个球体并加入地球图像作为纹理。
图像的尺寸为1024×512
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.
当我在我的三星Galaxy SL运行此code,球体是不是有这个纹理相反,它是在一个黑暗的灰色。但是,当我运行的其他设备(的Nexus 7和索尼Xperia)这个code,正确显示纹理。
另外,如果我使用纹理像512×512,显示正确的三星Galaxy SL的质感。
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.
我发现一个提示,但不知道如何着手:OpenGL ES 2.0的质地没有显示的设备上
I found a hint but dont know how to proceed: OpenGL ES 2.0 texture not showing on some device
推荐答案
这是OpenGL的提供的最小过滤器
The min filters provided by opengl are
GLES20.GL_LINEAR_MIPMAP_LINEAR,GLES20.GL_NEAREST_MIPMAP_NEAREST,GLES20.GL_LINEAR,
GLES20.GL_NEAREST
GLES20.GL_LINEAR_MIPMAP_LINEAR, GLES20.GL_NEAREST_MIPMAP_NEAREST, GLES20.GL_LINEAR,GLES20.GL_NEAREST
纹理似乎呈现以下行code的
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_LINEAR);
The texture seems to be rendering for the following line of codeGLES20.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.
这篇关于纹理不显示在球体的三星Galaxy SL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!