【发布时间】:2015-08-29 02:29:21
【问题描述】:
我一直在尝试让 NSOpenGLView 在调整窗口大小时正确调整大小,但我不断遇到我无法解释的奇怪行为。看起来是这样的:
原创(开头的样子):
调整大小后:
这是我的调整大小代码:
- (void)reshape
{
[super reshape];
CGLLockContext([[self openGLContext] CGLContextObj]);
NSRect viewRectPoints = [self bounds];
#if SUPPORT_RETINA_RESOLUTION
NSRect viewRectPixels = [self convertRectToBacking:viewRectPoints];
#else //if !SUPPORT_RETINA_RESOLUTION
NSRect viewRectPixels = viewRectPoints;
#endif // !SUPPORT_RETINA_RESOLUTION
[self resizeWithWidth:viewRectPixels.size.width
AndHeight:viewRectPixels.size.height];
CGLUnlockContext([[self openGLContext] CGLContextObj]);
}
- (void) resizeWithWidth:(GLuint)width AndHeight:(GLuint)height
{
glViewport(0, 0, width, height);
m_width = width;
m_height = height;
}
我正在使用:“glViewport(0, 0, m_width, m_height);”每当我调用 glDrawArrays();
谁能帮忙?
【问题讨论】:
-
你也可以发布你的drawRect函数吗?
标签: macos cocoa opengl nsopenglview