I'm trying to figure out how to get a BlitzMax screensaver to work on a Mac. I found working Windows code on the forums which is cool but irrelevant to Mac.
I read a few websites that sort of point the direction but of course mainly in C or Java and with little clue of how to integrate with BlitzMax.
From what I understand so far, it's not quite the same as on Windows. In Windows our screensaver exe basically can do whatever it likes, it deals with opening its own screen and closing it and setting up its own event handling and basically is just a regular program that gets called with some flags passed to it to select whether to do fullscreen, a preview, or a configuration. Of course the details of the preview window involve interacting with Windows but it appears to work from what I've read. This seems like a pretty simple arrangement.
On the Mac a screensaver seems to be built around the screensaver/screensaver.h include file which is in something like C, maybe C++ or Objective C. That seems to imply that the screensaver has to be coded IN C, or written in some other language and imported into the C program and compiled within the XCode IDE. It seems that you get given an NSView screen by default which also seems not to be double buffered, and you get this system timer that calls a function for each frame to render. So you need to add any blitz code to get called within that framework which sounds like the reverse of having blitz include the header files.
So the issue then is how to be calling blitz code from within a C program. This makes it C-centric and not blitz-centric, plus the problem of needing to open a proper OpenGL graphics display or using MaxGUI for configuration (which Mac refers to as a `sheet` which slides into view within the Screensaver preference window. I can see that it would be fairly simple to code a screensaver in C, but how would one go about including BlitzMax routines to do all the graphics? Compiling the default setup for a screensaver in XCode actually does make a working screensaver, except that you basically just have a black screen and nothing to look at.
One idea I thought is to actually use XCode to compile the exe, and to have BlitzMax's compiler generate linkable files or something that could be linked into the XCode project within the functions that get called. But even if that is possible, how would C then call the appropriate pieces of code, e.g. the config panel, the startup, shutdown, and per-frame-update? It would be much nicer if the whole thing could just be a regular BlitzMax-centric app including any necessary C bits. But I don't know that that would work. It seems that MacOS runs a generic screensaver handler program which then executes the selected screensaver itself... so the screensaver IS just a regular program, but it's a C-based program.
Has anyone tried to get this working in a Max compatible way? Any code to share? Anyone like to take a stab at coming up with the basic pieces needed to make a Mac screensaver? It looks like the below code is the basic structure of the C screensaver program. I don't understand some parts of it. Any help getting proper screensavers to work on the mac would be much appreciated!
I read a few websites that sort of point the direction but of course mainly in C or Java and with little clue of how to integrate with BlitzMax.
From what I understand so far, it's not quite the same as on Windows. In Windows our screensaver exe basically can do whatever it likes, it deals with opening its own screen and closing it and setting up its own event handling and basically is just a regular program that gets called with some flags passed to it to select whether to do fullscreen, a preview, or a configuration. Of course the details of the preview window involve interacting with Windows but it appears to work from what I've read. This seems like a pretty simple arrangement.
On the Mac a screensaver seems to be built around the screensaver/screensaver.h include file which is in something like C, maybe C++ or Objective C. That seems to imply that the screensaver has to be coded IN C, or written in some other language and imported into the C program and compiled within the XCode IDE. It seems that you get given an NSView screen by default which also seems not to be double buffered, and you get this system timer that calls a function for each frame to render. So you need to add any blitz code to get called within that framework which sounds like the reverse of having blitz include the header files.
So the issue then is how to be calling blitz code from within a C program. This makes it C-centric and not blitz-centric, plus the problem of needing to open a proper OpenGL graphics display or using MaxGUI for configuration (which Mac refers to as a `sheet` which slides into view within the Screensaver preference window. I can see that it would be fairly simple to code a screensaver in C, but how would one go about including BlitzMax routines to do all the graphics? Compiling the default setup for a screensaver in XCode actually does make a working screensaver, except that you basically just have a black screen and nothing to look at.
One idea I thought is to actually use XCode to compile the exe, and to have BlitzMax's compiler generate linkable files or something that could be linked into the XCode project within the functions that get called. But even if that is possible, how would C then call the appropriate pieces of code, e.g. the config panel, the startup, shutdown, and per-frame-update? It would be much nicer if the whole thing could just be a regular BlitzMax-centric app including any necessary C bits. But I don't know that that would work. It seems that MacOS runs a generic screensaver handler program which then executes the selected screensaver itself... so the screensaver IS just a regular program, but it's a C-based program.
Has anyone tried to get this working in a Max compatible way? Any code to share? Anyone like to take a stab at coming up with the basic pieces needed to make a Mac screensaver? It looks like the below code is the basic structure of the C screensaver program. I don't understand some parts of it. Any help getting proper screensavers to work on the mac would be much appreciated!
#import "MySaverView.h" @implementation MySaverView - (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview { self = [super initWithFrame:frame isPreview:isPreview]; if (self) { [self setAnimationTimeInterval:1/30.0]; } return self; } - (void)startAnimation { [super startAnimation]; } - (void)stopAnimation { [super stopAnimation]; } - (void)drawRect:(NSRect)rect { [super drawRect:rect]; } - (void)animateOneFrame { return; } - (BOOL)hasConfigureSheet { return NO; } - (NSWindow*)configureSheet { return nil; } @end