Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 40

Thread: EyeCandy Contest

  1. #21

    EyeCandy Contest

    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.

  2. #22

    EyeCandy Contest

    What Linux C developers do is use the xscreensaver API. Here is a description:

    ================================================== ========================
    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.
    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?

    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]

  3. #23

    EyeCandy Contest

    Quote Originally Posted by dmantione
    a screensaver is just a normal program that runs full screen.
    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.

    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]

  4. #24
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    EyeCandy Contest

    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)

  5. #25

    EyeCandy Contest

    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]

  6. #26
    Legendary Member cairnswm's Avatar
    Join Date
    Nov 2002
    Location
    Randburg, South Africa
    Posts
    1,537

    EyeCandy Contest

    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)

  7. #27

    EyeCandy Contest

    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.

  8. #28

    EyeCandy Contest

    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]

  9. #29

    EyeCandy Contest

    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]

  10. #30

    EyeCandy Contest

    No, I haven't tested it, so you are probably right.

Page 3 of 4 FirstFirst 1234 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •