Cocoa: Update the current GL context when its window moves or resizes.
According to the NSOpenGLContext docs, you need to do this, and we were previously masking the need in the SDL_GL_MakeCurrent() implementation.
This commit is contained in:
parent
34edc62460
commit
0b3c783570
1 changed files with 32 additions and 1 deletions
|
@ -114,6 +114,7 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
|||
- (void)windowDidMove:(NSNotification *)aNotification
|
||||
{
|
||||
int x, y;
|
||||
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
||||
SDL_Window *window = _data->window;
|
||||
NSWindow *nswindow = _data->nswindow;
|
||||
NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
|
||||
|
@ -136,17 +137,28 @@ static __inline__ void ConvertNSRect(NSRect *r)
|
|||
|
||||
x = (int)rect.origin.x;
|
||||
y = (int)rect.origin.y;
|
||||
|
||||
if (window == device->current_glwin) {
|
||||
[((NSOpenGLContext *) device->current_glctx) update];
|
||||
}
|
||||
|
||||
SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y);
|
||||
}
|
||||
|
||||
- (void)windowDidResize:(NSNotification *)aNotification
|
||||
{
|
||||
SDL_VideoDevice *device = SDL_GetVideoDevice();
|
||||
int w, h;
|
||||
NSRect rect = [_data->nswindow contentRectForFrameRect:[_data->nswindow frame]];
|
||||
w = (int)rect.size.width;
|
||||
h = (int)rect.size.height;
|
||||
if (SDL_IsShapedWindow(_data->window))
|
||||
Cocoa_ResizeWindowShape(_data->window);
|
||||
|
||||
if (_data->window == device->current_glwin) {
|
||||
[((NSOpenGLContext *) device->current_glctx) update];
|
||||
}
|
||||
|
||||
SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESIZED, w, h);
|
||||
}
|
||||
|
||||
|
@ -683,6 +695,10 @@ Cocoa_SetWindowPosition(_THIS, SDL_Window * window)
|
|||
[nswindow setFrameOrigin:rect.origin];
|
||||
s_moveHack = moveHack;
|
||||
|
||||
if (window == _this->current_glwin) {
|
||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
|
@ -690,12 +706,18 @@ void
|
|||
Cocoa_SetWindowSize(_THIS, SDL_Window * window)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
SDL_WindowData *windata = (SDL_WindowData *) window->driverdata;
|
||||
NSWindow *nswindow = windata->nswindow;
|
||||
NSSize size;
|
||||
|
||||
size.width = window->w;
|
||||
size.height = window->h;
|
||||
[nswindow setContentSize:size];
|
||||
|
||||
if (window == _this->current_glwin) {
|
||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
|
@ -738,6 +760,11 @@ Cocoa_MaximizeWindow(_THIS, SDL_Window * window)
|
|||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
|
||||
[nswindow zoom:nil];
|
||||
|
||||
if (window == _this->current_glwin) {
|
||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
|
@ -856,6 +883,10 @@ Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display
|
|||
#endif
|
||||
[nswindow makeKeyAndOrderFront:nil];
|
||||
|
||||
if (window == _this->current_glwin) {
|
||||
[((NSOpenGLContext *) _this->current_glctx) update];
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue