📄 camphill.dpr
字号:
program Camphill;
{(c) 1999 Production Robots Engineering Ltd
{this program implements an OpenGL Sceensaver. This program
does not use the VCL - this is appropriate as OpenGL programming
is an entirely seperate matter.
The VCL would be useful for dialog box, but seems a bit of an
overkill so I have done it the old-fashioned windows way. You
will need a resource editor if you want to do the same.
If you want to use the VCL then you will have to put all that
Application.CreateForm stuff that Delphi does inside a Setup
Function which you pass to DoScreenSaver. You don't want the VCL to
do anything in preview and run modes. It would just get in the way
Example of doing the config dialog with the VCL
procedure VCLDoSetup(Wnd: hWnd);
begin
Application.Initialize;
Application.CreateForm(TConfigDialog, ConfigDialog);
Application.Run;
end;
Pass this function as the ConfigurationFunction to DoScreensaver. You will
also need to use Forms and your ConfigDialogUnit. I have not tried this
but it should work
Doing this will add about 300kB to your screensaver!
To Create your own OpenGL screensaver you will need to
1) Modify CamphillOGL.InitialiseOGL to set up the data you will want to
render your scene. You will have to read your settings from the registry.
2) Modify Camphill.RunOGL to render your scene. This will be called regularly and
if you want to animate your scene (you do) then you will need to update your
state variables here.
3) Modify Camphill.DoneOGL to clean up data specific to your scene.
4) Modify CamphillSetup to deal with the settings appropriate to your screensaver
You don't need to modify Screensaver.pas. The function DoScreensaver handles all the
screensaver mechanics: parameters, passwords, window creation etc.. etc.. The window
you must draw on is passed to your Run procedure. You shouldn't need to worry about
whether it is preview or full screen mode - although this information is passed into
the initialisation procedure in case you want to render your scene differently in each
case.
Note that a screensaver never changes mode while it is running. To go from little
preview to config to big preview to run etc.. Windows restarts the program with the
appropriate parameter. This is why it is a good idea to try and keep the programs small
and fast loading.
This program uses OpenGL units from Mike Lischke which are a lot more complete than
the Borland units (Borland unit still do not support arrays - which the red book seems
to treat as a given). We should all be grateful for Mike's efforts - although what I
would really like is an implicitly linked unit which doesn't have a load of stuff
missing (I can see that these two wishes are pretty much mutually exclusive) I guess
one advantage of explicit linking for a screensaver is that you don't need to bind to
OpenGL at all in configuration mode, which is nice.
If you are trying to build with Delphi 3 or 4 you may have to rename camphill.rc to
something else and compile the resources outside the ide
i.e
brcc32 camphill.rc
I don't think D 3/4 support the *.res *.rc syntax
}
{$R 'camphill.res' 'camphill.rc'}
{%File 'Camphill.inc'}
uses
ScreenSaver in 'ScreenSaver.pas',
CamphillOGL in 'CamphillOGL.pas',
CamphillSetup in 'CamphillSetup.pas',
glFont in 'glFont.pas',
OpenGL12 in 'OpenGL12.pas',
Geometry in 'Geometry.pas';
{$E SCR}
begin
ScreenSaver.DoScreenSaver(
CamphillOGL.InitialiseOGL, {initialisation function called before saver starts to run}
CamphillOGL.RunOGL, {called periodically while saver is running}
CamphillOGL.DoneOGL, {called when saver is stopped}
CamphillSetup.DoSetup, {called when saver is opened in 'config mode'i.e Settings... button}
50) {time period (ms) between calls to RunFunction}
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -