Flipping OpenGL texture

房东的猫 提交于 2019-12-04 04:02:45

Any of those:

Flip texture during the texture load,
OR flip model texture coordinates during model load OR set texture matrix to flip y (glMatrixMode(GL_TEXTURE)) during render.

Also, another thing I was wondering about: If I made a simple game, with pixels mapped to units, would it be alright to set it up so that the origin is in the top-left corner (personal preference), or would I run in to problems with other things (e.g. text rendering)?

Depends on how you are going to render text.

mk12

Jordan Lewis pointed out CGContextDrawImage draws image upside down when passed UIImage.CGImage. There I found a quick and easy solution: Before calling CGContextDrawImage,

CGContextTranslateCTM(context, 0, height);
CGContextScaleCTM(context, 1.0f, -1.0f);

Does the job perfectly well.

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