aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-06-29 12:45:24 +0200
committerDavid Robillard <d@drobilla.net>2019-06-29 12:45:24 +0200
commitb81dbe03ac16e4c5ccf3bcfd6795f476299a3852 (patch)
treea56f8630357e70ca78c4ae5ff99b90b4a01accab
parentaa9eafb77d8122553d3090107a7f9c732817f64a (diff)
Implement attributes on MacOS
-rw-r--r--pugl/pugl_osx.m25
1 files changed, 18 insertions, 7 deletions
diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m
index 1503034..e226a19 100644
--- a/pugl/pugl_osx.m
+++ b/pugl/pugl_osx.m
@@ -147,15 +147,25 @@ struct PuglInternalsImpl {
- (id) initWithFrame:(NSRect)frame
{
+ const int major = puglview->hints.context_version_major;
+ const int profile = ((puglview->hints.use_compat_profile || major < 3)
+ ? NSOpenGLProfileVersionLegacy
+ : puglview->hints.context_version_major >= 4
+ ? NSOpenGLProfileVersion4_1Core
+ : NSOpenGLProfileVersion3_2Core);
+
NSOpenGLPixelFormatAttribute pixelAttribs[16] = {
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
- NSOpenGLPFAColorSize, 32,
- NSOpenGLPFADepthSize, 32,
- 0
- };
-
- NSOpenGLPixelFormat* pixelFormat = [
+ NSOpenGLPFAOpenGLProfile, profile,
+ NSOpenGLPFAColorSize, 32,
+ NSOpenGLPFADepthSize, 32,
+ NSOpenGLPFAMultisample, puglview->hints.samples ? 1 : 0,
+ NSOpenGLPFASampleBuffers, puglview->hints.samples ? 1 : 0,
+ NSOpenGLPFASamples, puglview->hints.samples,
+ 0};
+
+ NSOpenGLPixelFormat *pixelFormat = [
[NSOpenGLPixelFormat alloc] initWithAttributes:pixelAttribs];
if (pixelFormat) {
@@ -580,8 +590,9 @@ puglCreateWindow(PuglView* view, const char* title)
[NSAutoreleasePool new];
impl->app = [NSApplication sharedApplication];
- impl->glview = [PuglOpenGLView new];
+ impl->glview = [PuglOpenGLView alloc];
impl->glview->puglview = view;
+ [impl->glview init];
[impl->glview setFrameSize:NSMakeSize(view->width, view->height)];
[impl->glview addConstraint: