mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 20:28:49 -05:00
Moved to using NSOpenGLView.
This commit is contained in:
parent
4783b17fa3
commit
81bcefe86c
|
@ -96,6 +96,7 @@ GLFW bundles a number of dependencies in the `deps/` directory.
|
|||
- Bugfix: The cursor was not positioned over newly created full screen windows
|
||||
- [Cocoa] Added `_GLFW_USE_RETINA` to control whether windows will use the full
|
||||
resolution on Retina displays
|
||||
- [Cocoa] Made content view subclass of `NSOpenGLView`
|
||||
- [Cocoa] Bugfix: Using a 1x1 cursor for hidden mode caused some screen
|
||||
recorders to fail
|
||||
- [Cocoa] Bugfix: Some Core Foundation objects were leaked during joystick
|
||||
|
|
|
@ -167,8 +167,6 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
|||
|
||||
- (void)windowDidResize:(NSNotification *)notification
|
||||
{
|
||||
[window->nsgl.context update];
|
||||
|
||||
const NSRect contentRect = [window->ns.view frame];
|
||||
const NSRect fbRect = convertRectToBacking(window, contentRect);
|
||||
|
||||
|
@ -182,8 +180,6 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
|||
|
||||
- (void)windowDidMove:(NSNotification *)notification
|
||||
{
|
||||
[window->nsgl.context update];
|
||||
|
||||
int x, y;
|
||||
_glfwPlatformGetWindowPos(window, &x, &y);
|
||||
_glfwInputWindowPos(window, x, y);
|
||||
|
@ -304,7 +300,7 @@ static int translateKey(unsigned int key)
|
|||
// Content view class for the GLFW window
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
@interface GLFWContentView : NSView
|
||||
@interface GLFWContentView : NSOpenGLView
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
NSTrackingArea* trackingArea;
|
||||
|
@ -332,7 +328,8 @@ static int translateKey(unsigned int key)
|
|||
|
||||
- (id)initWithGlfwWindow:(_GLFWwindow *)initWindow
|
||||
{
|
||||
self = [super init];
|
||||
self = [super initWithFrame:NSMakeRect(0, 0, 1, 1)
|
||||
pixelFormat:nil];
|
||||
if (self != nil)
|
||||
{
|
||||
window = initWindow;
|
||||
|
@ -870,15 +867,9 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||
return GL_FALSE;
|
||||
}
|
||||
|
||||
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
||||
{
|
||||
#if defined(_GLFW_USE_RETINA)
|
||||
[window->ns.view setWantsBestResolutionOpenGLSurface:YES];
|
||||
#endif
|
||||
|
||||
if (wndconfig->resizable)
|
||||
[window->ns.object setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
}
|
||||
|
@ -898,7 +889,6 @@ static GLboolean createWindow(_GLFWwindow* window,
|
|||
}
|
||||
|
||||
[window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
|
||||
[window->ns.object setContentView:window->ns.view];
|
||||
[window->ns.object setDelegate:window->ns.delegate];
|
||||
[window->ns.object setAcceptsMouseMovedEvents:YES];
|
||||
|
||||
|
@ -929,6 +919,22 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||
return GL_FALSE;
|
||||
|
||||
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
|
||||
|
||||
#if defined(_GLFW_USE_RETINA)
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
|
||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
|
||||
[window->ns.view setWantsBestResolutionOpenGLSurface:YES];
|
||||
#endif /*MAC_OS_X_VERSION_MAX_ALLOWED*/
|
||||
#endif /*_GLFW_USE_RETINA*/
|
||||
|
||||
[window->ns.object setContentView:window->ns.view];
|
||||
// NOTE: If you set the pixel format before the context it creates another
|
||||
// context, only to have it destroyed by the next line
|
||||
// We cannot use the view to create the context because that interface
|
||||
// does not support context resource sharing
|
||||
[window->ns.view setOpenGLContext:window->nsgl.context];
|
||||
[window->ns.view setPixelFormat:window->nsgl.pixelFormat];
|
||||
[window->nsgl.context setView:window->ns.view];
|
||||
|
||||
if (wndconfig->monitor)
|
||||
|
|
Loading…
Reference in New Issue
Block a user