0

I'm trying to do a full screen render to texture with iOS and GL ES1. I've already achieved that using an FBO with an attached texture and it's working fine.

But i'm unsure whether my approach is correct: The iPhone screen is not power-of-two so what I did is to set glViewport to the nearest POT values to match the texture size then map it to a quad with the same size of the screen. This works, but the image looks slightly blurry.

Is it possible to draw just a portion of the texture attached to the FBO then map the quad UV coordinates accordingly?

An alternative would be to use non-pot textures but I'd like to avoid that.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
yggdrasil
  • 737
  • 5
  • 14
  • Why not simply render to an NPOT texture? All but the oldest iOS devices (original iPhone, iPhone 3G) [support NPOT textures](http://stackoverflow.com/questions/4760174/rendering-to-non-power-of-two-texture-on-iphone/4761453#4761453). Those old devices make up a negligible percentage of devices in use today, so it's safe to ignore them. – Brad Larson Jun 06 '13 at 20:03
  • You're right, but I'm also planning an android port and I'm not sure whether all android devices provide NPOT support. I also heard Npot textures are generally slightly slower than pot. – yggdrasil Jun 06 '13 at 22:25

1 Answers1

2

I would say your approach is good except for one thing. You wrote "nearest POT values to match the texture size", do not use nearest, use closest that are larger. If you downscale it the result should be a bit blurry.

So create a POT texture larger then the screen itself, attach it to a frame buffer, use view port with same parameters as screen, then if you need to use that texture to redisplay use texture coordinates such as screen.width/texture.width instead of 1.0. This should give you a nice 1:1 sampling and the result should be as clear as possible.

Matic Oblak
  • 16,318
  • 3
  • 24
  • 43
  • Thanks for your answer! Yes, sorry, by "nearest POT texture" I meant "larger closest POT" as you said. :). Looks like the rest of the texture is automatically filled by openGL with white. – yggdrasil Jun 06 '13 at 22:18
  • It should be filled with garbage or clear color if you clear the buffer at all (you probably don't even need to) – Matic Oblak Jun 07 '13 at 06:17