Note that there are some explanatory texts on larger screens.

plurals
  1. POSample texturing using Texture atlas and openGL 1.1 in android
    primarykey
    data
    text
    <p>I'm having a problem with texturing objects in OpenGL using texture atlases, I'm creating a 2d game and I know how to texture a POT bitmap to an object but, I can't seem to find a tutorial in converting my code to use a texture atlas for performance reasons, here is my code for my current working object creation and texturing implementation.</p> <pre><code>public void createTexture(Bitmap bmp, GL10 gls, int texturename) { this.gl = (GL11) gls; this.TextureName = texturename; bombBmp = bmp; VertexBuffer = null; TextureBuffer = null; IndexBuffer = null; ByteBuffer byteBuffer = ByteBuffer.allocateDirect(12 * 4); byteBuffer.order(ByteOrder.nativeOrder()); VertexBuffer = byteBuffer.asFloatBuffer(); VertexBuffer.put(new float[] { 0, 0, 0.0f, 0, -h, 0.0f, w, 0, 0.0f, w, -h, 0.0f }); VertexBuffer.position(0); byteBuffer = ByteBuffer.allocateDirect(8 * 4); byteBuffer.order(ByteOrder.nativeOrder()); TextureBuffer = byteBuffer.asFloatBuffer(); TextureBuffer.put(new float[] { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f }); TextureBuffer.position(0); byteBuffer = ByteBuffer.allocateDirect(6 * 2); byteBuffer.order(ByteOrder.nativeOrder()); IndexBuffer = byteBuffer.asShortBuffer(); IndexBuffer.put(new short[] { 0, 1, 2, 1, 3, 2 }); IndexBuffer.position(0); gl.glBindTexture(GL10.GL_TEXTURE_2D, this.TextureName); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE); gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE); GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bombBmp, 0); bombBmp.recycle(); bombBmp = null; } </code></pre> <p>I generate my Texturename from genTexture and pass the POT bitmap to this function</p> <pre><code>gl.glGenTextures(1, textures, 0); bomb.createTexture(bombBmp, gl, textures[0]); </code></pre> <p>here's my supposed texture bitmap</p> <p><img src="https://i.stack.imgur.com/uxEVI.png" alt="bomb_atlas.png"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload