View Full Version : open gl screen saver

11-03-2000, 06:09 AM
I am 15 and have been programming in DOS for about a year with DJGPP. I have recently attempted to program in windows with open gl with DEV-C++. My question is: How do you turn your program into a screen saver? I know that this question is more related to the windows OS, but I figured you guys (and gals) would know. Thanks.

11-03-2000, 06:27 AM
I'm not familar with Dev-c++, but there is a common screen-saver library that is useful for creating screensavers. If you were using VC++, I would have a simple appwizard that sets up the framework for you. You can also just rename an .exe to an .scr, but IMO, it's more convenient to use the screensaver library. It handles things for you like the preview, password protection, closing on mouse or keyboard events, etc..

A good source of information on creating Windows screensavers can be found at http://www.msdn.microsoft.com/library/default.asp?URL=/library/psdk/shellcc/Shell/ScrnSave.htm

You can also e-mail me and I'll be glad to try and help you out.

11-03-2000, 06:45 AM
If you get MSVC++ there's documentation about this. But aside from that, all I know about it (I have not made one myself yet) is that a screensaver is just a .EXE with the extension of .SCR with a couple of exceptions. A screensaver has a couple of callback routines you have to implement. And I seem to remember someone posting that they were using some sort of Microsoft base classes or examples of screensavers (a library?) somwhere. If anyone knows of any such base classes/examples/libraries, please post. Beyond this, I know that you still have to code things like detecting mouse movement and so forth to trigger the automatic exitting of the app. But I think once the screensaver is installed, Windows will automatically launch it when the time limit has been reached. I think the special callbacks are for the setting of peroperties and the other special functions of screensavers such as the little preview window in display properties.

11-03-2000, 08:18 AM
If you decide to do it as an exe, then rename it to an scr, you have to check for a couple of command-line parameters. I don't remember what they are offhand. One is to run the screensaver, the other is to run the dialog box. Using Win32's screensaver library, you have to implement and export a couple of callback functions. One is a standard window's message loop with the exception that you call DefaultScreenSaverProc (or somethng like that) for unhandled messages. The other is the procedure for the dialog box. If I remember correctly, there is also one or two other functions that need to be created.

The URL I posted above gives all these details and more.

11-03-2000, 09:07 AM
Thankyou. I am sure I can figure it out from that. Thanks for you time!

11-06-2000, 11:05 AM
Creating a screensaver in Windows is pretty easy. You need to define three basic functions.


This is the function that defines what your screensaver actually does, i.e. graphics or whatever. This is also where you would handle any messages that are generated.

I can't remember the names of the other two functions, but they don't do anything unless you want to save your screensaver's settings in the registry.

Be sure to include scrnsave.h in your code, and to link scrnsave.lib when compiling everything. Hope this helps.


11-09-2000, 04:19 AM
Here's the lowdown.

the jibe on implementing callbacks and including windows scrnsave.h just makes the whole process easier (and handles things like password protection, which is different ((a little bit)) between W95, W98, and NT).

To actually get the thing going, in a normal sense, you need to do two things, implement handlers for when you are pased
-s, and -p XXXX on the command line.
-s is supposed to run the screensaver in full screen mode. -p XXXX (where XXXX is the HWND of the little screensaver preview window in Display settings) is for preview.

There are afew good pages that describe all the command line options that are passed in different situations, but that's all they are, command line switches (you know the
LPCTSTR lpCmdLine bit).

The main thing to keep in mind is not to run the screensaver in fullscreen mode if called from the preview window. override -p XXXX to do nothing if you want, but override it.

(oh yeah, and they're just renamed .exe's)

(sorry, I'm tired, but thats the lowdown)

Tim Scott