opengl - How to check if image should be flipped vertically before loading using stb_image
问题描述
I'm writing a project using OpenGL, and loading the textures using stb_image.
Some of the textures are loaded flipped upside down (regarding the y-axis) so I use "stbi flip image vertically on load" to load them properly.
The problem is that some of the textures I load require flipping, and some not, But of course my code flipps them all. how can I check (before loading, or at least before flipping) whether or not to flip the image?
解决方案
简短的回答:从 stb_image 加载图像到 OpenGL 纹理时总是翻转。更长的答案:您无法知道用户是否想要自己翻转图像。正如提出的那样,我认为您的问题已由Kai Burjack 链接到的问题(我是否应该垂直翻转加载了 stb_image 以在 OpenGL 中使用的图像的线条?)回答了您的问题,因为它阐明了 stb_image 的此功能的正确使用。
如果您直接从图像文件转到 OpenGL 纹理,那么如果您希望导入的纹理的“向上”与用户在其艺术程序中看到的内容相匹配,则应始终在导入期间翻转。但是,如果您想让用户选择将图像倒置加载,而与图像在艺术程序中的外观无关,您也完全可以做到这一点。问题是用户必须告诉你。没有办法知道用户想要什么,而且想要颠倒图像的 IMO 艺术家很可能只是在他们的艺术程序中以这种方式制作它们。
推荐阅读
- json - 如何从 django 请求中获取分钟/小时/秒?
- java - 如何为 Java 中的 String 对象生成 hashCode()?
- .htaccess - 将所有重定向到 ssl,管理面板除外
- php - 登录并在php中注册没有响应
- python - 如何通过生成两个时间段之间的日期范围来填充数据框中缺失的日期值
- json - 如何从 iOS Swift 中的 JSON 响应中获取数据?
- kubernetes - Helm - Configmap - 仅替换文件的内容而不是文件名
- sql - 根据销售数量选择每个国家/地区最受欢迎的时间
- python - 为什么 python 请求没有终止,为什么打印这些单独的日志?
- javascript - 如何找到在模态输入中键入的值并在按下回车键时更改另一个输入的值