OpenGL 中的纹理因 Android 屏幕密度 (hdpi) 而损坏
我的 HDPI 屏幕有问题(在 Samsung Galaxy S2 上测试)。
我有一个纹理贴图,与 OES_draw_texture 1.1 扩展一起使用。这适用于 MDPI 屏幕,无论大小(在 HTC Legend 和 Asus Transformer 平板电脑上测试)。纹理贴图被正确裁剪并且纹理被正确显示。
但是,在 Galaxy S2(可能还有所有 HDPI 设备)上,纹理贴图未正确裁剪。纹理贴图位于/drawable/目录下,minSdkVersion设置为4,因此Screen Compatibility不会开启。如果打开屏幕兼容性(通过将 minSdkVersion 设置为 3),即使在 S2 上它也能正常工作,因为它模拟 MDPI 屏幕。
我的印象是,如果您要访问可绘制资源“a”,Android 会在特定密度文件夹(在本例中为 /drawable-hdpi/)中查找,如果找不到,则返回到 /drawable/ 或 /drawable -mdpi/.然而,我无法找到支持这一点的文档。
我的问题如下:
- Android资源搜索的行为是什么?如果在hdpi中找不到资源,它实际上会回退到mdpi吗?来源?
- 为什么 OES_draw_texture GL-ES1.1 扩展无法正确裁剪?我怀疑这与 px 和 dp 有关; draw_texture 通常使用直接像素,但 Android 可能会尝试使用 dp,因此将所有裁剪位置乘以 1.5,因为资源位于 /drawable/ 文件夹中?
- 是否有办法强制 HDPI 设备在不使用屏幕兼容性的情况下模拟 MDPI?
如果您了解这方面的知识,我们将不胜感激。
I am having a problem with HDPI screens (tested on Samsung Galaxy S2).
I have a texture map which I use in conjunction with the OES_draw_texture 1.1 extension. This works fine for MDPI screens, big and small (tested on HTC Legend and Asus Transformer tablet). The texture map is cropped correctly and the texture is displayed correctly.
However, on the Galaxy S2 (and presumably all HDPI devices), the texture map is not cropped correctly. The texture map is located in the /drawable/ directory, and the minSdkVersion is set to 4, so Screen Compatibility will not be on. If screen compatibility is turned on (by setting minSdkVersion to 3), it works correctly even on the S2 because it's emulating an MDPI screen.
I was under the impression that if you were to access a drawable resource "a", Android would look in the specific density folder (in this case /drawable-hdpi/) and if not found, fall back onto /drawable/ or /drawable-mdpi/. I have not been able to find documentation to support this however.
My questions are as follows:
- What is the behaviour of Android's resource searching? Does it actually fall back onto mdpi if it cannot find the resource in hdpi? Source?
- Why is OES_draw_texture GL-ES1.1 extension failing to crop correctly? I suspect it has to do with px and dp; draw_texture typically uses direct pixels, but Android may be trying to use dp and therefore multiplies all crop positions by 1.5 since the resource is located in the /drawable/ folder?
- Is there a way to force an HDPI device to emulate MDPI without using screen compatibility?
Any knowledge into this would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从这里开始。(加载纹理时)
From here. (When loading your texture)