视网膜显示屏图像质量问题

发布于 2024-10-15 08:08:23 字数 135 浏览 6 评论 0原文

我试图让我的 OPENGL ES 应用程序支持视网膜显示。我添加了带有 @2x 扩展名的图像,并将内容比例因子设置为 2。高分辨率图像正确地进入屏幕,但质量损失很大。边缘模糊,并且没有我添加到资源文件夹中的图像质量。

我该如何解决这个问题?

I was trying to make my OPENGL ES app to support for retina display. I've added the image with @2x extension and made the contentscale factor to 2. The high resolution image is coming in the screen correctly but it suffers great loss of quality. The edges and blurred and it doesn't have quality of image I added into the resource folder.

How can I fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不必在意 2024-10-22 08:08:23

我的应用程序基于默认框架,在基于 Retina 的设备上运行时遇到此问题。具体来说,我的帧缓冲区是以 320x480 而不是我想要的 640x960 创建的。抱歉詹姆斯,但这不是自动的,因为问题在于 renderBufferStorage:fromDrawable: (代表我们调用 glRenderbufferStorage,但默认指定布局像素而不是本机设备像素的宽度和高度)。

我在 EAGLView.minitWithCoder: 中设置 eaglLayer.drawableProperties 的行下面添加了以下代码:

UIScreen *mainScreen = [UIScreen mainScreen];
if ([mainScreen respondsToSelector:@selector(scale)])
{
    // iOS 4.0 and up (further to simeon's comment)
    const CGFloat scale = mainScreen.scale;
    self.contentScaleFactor = scale;
    eaglLayer.contentsScale = scale;
}

感谢 David Amador 的 帖子为我指点朝着正确的方向。最近,感谢 simeon 的有用评论。

My app is based on the default framework and I was getting this issue when running on a Retina based device. Specifically my framebuffer was being created at 320x480 rather than 640x960 as I wanted. Sorry James but this is NOT automatic because the problem is with the framebuffer created by renderBufferStorage:fromDrawable: (which calls glRenderbufferStorage on our behalf but specifies layout pixels rather than native device pixels for width and height by default).

I added the following code below line lines which set eaglLayer.drawableProperties in initWithCoder: in EAGLView.m:

UIScreen *mainScreen = [UIScreen mainScreen];
if ([mainScreen respondsToSelector:@selector(scale)])
{
    // iOS 4.0 and up (further to simeon's comment)
    const CGFloat scale = mainScreen.scale;
    self.contentScaleFactor = scale;
    eaglLayer.contentsScale = scale;
}

Thanks to David Amador's post for pointing me in the right direction. Thanks, more recently, to simeon's helpful comments.

银河中√捞星星 2024-10-22 08:08:23

在 EAGLView.m initWithCoder: 方法中,添加以下代码:

if( [[UIScreen mainScreen] respondsToSelector:@selector(scale)] )
{
    self.contentScaleFactor = [[UIScreen mainScreen] scale];   
}

In your EAGLView.m initWithCoder: method, add the following code:

if( [[UIScreen mainScreen] respondsToSelector:@selector(scale)] )
{
    self.contentScaleFactor = [[UIScreen mainScreen] scale];   
}
尴尬癌患者 2024-10-22 08:08:23

OpenGLES 将自动在视网膜显示屏上以最大可能的分辨率进行渲染(假定您已将视口设置为屏幕的宽度和高度等),因此问题来自于您的 OpenGL 渲染。

OpenGLES 不关心您附加到图像的后缀@2X(这是针对Cocoa Touch 框架的)。然而,它确实关心图像的分辨率。为了获得最佳结果,您应该使用宽度和高度为 2 的幂的方形图像(例如 1024、2048 等)。

您应该确保将纹理加载到 OpenGLES 时使用正确的图像格式,并且不以任何方式压缩它。

您应该尝试的另一件事是纹理参数。例如:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

我希望这能为您指明正确的方向。

OpenGLES will be rendered at the greatest possible resolution on the retina display automatically (given you've set your viewport to the width and height of the screen, etc. etc.) so the problem comes from your OpenGL rendering.

OpenGLES doesn't care about the suffix @2X you've appended to the image (this is for Cocoa Touch frameworks). It does, however, care about the resolution of the image. For the best results, you should use square images that are a width and height that is a power of two (e.g. 1024, 2048 etc.).

You should ensure that when you're loading the texure into OpenGLES that you're using the correct image format, and that you're not compressing it in any way.

The other thing you should experiment with is the texture parameters. For example:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

I hope this points you in the right direction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文