mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Cocoa: Implement GLFW_TRANSPARENT
This is an extract of a commit, minimally edited to ensure it compiles. Closes #663. Related to #197.
This commit is contained in:
parent
51f0cd3b51
commit
ac009a5f5c
@ -413,7 +413,11 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
||||
|
||||
- (BOOL)isOpaque
|
||||
{
|
||||
return YES;
|
||||
// Set to NO even if alphaMask is not used;
|
||||
// The NSView/GLFWContentView does not need to be opaque anyway,
|
||||
// and to avoid keeping track of alphaMask inside the NSView we
|
||||
// just return NO here instead.
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)canBecomeKeyView
|
||||
@ -1081,6 +1085,12 @@ static GLFWbool createNativeWindow(_GLFWwindow* window,
|
||||
if (wndconfig->ns.retina)
|
||||
[window->ns.view setWantsBestResolutionOpenGLSurface:YES];
|
||||
|
||||
if (window->transparent)
|
||||
{
|
||||
[window->ns.object setOpaque:NO];
|
||||
[window->ns.object setBackgroundColor:[NSColor clearColor]];
|
||||
}
|
||||
|
||||
[window->ns.object setContentView:window->ns.view];
|
||||
[window->ns.object makeFirstResponder:window->ns.view];
|
||||
[window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
|
||||
|
@ -296,6 +296,12 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
if (window->transparent)
|
||||
{
|
||||
GLint opaque = 0;
|
||||
[window->context.nsgl.object setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];
|
||||
}
|
||||
|
||||
[window->context.nsgl.object setView:window->ns.view];
|
||||
|
||||
window->context.makeCurrent = makeContextCurrentNSGL;
|
||||
|
Loading…
Reference in New Issue
Block a user