NSOpenGLView with broken -initWithFrame: in Xcode 6?
NSOpenGLView with broken -initWithFrame: in Xcode 6?
- Subject: NSOpenGLView with broken -initWithFrame: in Xcode 6?
- From: Jochen Moeller <email@hidden>
- Date: Fri, 31 Oct 2014 17:23:30 +0100
Hello all,
The normal way to init an NSOpenGLView subclass seems no longer to be
possible in Xcode 6 and Yosemite (Xcode 6.1, OS X 10.10, Mac Pro 2010).
See also WWDC-2014 session page 44 in
601_harnessing_the_power_of_the_mac_pro_with_opengl_and_opencl.pdf
Demo:
New Cocoa App "OpenGLInitDemo", all other options are switched off.
Link to OpenGL.framework.
Subclass of NSOpenGLView: DemoGLView with the Listing below.
MainMenu.xib: NSView template (Custom View) linked to DemoGLView.
Then Run. The window is not colored (white) and the Log is:
2014-10-31 15:12:39.207 OpenGLInitDemo[758:20688] DemoGLView - prepareOpenGL
ATI Radeon HD 5870 OpenGL Engine - 2.1 ATI-1.28.29 - Shading language
version: 1.20
2014-10-31 15:12:39.207 OpenGLInitDemo[758:20688] DemoGLView - drawRect:
So instead of version 4.10 the version 1.20 is installed,
-initWithFrame: is not invoked.
But this demo works well when created with Xcode 5.1.1 and OS X 10.9.5
and the Log is:
2014-10-31 13:14:11.126 OpenGLInitDemo[1646:303] DemoGLView - initWithFrame:
2014-10-31 13:14:13.110 OpenGLInitDemo[1646:303] DemoGLView - prepareOpenGL
ATI Radeon HD 5870 OpenGL Engine - 4.1 ATI-1.24.38 - Shading language
version: 4.10
2014-10-31 13:14:13.110 OpenGLInitDemo[1646:303] DemoGLView - drawRect:
-initWithFrame: is invoked, the window is colored and version 4.10 is
installed.
When opening this working demo with Xcode 6.1 and OS X 10.10 then it
remains working even after changing the target from OSX 10.9 to 10.10.
2014-10-31 15:05:29.415 OpenGLInitDemo[728:18987] DemoGLView -
initWithFrame:
2014-10-31 15:05:29.448 OpenGLInitDemo[728:18987] DemoGLView - prepareOpenGL
ATI Radeon HD 5870 OpenGL Engine - 4.1 ATI-1.28.29 - Shading language
version: 4.10
2014-10-31 15:05:29.449 OpenGLInitDemo[728:18987] DemoGLView - drawRect:
This Log I expected after creating the demo with Xcode 6.1 and OS X 10.10.
So what is the best solution? Bugreport or have I overlooked something?
Thanks
Jochen Moeller
The Listing:
// DemoGLView.h
#import <Cocoa/Cocoa.h>
#import <OpenGL/gl3.h>
@interface DemoGLView : NSOpenGLView
@end
// DemoGLView.m
#import "DemoGLView.h"
@implementation DemoGLView
- (id)initWithFrame:(NSRect)frame {
NSLog(@"%@ - %@", [self className], NSStringFromSelector(_cmd));
NSOpenGLPixelFormatAttribute attrs[] = {
NSOpenGLPFADoubleBuffer, NSOpenGLPFADepthSize, 24,
NSOpenGLPFAColorSize, 24, NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
NSOpenGLPFAAccelerated, 0
};
NSOpenGLPixelFormat *pf = [[ NSOpenGLPixelFormat alloc ]
initWithAttributes:attrs ];
if ( ! pf ) {
fprintf( stderr, "No valid OpenGL pixel format -> Quit.\n" );
[ NSApp terminate:self ];
}
self = [ super initWithFrame:frame pixelFormat:pf ];
// if (self) { }
return self;
}
- (void)prepareOpenGL {
NSLog(@"%@ - %@", [self className], NSStringFromSelector(_cmd));
printf("%s - %s - Shading language version: %s\n",
glGetString(GL_RENDERER), glGetString(GL_VERSION),
glGetString(GL_SHADING_LANGUAGE_VERSION));
glClearColor( 0.5f, 0.5f, 0.0f, 1.0f );
}
- (void)drawRect:(NSRect)updateRect {
[super drawRect:updateRect];
NSLog(@"%@ - %@", [self className], NSStringFromSelector(_cmd));
glClear( GL_COLOR_BUFFER_BIT );
[[ self openGLContext ] flushBuffer ];
}
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden