I am drawing lots of textures and panning and zooming in and out on them. When the camera zooms out they look really ugly.

What can I do?

  • 4
    \$\begingroup\$ Did you try generating mipmaps? \$\endgroup\$ – bummzack Apr 14 '11 at 12:04
  • 1
    \$\begingroup\$ Might also help to provide some screenshots of what exactly you're talking about. Could be a couple things, but as bummzack said, probably mipmaps. \$\endgroup\$ – Leniency Apr 14 '11 at 14:33
  • \$\begingroup\$ imgur.com/a/pdzdS theres zoomed in and zoomed out \$\endgroup\$ – t123 Apr 14 '11 at 15:03
  • \$\begingroup\$ That texture is a bad example, no matter what, its tiled, it will always look strange zoomed out (esp since it has a distinct pattern) \$\endgroup\$ – deceleratedcaviar Apr 16 '11 at 8:22

Yup, looks like mipmaps. This looks like it might be a good resource on how to add them in. Once in though, you can manipulate the filtering - try enabling trilinear filtering or anisotropic filtering.

  • \$\begingroup\$ gluBuild2DMipmaps is a bad function to suggest. If you are targeting OpenGL 2, you should use GL_GENERATE_MIPMAP. If you are targeting OpenGL 3, you should use glGenerateMipmaps. \$\endgroup\$ – user744 Apr 14 '11 at 18:51
  • 1
    \$\begingroup\$ Also, for preference, don't even bother with online generation. You can generate mips offline pretty easily, which only adds around 30% to your texture sizes, but saves a ton of loading time. You can also experiment with alternate shrinking filters to achieve the look you want (sharper, softer, etc). As for filtering: if you're only doing 2D screens, don't bother with anything but linear: anisotropic filtering is for coping with changing mip levels across a single polygon, which can't happen if you're orthogonal to the camera. \$\endgroup\$ – Chris Subagio Apr 14 '11 at 19:03
  • \$\begingroup\$ Online generation is still useful if you're doing dynamic textures. Some 2D APIs I have worked with will automatically atlas as you load (under the premise a 2D game is more likely to load lots of small textures, and the artist burden of manually atlasing would be large), which requires online mipmap generation. \$\endgroup\$ – user744 Apr 14 '11 at 20:01
  • \$\begingroup\$ Made my answer a community wiki - haven't done openGl in years so others can suggest better resources in the answer if they want. \$\endgroup\$ – Leniency Apr 14 '11 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.