openGL ES 视网膜支持
我正在尝试让 avTouch 示例代码应用程序在视网膜显示屏上运行。有人这样做过吗?
在 CALevelMeter 类中,我尝试了以下操作:
- (id)initWithCoder:(NSCoder *)coder {
if (self = [super initWithCoder:coder]) {
CGFloat f = self.contentScaleFactor;
if ([self respondsToSelector:@selector(contentScaleFactor)])
{
self.contentScaleFactor = [[UIScreen mainScreen] scale];
}
f = self.contentScaleFactor;
_showsPeaks = YES;
_channelNumbers = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:0], nil];
_vertical = NO;
_useGL = YES;
_meterTable = new MeterTable(kMinDBvalue);
[self layoutSubLevelMeters];
[self registerForBackgroundNotifications];
}
return self;
}
并将 contentScaleFactor 设置为“2”。太好了,这是预料之中的。但在layoutSubviews中,CALevelMeter框架仍然是应有的1/2。
有什么想法吗?
I'm trying to get the avTouch sample code app to run on the retina display. Has anyone done this?
In the CALevelMeter class, I've tried the following:
- (id)initWithCoder:(NSCoder *)coder {
if (self = [super initWithCoder:coder]) {
CGFloat f = self.contentScaleFactor;
if ([self respondsToSelector:@selector(contentScaleFactor)])
{
self.contentScaleFactor = [[UIScreen mainScreen] scale];
}
f = self.contentScaleFactor;
_showsPeaks = YES;
_channelNumbers = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:0], nil];
_vertical = NO;
_useGL = YES;
_meterTable = new MeterTable(kMinDBvalue);
[self layoutSubLevelMeters];
[self registerForBackgroundNotifications];
}
return self;
}
and it sets the contentScaleFactor to "2". Great, that was expected. But then in the layoutSubviews, CALevelMeter frame is still 1/2 of what it should be.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
帧以点为单位,而不是像素。当比例因子应用于托管 CAEAGLLayer 的 UIView 时,它将是像素的两倍,但其帧点大小将保持不变。
如果您使用如下代码查看附加到 CAEAGLLayer 的颜色渲染缓冲区的背景宽度和高度:
您应该看到 Retina 显示器上渲染缓冲区的宽度和高度是标准 iPhone 显示器上的值的两倍。
上面显示的代码应该会在 Retina 显示屏上产生漂亮、清晰的渲染效果。
编辑(12/22/2010):为了回答您的进一步问题,查看 avTouch 示例代码表明该代码的当前版本在查找 OpenGL 托管视图的边界时出错,而不是使用支持渲染缓冲区的宽度和高度。使用非 1.0 比例因子时,这将导致 OpenGL 内容以一半大小绘制。
要解决此问题,请将 GLLevelMeter 中的
_drawView
中的相应部分替换为以下代码:这将使所有内容在适当的像素空间中工作,并导致在均衡器中以正确的尺寸进行清晰的渲染。我已就此提交了错误报告。
Frames are in points, not pixels. When a scale factor is applied to the UIView hosting your CAEAGLLayer, it will be double the pixels, but its frame point size will remain the same.
If you look at the backing width and height for the color renderbuffer attached to the CAEAGLLayer using code like the following:
you should see that the width and height of the renderbuffer on a Retina display are twice the values they are on a standard iPhone display.
The code you show above should cause nice, sharp rendering on a Retina display.
EDIT (12/22/2010): In response to your further question, looking at the avTouch sample code shows that the current version of that code makes a mistake in looking up the bounds of the OpenGL-hosting view, rather than using the backing width and height of the renderbuffer. With a non-1.0 scale factor, this will cause the OpenGL content to be drawn at half size.
To fix this, replace the appropriate section within
_drawView
in GLLevelMeter with the following code:This will cause everything to work in the appropriate pixel space, and lead to crisp rendering at the correct size in the equalizer. I've filed a bug report on this.