简体   繁体   中英

OpenGL ES render to non POT texture

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM