-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathTransparent.mm
More file actions
35 lines (28 loc) · 949 Bytes
/
Transparent.mm
File metadata and controls
35 lines (28 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <SFML/Graphics.hpp>
#import <Cocoa/Cocoa.h>
@implementation NSOpenGLView (Opaque)
-(BOOL)isOpaque
{
return NO;
}
@end
// While this functions will set a custom shape for the window, mouse events may not pass through
// the clipped parts of the window to the windows behind it. If you want this, then you can
// check out https://gist.github.com/iman-zamani/519e241916aeaa0c26e9f4787884f5bf
bool setShape(sf::WindowHandle handle, const sf::Image& image)
{
NSWindow* wnd = (NSWindow*)handle;
GLint opaque = 0;
[[[wnd contentView] openGLContext] setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity];
[wnd setBackgroundColor:[NSColor clearColor]];
[wnd setOpaque:NO];
return true;
}
bool setTransparency(sf::WindowHandle handle, unsigned char alpha)
{
NSWindow* wnd = (NSWindow*)handle;
CGFloat opacity = alpha / 255.0f;
[wnd setAlphaValue:opacity];
[wnd setOpaque:NO];
return true;
}