I am trying to get the programmable renderer working with a screen saver. The screen saver must extend Apple’s ScreenSaverView which extends NSView. I have achieved a working screen saver with 08, but now need it to work with the programmable renderer in 09.
This is what I am using to create the NSOpenGL pixels format
NSOpenGLPixelFormatAttribute attributes[] = {
NSOpenGLPFAAccelerated,
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
NSOpenGLPFADoubleBuffer,
//NSOpenGLPFAMultiScreen,
NSOpenGLPFASampleBuffers, 1,
NSOpenGLPFASamples, 8,
NSOpenGLPFADepthSize, 24,
NSOpenGLPFAAlphaSize, 8,
NSOpenGLPFAColorSize, 24,
NSOpenGLPFANoRecovery,
(NSOpenGLPixelFormatAttribute)0
};
The screen saver compiles. But when I try to run it, I get a crash. Below is the log.
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 ??? 000000000000000000 0 + 0
1 cc.designio.ElementsScreenSaver 0x0000000105d88e54 ofShader::checkAndCreateProgram() + 164
2 cc.designio.ElementsScreenSaver 0x0000000105d880b8 ofShader::setupShaderFromSource(unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 56
3 cc.designio.ElementsScreenSaver 0x0000000105dc7cca ofGLProgrammableRenderer::setup(int, int) + 122
4 cc.designio.ElementsScreenSaver 0x0000000104edac7d ofxScreenSaverWindow::setup(ofxScreenSaverWindowSettings const&) + 429
5 cc.designio.ElementsScreenSaver 0x0000000104ed4c6a ofxScreenSaverApp::setupOpenGL(int, int, bool) + 298
6 cc.designio.ElementsScreenSaver 0x0000000104ed3f08 -[ofxScreensaverElementsScreenSaverBase startAnimation] + 632
7 com.apple.CoreFoundation 0x00007fff8a361cd0 -[NSArray makeObjectsPerformSelector:] + 480
8 com.apple.ScreenSaver 0x00007fff959b0252 -[ScreenSaverEngine startScreenSaver:] + 8747
9 com.apple.ScreenSaver 0x00007fff959adf03 -[ScreenSaverEngine applicationDidFinishLaunching:] + 1415
10 com.apple.CoreFoundation 0x00007fff8a3e9e0c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
11 com.apple.CoreFoundation 0x00007fff8a2dd82d _CFXNotificationPost + 2893
12 com.apple.Foundation 0x00007fff8ac55e4a -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
13 com.apple.AppKit 0x00007fff93938b69 -[NSApplication _postDidFinishNotification] + 289
14 com.apple.AppKit 0x00007fff9393889c -[NSApplication _sendFinishLaunchingNotification] + 195
15 com.apple.AppKit 0x00007fff93935786 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 570
16 com.apple.AppKit 0x00007fff939351db -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 242
17 com.apple.Foundation 0x00007fff8ac7459a -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 294
18 com.apple.Foundation 0x00007fff8ac7440d _NSAppleEventManagerGenericHandler + 106
19 com.apple.AE 0x00007fff8ee2de1f aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 381
20 com.apple.AE 0x00007fff8ee2dc32 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 31
21 com.apple.AE 0x00007fff8ee2db36 aeProcessAppleEvent + 315
22 com.apple.HIToolbox 0x00007fff8cf62161 AEProcessAppleEvent + 56
23 com.apple.AppKit 0x00007fff939310b6 _DPSNextEvent + 1026
24 com.apple.AppKit 0x00007fff9393089b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
25 com.apple.ScreenSaver.Engine 0x0000000100750879 -[ScreenSaverApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 49
26 com.apple.AppKit 0x00007fff9392499c -[NSApplication run] + 553
27 com.apple.ScreenSaver.Engine 0x00000001007506ec main + 550
28 libdyld.dylib 0x00007fff976985fd start + 1
Not sure what else I have to invoke to get the programmable renderer working in this environment.
This is how I create the programmable renderer.
if( settings.glVersionMajor>=3 ){
// glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE );
currentRenderer = shared_ptr<ofBaseRenderer>( new ofGLProgrammableRenderer(this) );
} else {
currentRenderer = shared_ptr<ofBaseRenderer>( new ofGLRenderer(this) );
}
NSLog(@"ofxScreenSaverWindow :: about to setup the programmable renderer." );
if(currentRenderer->getType()==ofGLProgrammableRenderer::TYPE) {
static_cast<ofGLProgrammableRenderer*>(currentRenderer.get())->setup(settings.glVersionMajor,settings.glVersionMinor);
} else {
static_cast<ofGLRenderer*>(currentRenderer.get())->setup();
}
NSLog(@"ofxScreenSaverWindow :: dims %i x %i", windowW, windowH );
Is this glfw hit necessary to use the programmable renderer?
glfwWindowHint( GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE );
Is there a way to route the debug output to the Console application? I can see the output of NSLog, but now of ofLogWarning and it would be really helpful for debugging.