OpenGL: Rendering to texture by using FBO and viewport offset problems

心已入冬 提交于 2019-12-04 21:57:03

You of course get the twice the viewport - since you basically apply it twice - the viewport is also effective when rendring to the texture, so you end up with the object origin mappted to pixel (x,y) in the texture. Then, you draw that texture, again with the viewport, so the quad begins at (x,y) in window coords, and the object in the texture is further shifted away - the two offsets accumulate.

Just set the viewport to begin at origin when you render into the texture.

If width() == w and height() == h (the w & h values in your resize function), then your texture (and FBO) size is different from your viewport size. To be explicit, your viewport is (w-100) * (h-100) and your texture is (w-150) * (h-150).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!