-1
\$\begingroup\$

I want to display a bitmap image at screen using texture api in android opengl. Some code which I have used in our code as below.

public void onSurfaceChanged(GL10 gl, int width, int height) {
    gl.glGenTextures(1, texture, 0);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, texture[0]);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST);
    gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST);
    Bitmap bmp = BitmapFactory.decodeResource(ContextController.getContext().getResources(), R.drawable.ic_launcher);
    GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bmp, 0);
    bmp.recycle();
}

I have use this code But image is not display, screen is display as blank.

\$\endgroup\$
3
  • \$\begingroup\$ What's the size of ic_launcher? \$\endgroup\$
    – Chuck D
    May 2, 2012 at 23:30
  • \$\begingroup\$ Image size is 48*48 pixel..... \$\endgroup\$ May 3, 2012 at 12:30
  • \$\begingroup\$ You should be getting white polygons for textures that have not loaded correctly, rather than just a blank screen. What about the rest of your code? Also, images must be power of 2 for opengl-es. So 16x16, 32x32, 64x64 etc \$\endgroup\$ May 15, 2012 at 15:10

1 Answer 1

1
\$\begingroup\$

You are omitting important opengl calls. http://www.opengl.org/wiki/Common_Mistakes#Creating_a_Texture

\$\endgroup\$
1
  • \$\begingroup\$ Thank you very much for supporting me for this issue, but i have resolved this issue already...... \$\endgroup\$ May 23, 2012 at 7:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .