Pages: [1] 2
Author Topic: Screen Saver  (Read 2992 times)
vanderlin
Cambridge

Posts: 264

Gravatar


WWW
Screen Saver
« on: March 13, 2009, 10:23:04 PM »

I was wondering if it is possible to create a c++ app in objective c. I was trying to use the screensaver.framework for osx to build a screen saver.

Does anyone know if this is possible?
« Last Edit: January 01, 1970, 01:00:00 AM by vanderlin » Logged
hahakid
London

Posts: 143

Gravatar


WWW
(No subject)
« Reply #1 on: March 14, 2009, 01:07:00 AM »

I found these pretty helpul with making OSX screensavers:


http://cocoadevcentral.com/articles/000088.php

http://cocoadevcentral.com/articles/000089.php


http://www.mactech.com/articles/mactech ... urScreens/

http://www.mactech.com/articles/mactech ... creens102/


/A
« Last Edit: January 01, 1970, 01:00:00 AM by hahakid » Logged

vanderlin
Cambridge

Posts: 264

Gravatar


WWW
(No subject)
« Reply #2 on: March 17, 2009, 07:07:37 PM »

were you able to compile OF as a screensaver? I was asking memo about it and he said I would need to replace glut.
« Last Edit: January 01, 1970, 01:00:00 AM by vanderlin » Logged
hahakid
London

Posts: 143

Gravatar


WWW
(No subject)
« Reply #3 on: March 17, 2009, 08:54:35 PM »

I wasn't using OF I'm afraid, just plain C++ and some Objective-C.


/A
« Last Edit: January 01, 1970, 01:00:00 AM by hahakid » Logged

memo
London, UK

Posts: 747

Gravatar

I like to touch people and make them giggle or cry


WWW
(No subject)
« Reply #4 on: March 18, 2009, 12:16:02 PM »

Now that OF has the glut abstraction in place, it shouldn't be too hard to create an addon to remove glut and provide a native cocoa layer to run openFrameworks - similar to ofxiPhone (e.g. ofxCocoa or ofxOSX). Then you'd have full control of the window creation and there'd be no issues making screensavers (or using other osx frameworks or even making quartz composer plugins!). This has been on my todo list for a while but not had time :o
« Last Edit: January 01, 1970, 01:00:00 AM by memo » Logged
theo
Administrator
Amsterdam

Posts: 1090

Gravatar


WWW
Re: Screen Saver
« Reply #5 on: June 24, 2009, 07:25:45 PM »

ofAppCocoaWindow now exists:
http://forum.openframeworks.cc/index.php/topic,2200.msg11872.html#msg11872
Logged

moka
Kiel - Germany

Posts: 409

Gravatar


WWW
Re: Screen Saver
« Reply #6 on: June 24, 2009, 07:40:29 PM »

SWEET YEAH!
Logged
memo
London, UK

Posts: 747

Gravatar

I like to touch people and make them giggle or cry


WWW
Re: Screen Saver
« Reply #7 on: June 24, 2009, 07:54:09 PM »

Damn yea!
Logged
theo
Administrator
Amsterdam

Posts: 1090

Gravatar


WWW
Re: Screen Saver
« Reply #8 on: June 26, 2009, 12:48:12 PM »

Okay I have OF running as a screensaver.



Webcam seems to work too


Only thing that doesn't seem to work is FMOD because the dylib has to be copied to the MAC_OS folder in myScreenSaver.saver/Contents/MAC_OS . The copying is fine but the @executable_path command we use in the build script for setting the dylib path fails because .saver is not an executable.

There is more info about the issue here:
http://forum.soft32.com/mac/Including-f ... 44390.html

Also I found this gem! A way to debug a screensaver on the command line.
Code:
/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -module RandomWeb -foreground 

RandomWeb being the name of the screensaver.

This is so much better than the generic error System Preferences give you when you have an error in your code.

BTW most of this effort is based on the guide Andreas posted - so big thanks!
http://cocoadevcentral.com/articles/000089.php

Code posted in next post.
Logged

theo
Administrator
Amsterdam

Posts: 1090

Gravatar


WWW
Re: Screen Saver
« Reply #9 on: June 26, 2009, 12:58:10 PM »

Okay so here is the example project.

the openFrameworks folder is included in the project folder because I had to comment out some FMOD related code to make it work.

the only other change that is needed is to modify freeimage.h

find the line:
Code:
typedef int32_t BOOL;

and change it to:
Code:
//typedef int32_t BOOL;
#define BOOL int32_t

Also a thing to note is that sometimes the system preferences doesn't re-load the screensaver correctly. so you have to right click on it in the list and remove it and then close system preferences and re-add it.

the screensaver can be found in Build/Debug/

I have not done anything yet in relation to the data/ folder that will come next.

Also be aware of the symbol clash issue described at the end here: http://cocoadevcentral.com/articles/000089.php
Basically it means you might not be able to have multiple screen savers with the same names / class names running at the same time.

Theo

* ofScreenSaver003-PolygonExample.zip (147.41 KB - downloaded 182 times.)
Logged

moka
Kiel - Germany

Posts: 409

Gravatar


WWW
Re: Screen Saver
« Reply #10 on: June 26, 2009, 01:06:20 PM »

great, thanks theo, what target do you have to define for a screensaver?  Is that a .bundle? I could not find .saver type targets so maybe you could clear that up for me.
Logged
theo
Administrator
Amsterdam

Posts: 1090

Gravatar


WWW
Re: Screen Saver
« Reply #11 on: June 26, 2009, 01:19:20 PM »

no idea :D

I just took a screensaver template project and hacked OF in.

one thing that would be good is to have two targets for a project - one that builds it as a cocoa window and another as a screensaver - that way it would be a lot faster to test stuff.
Logged

moka
Kiel - Germany

Posts: 409

Gravatar


WWW
Re: Screen Saver
« Reply #12 on: June 26, 2009, 01:55:25 PM »

yes, I just checked it and it seems to be a .boundle. no idea about the details though. Just out of curiosity I will try to build a project from scracth the next days :)
Logged
sth
Hamburg

Posts: 114

Gravatar


WWW
Re: Screen Saver
« Reply #13 on: June 26, 2009, 03:52:49 PM »

Quote from: "theo"
Okay I have OF running as a screensaver.
Only thing that doesn't seem to work is FMOD because the dylib has to be copied to the MAC_OS folder in myScreenSaver.saver/Contents/MAC_OS . The copying is fine but the @executable_path command we use in the build script for setting the dylib path fails because .saver is not an executable.

You can adjust the loader_path of the plugin with install_name_tool, set it to @loaderpath instead of @executable_path this will circumvent the problem

For more info do a google search for install_name_tool and loader_path / bundle

HTH,
Stephan
Logged

theo
Administrator
Amsterdam

Posts: 1090

Gravatar


WWW
Re: Screen Saver
« Reply #14 on: June 26, 2009, 04:47:04 PM »

oh thats awesome - thanks!
that should do the trick.

I also have the same problem with loading files - currently I have to hardcode the data path in, but I think I should be able to get the screensaver's current path then set that as the data path on runtime.

Theo
Logged

Pages: [1] 2
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines
kinect

viagra priser