有了Android和OpenGL ES 1.0,为什么我的1440 x 320像素背景会缩小到截锥体宽度和截锥体高度(480 x 320)?

有了Android和OpenGL ES 1.0,为什么我的1440 x 320像素背景会缩小到截锥体宽度和截锥体高度(480 x 320)?,android,opengl-es,Android,Opengl Es,有了Android和OpenGL ES 1.0,为什么我的1440 x 320像素背景会缩小到截锥体宽度和截锥体高度(480 x 320) 我的直接目标是在每个屏幕上只显示我背景的三分之一,最终目标是实现2D滚动背景。我最初的理由是因为视图截头体/视图端口的宽度只有480像素,而我的原始图像的宽度是1440像素,所以我将在每个屏幕截图中只看到1440/480或1/3的背景 但是,整个图像似乎被缩小以适合视口。我认为这与我的默认加载纹理方法对缩小和放大过滤器使用G10.GL_这一事实有关: pri

有了Android和OpenGL ES 1.0,为什么我的1440 x 320像素背景会缩小到截锥体宽度和截锥体高度(480 x 320)

我的直接目标是在每个屏幕上只显示我背景的三分之一,最终目标是实现2D滚动背景。我最初的理由是因为视图截头体/视图端口的宽度只有480像素,而我的原始图像的宽度是1440像素,所以我将在每个屏幕截图中只看到1440/480或1/3的背景

但是,整个图像似乎被缩小以适合视口。我认为这与我的默认加载纹理方法对缩小和放大过滤器使用G10.GL_这一事实有关:

private void load () {
    GL10 gl = glGraphics.getGL();
    int[] textureIds = new int[1];
    gl.glGenTextures(1, textureIds, 0);
    textureId = textureIds[0];

    InputStream in = null;

    try {
        in = fileIO.readAsset(fileName);
        Bitmap bitmap = BitmapFactory.decodeStream(in);
        width = bitmap.getWidth(); // added by me to fix TextureRegion
        height = bitmap.getHeight(); // added by me to fix TextureRegion
        gl.glBindTexture(GL10.GL_TEXTURE_2D, textureId);
        GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);
        setFilters(GL10.GL_NEAREST, GL10.GL_NEAREST);
        gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
    }
    catch (IOException e) {
        throw new RuntimeException("Couldn't load texture '" + fileName + "'", e);
    }
    finally {
        if (in != null) {
            try {
                in.close();
            }
            catch (IOException e) {
            }
        }
    }
}

public void reload () {
    load();
    bind();
    setFilters(minFilter, magFilter);
    glGraphics.getGL().glBindTexture(GL10.GL_TEXTURE_2D, 0);
}
因此,我决定将缩小和放大过滤器设置为GL10.GL_线性,因为这样做可以生成具有1:1贴图的纹理:

background = new Texture(game, "scrolling_background.png");
background.setFilters(GL10.GL_LINEAR, GL10.GL_LINEAR);
background.reload();
我相信这很简单。任何指导或帮助都将不胜感激

以下是spritebatcher.draw原型:

公共虚空drawSprite(浮动x、浮动y、浮动宽度、浮动高度、纹理区域){


这与最近的/线性无关。请尝试:
batcher.drawSprite(cam.position.x,cam.position.y,1440320,Assets.backgroundRegion);
如果指定用于渲染精灵的库(LibGDX?),它将非常有用还有这个drawSprite函数的原型?我想这两个参数代表屏幕上你想要的精灵的最终尺寸,所以如果你想滚动,这个尺寸应该大于“平截头体”正如你所说的。好吧,LibGDX的作者Mario Zechner写了这个框架,我用它作为LibGDX框架的基础,他稍后会写这个框架。cam.position.x=world.background.position.x;batcher.beginBatch(Assets.background);batcher.drawSprite(cam.position.x,cam.position.y,1440320,Assets.backgroundRegion);batcher.endBatch();您推荐的代码行渲染场景的效果要好得多,只是不管cam.position.x的值是0、720还是1440,我总是看到背景的中间部分。我从来没有看到过开始,也从来没有看到过结束……抱歉,VB_溢出。您是对的。我的理解很慢。我注意到以下内容://这显示了左侧侧面背景//batcher.drawSprite(cam.position.x+平截头体宽度,cam.position.y,world.background.WIDTH,world.background.height,Assets.backgroundRegion);//这显示中间背景//batcher.drawSprite(cam.position.x,cam.position.y,world.background.WIDTH,world.background.height,Assets.backgroundRegion);//这显示右侧背景//batcher.drawSprite(cam.position.x-trustum_WIDTH,cam.position.y,world.background.WIDTH,world.background.height,Assets.backgroundRegion);
background = new Texture(game, "scrolling_background.png");
background.setFilters(GL10.GL_LINEAR, GL10.GL_LINEAR);
background.reload();
    float halfWidth = width / 2;
    float halfHeight = height / 2;

    float x1 = x - halfWidth;
    float y1 = y - halfHeight;
    float x2 = x + halfWidth;
    float y2 = y + halfHeight;

    // bottom left

    verticesBuffer[bufferIndex++] = x1;
    verticesBuffer[bufferIndex++] = y1;
    verticesBuffer[bufferIndex++] = region.u1;  
    verticesBuffer[bufferIndex++] = region.v2;

    // bottom right

    verticesBuffer[bufferIndex++] = x2;
    verticesBuffer[bufferIndex++] = y1;
    verticesBuffer[bufferIndex++] = region.u2;
    verticesBuffer[bufferIndex++] = region.v2;

    // top right

    verticesBuffer[bufferIndex++] = x2;
    verticesBuffer[bufferIndex++] = y2;
    verticesBuffer[bufferIndex++] = region.u2;
    verticesBuffer[bufferIndex++] = region.v1;

    // top left

    verticesBuffer[bufferIndex++] = x1;
    verticesBuffer[bufferIndex++] = y2;
    verticesBuffer[bufferIndex++] = region.u1;
    verticesBuffer[bufferIndex++] = region.v1;

    numSprites++;



}