开发者

parameters for glOrtho for screen size quad in cocos2dx

I am creating a render texture of 2048x2048 and rendering a sprite of size 2048x2048 over it covering the whole render texture. How is the parameters for glOrtho(..) calculated? glOrtho((float)-1.0f , (float)1.0f , (float)-1.0f , (float)1.0f, -1, 1) works for sprite of size 1024x768 and also 512x512. What is the limitation on the max resolution开发者_如何学运维 of the render target?


In case with sprite you mean a quad or something the like:

A call to glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) will neither work with a sprite of 2048x2048 nor one of size 1024x768 nor one of size 512x512. Or better it will work, but I'm sure it won't give the intended results. The coordinates of the sprite and the arguments to glOrtho are in the same space (which doesn't need to be pixels).

Either use a sprite of size 2x2 with glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0) or a sprite of size 1x1 with glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0) or a sprite of size 2048x2048 with glOrtho(0.0, 2048.0, 0.0, 2048.0, -1.0, 1.0) or whatever you like with the sprite coordinates matching the arguments to glOrtho, it doesn't really matter.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜