With Android and OpenGL ES 1.0, why is my 1440 x 320 pixel background down-scaled to my Frustum Width and Frustum Height (480 x 320)? -


with android , opengl es 1.0, why 1440 x 320 pixel background down-scaled frustum width , frustum height (480 x 320)?

background = new texture(game, "scrolling_background.png"); backgroundregion = new textureregion(background, 0, 0, 1440, 320);  batcher.beginbatch(assets.background); batcher.drawsprite(cam.position.x, cam.position.y, frustum_width, frustum_height, assets.backgroundregion); batcher.endbatch();  cam.position.x = 240 cam.position.y = 160 frustum_width = 480 frustum_height = 320 

my immediate display 1 third of background each screen ultimate goal @ implement 2d scrolling background. original rationale because view frustum / view port 480 pixels in width , original image 1440 pixels in width, see 1440 / 480 or 1/3 of background each screen shot.

however, entire image appears down-scaled fit view port. thought had fact default load texture method uses g10.gl_nearest both minification , magnification filters:

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 me fix textureregion         height = bitmap.getheight(); // added me 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);     }     {         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); } 

so decided set both minification , magnification filters gl10.gl_linear thinking make texture 1:1 mapping doing this:

background = new texture(game, "scrolling_background.png"); background.setfilters(gl10.gl_linear, gl10.gl_linear); background.reload(); 

i'm sure simple. guidance or appreciated.

here spritebatcher.draw prototype:

public void drawsprite(float x, float y, float width, float height, textureregion region) {

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


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -