在调整窗口大小时,我一直试图让 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();
任何人都可以帮忙吗?