FPC is really good and I maintaining compatiblity of all my projects with it.
But Linux is not in my plans yet (at least for next 2-3 months).
Another barrier for me is open sources. It's ok for an entry itself but not for entire framework/engine.
FPC is really good and I maintaining compatiblity of all my projects with it.
But Linux is not in my plans yet (at least for next 2-3 months).
Another barrier for me is open sources. It's ok for an entry itself but not for entire framework/engine.
What Linux C developers do is use the xscreensaver API. Here is a description:
So you can see it's quite easy to do it in C. It seems that we would need to translate all of the xscreensaver code, or the guts of it, to get a Pascal version working. Or maybe just the screenhack.h header?================================================== ========================
The XScreenSaver API
================================================== ========================
- Start with #include "screenhack.h"
- Define 2 global variables:
yoursavername_defaults -- Default values for the resources you use.
yoursavername_options -- The command-line options you accept.
- Define 5 functions:
yoursavername_init -- Return an object holding your global state.
yoursavername_draw -- Draw a single frame, quickly.
yoursavername_free -- Free everything you've allocated.
yoursavername_reshape -- Called when the window is resized.
yoursavername_event -- Called when a keyboard or mouse event happens.
The "reshape" and "event" functions are only
called when running in a window (not as a
screen saver). It's ok for them to do nothing.
- All other functions should be static.
- The last line of the file should be
XSCREENSAVER_MODULE ("YourSaverName", yoursavername)
- Finally, edit the Makefile to add a rule for your program.
Just cut-and-paste one of the existing rules.
Your "draw" must not run for more than a fraction of a second without
returning. This means "don't call usleep()". Everything has to be a
state machine.
You may not store global state in global variables, or in function-local
static variables. All of your runtime state must be encapsulted in the
"state" object created by your "init" function. If you use global or
static variables, your screen saver will not work properly on MacOS.
Do not call XSync() or XFlush(). If you think you need to do that, it
probably means that you are you are relying on the speed of the graphics
card for timing, which probably means that your "draw" function is
taking too long.
I think this should be a challenge. Write a Linux screensaver in Object Pascal!
[size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]
Except that you're not finished. A screensaver is a program that runs full screen after a set time interval of user-input inactivity. You need to find some way to monitor user-input activity, and when there is no such activity after the specified time, you can then start the full-screen program. On Linux the vast majority of screensaver developers let xscreensaver monitor user-input activity, and then simply interface their full screen program with xscreensaver.Originally Posted by dmantione
So the task for Free Pascal developers on Linux is to either find out how to properly interface with xscreensaver (which nearly every Linux user uses), or create our own user-activity monitoring software and interface with that. The disadvantage with the latter method is that to use our screensaver, nearly every Linux user would have to disable their xscreensaver program, which I suspect they would be very loathe to do. Thus, I think it's more desirable to try the former method. That would require someone who is highly skilled in both C and Object Pascal.
I think you begin to see now why there are currently no Linux screensavers written in Free Pascal.
[size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]
Doesn't linux check for the no activity and then call the "screensaver" app. The App needs to check for any input and then exit cleanly.
William Cairns
My Games: http://www.cairnsgames.co.za (Currently very inactive)
MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)
Well, if you consider xscreensaver to be a fundamental part of Linux, then yes. But your program still needs to interface properly with xscreensaver. Maybe it's easier than I think, I will look into it. Edit: Oh and if you interface properly with xscreensaver, you don't need to check for input; your program will be shut down by xscreensaver.
[size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]
Understood. Our plan currently is just to make a series of 2D demo effects. We'll cycle through states showing different effects (and making it easy to use as learning code). And just close based on input. We'll be ignoring the xscreensaver stuff for now.
William Cairns
My Games: http://www.cairnsgames.co.za (Currently very inactive)
MyOnline Games: http://TheGameDeveloper.co.za (Currently very inactive)
xscreensaver will lauch your program based on the configuration file /usr/lib/X11/app-defaults/XScreenSaver. Most screensavers have a command line option to switch between full screen and window. When user input occurs, xscreensaver will shut down your program. So, you don't need to do any weird things, just concentrate on the graphics.
xscreensaver will launch your program, but if your program is not drawing on the X root window, then you can whistle Dixie all you like because you won't see your wonderful special effects on screen since xscreensaver will display the X root window over the top of your window. So you really ought to be drawing on the X root window, which means that you have to get down and dirty with the X windows API. Which will probably force you into using GLX, instead of SDL or GLUT (whose fullscreen modes do not use the root window).
But I may be wrong. Have you tried it yourself? If so, please post some example GLUT or SDL source code, and the line that you add to the xscreensaver config file.
Here's some stuff I found in the xscreensaver manual:
To use a program as a screensaver, two things are required:
that that program draw on the root window (or be able to be
configured to draw on the root window); and that that program
understand ``virtual root'' windows, as used by virtual window
managers such as tvtwm(1). (Generally, this is accomplished by
just including the "vroot.h" header file in the program's
source.)When it is time to activate the screensaver, a full-screen black window
is created on each screen of the display. Each window is created in
such a way that, to any subsequently-created programs, it will appear
to be a ``virtual root'' window. Because of this, any program which
draws on the root window (and which understands virtual roots) can be
used as a screensaver.
[size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]
I have tested it with GLUT and I get the problem I describe in the first paragraph of my previous post. Tomorrow I will test it with SDL.
[size=10px]"In science one tries to tell people, in such a way as to be understood by everyone, something that no one ever knew before. But in poetry, it's the exact opposite." -- Paul Dirac[/size]
No, I haven't tested it, so you are probably right.
Bookmarks