I have made many Android applications and games in Java before, however I am very new to OpenGL ES. Using guides online, I have made simple things in OpenGL ES, including a simple triangle and a cube.

I would like to make a 2D game with OpenGL ES, but what I've been doing isn't working quite so well, as the images I draw aren't to scale, and no matter what guide I use, the image is always choppy and not the right size (I'm debugging on my Nexus S).

How can I draw crisp, HD images to the screen with GL ES?

Here is an example of what happens when I try to do it: enter image description here

And the actual image: enter image description here

Here is how my texture is created:

//get id
int id = -1;
gl.glGenTextures(1, texture, 0);
id = texture[0];

//get bitmap
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.ball);

gl.glBindTexture(GL10.GL_TEXTURE_2D, id);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,

GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, bitmap, 0);

//crop image
mCropWorkspace[0] = 0;
mCropWorkspace[1] = height;
mCropWorkspace[2] = width;
mCropWorkspace[3] = -height;
((GL11) gl).glTexParameteriv(GL10.GL_TEXTURE_2D, GL11Ext.GL_TEXTURE_CROP_RECT_OES, mCropWorkspace, 0);
  • 1
    \$\begingroup\$ Hi and welcome to the site! As you can see in the FAQ this is a Q&A site, not a discussion forum. As such you tend to get the best, most-focused answers from our users if you only post a single actual question per "topic." I've edited your question to remove your query about creating a game loop as it's largely unrelated to your question about crisp sprites -- you should instead hit the "Ask A Question" button to create a new topic about your game loop question. \$\endgroup\$
    – user1430
    Commented Jan 20, 2012 at 22:52
  • 1
    \$\begingroup\$ That said, it would probably help if you provided at least a brief overview of the method by which you're currently rendering images to the screen and/or a screenshot of the artifacts you're seeing. \$\endgroup\$
    – user1430
    Commented Jan 20, 2012 at 22:53
  • \$\begingroup\$ @Josh: Thank you for your insightful words. I have added images of the problem, and how I'm currently creating textures. \$\endgroup\$
    – Qasim
    Commented Jan 20, 2012 at 22:59
  • \$\begingroup\$ I suggest showing the code which actually draws the texture. What you've got doesn't look unreasonable, but it's not the whole story. \$\endgroup\$
    – Kevin Reid
    Commented Jan 21, 2012 at 4:08

3 Answers 3


You need to change the GL_TEXTURE_MAG_FILTER to GL_LINEAR.



There is a couple of parameters you need to set on the texture, the first one is to tell OpenGL what to do if the texture need to be shrunk or magnified to match the rendered image. For a blurred image you should utilize another one. For a crisp and clean rendering image then other. For more details, followings #

  • GL_TEXTURE_MAG_FILTER : If the texture is smaller it needs to be magnified that is done with the magnification function
  • GL_TEXTURE_MIN_FILTER : If the texture needs to be scaled down using the minification function
  • GL_LINEAR : For a blurred image
  • GL_NEAREST : For a crisp and clean rendering image




What you want to achieve is called "pixel perfect texture mapping".

You need to call

gl.glOrthof(0, displayWidth, 0 , displayHeight, 0.0f, 100.0f);

in your initialization function. This will set 1 OpenGL unit equals to 1 pixel. OpenGL coordinates will be (0,0) for the top-left angle and (width, height) for the bottom-right angle.


You must log in to answer this question.

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