PDA

View Full Version : Fake weather screensaver


azathothgr
November 18th, 2007, 07:21 PM
Not sure this is the right forum, but here goes.
I've made a screensaver with pyhack (python module for xscreensaver hacks) that simulates weather changes . Everything is fake ofc, just pretty textures moving about, there's no directional light and similar stuff, but it came out looking rather better than I expected.

My code is horrid, and the whole thing is in python which isn't the fastest thing. It can be run with xwinwrap as a desktop background, however, and in my system cpu usage with it running is acceptably low.

To run it you'll need pyhack (http://www.liquidx.net/pyhack/), pyopengl, PIL, and psyco (which is very optional, just remove the 'import' from weather.py if you'd rather not use it).
Either run the 'run' script, which will set is as a desktop background with xwinwrap , or run 'weather.py' ( --nice and --maxfps XX are useful in that case, looks best at 25 to 75 fps)
Also, you can disable some features by setting the variables at the beginning of 'scene.py' to 0. They're pretty self explanatory.

PS: I hope someone would improve my code, or remove the pyhack dependency.. I couldn't find how to do an xscreensaver in python without it.

EDIT: fixed texture dimensions
http://azathothgr.googlepages.com/weather-pt.tar.gz

Screenshots :
http://azathothgr.googlepages.com/w0.jpg
http://azathothgr.googlepages.com/w1.jpg
http://azathothgr.googlepages.com/w2.jpg
http://azathothgr.googlepages.com/w3.jpg
http://azathothgr.googlepages.com/w4.jpg

That's the windows hill btw XD

SmSpillaz
November 19th, 2007, 09:15 AM
Looks cool. Is it possible to add an option to select the wallpaper?

azathothgr
November 19th, 2007, 01:35 PM
Just replace the scenery png with another with about the same dimensions and layout. I'm afraid you can't use a new image as is, part of it should be transparent so the sky, clouds and stuff are visible.

nik
November 20th, 2007, 12:57 PM
Doesn't work here. Here's the output:


nik@nik-laptop:~/Downloads/weather$ ./run
['./weather.py', '--root', '--maxfps', '25', '--nice', '-window-id', '0x4c00002']
./weather.py: invalid option -- w
./weather.py: invalid option -- i
./weather.py: invalid option -- d
./weather.py: invalid option -- o
./weather.py: invalid option -- w
./weather.py: invalid option -- -
./weather.py: invalid option -- i
./weather.py: invalid option -- d
Traceback (most recent call last):
File "./weather.py", line 67, in <module>
x = TestGLHack(sys.argv)
File "./weather.py", line 26, in __init__
self.scene=scene.scene()
File "/home/nik/Downloads/weather/scene.py", line 34, in __init__
self.moon=sceneelems.moon()
File "/home/nik/Downloads/weather/sceneelems.py", line 383, in __init__
self.InitGL()
File "/home/nik/Downloads/weather/sceneelems.py", line 424, in InitGL
self.id1,self.size1 = LoadTex("./pics/moon.png")
File "/home/nik/Downloads/weather/sceneelems.py", line 304, in LoadTex
glTexImage2D(GL_TEXTURE_2D, 0, 4, ix, iy, 0, GL_RGBA, GL_UNSIGNED_BYTE, image)
File "/usr/lib/python2.5/site-packages/OpenGL/wrapper.py", line 924, in wrapperCall
raise err
OpenGL.error.GLError: GLError(
err = 1281,
description = 'invalid value',
baseOperation = glTexImage2D,
pyArgs = [
GL_TEXTURE_2D,
0,
4,
200,
200,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
'\x00\x00\x00\x00\x00\x00\x00\x00\x00...
],
cArgs = [
GL_TEXTURE_2D,
0,
4,
200,
200,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
'\x00\x00\x00\x00\x00\x00\x00\x00\x00...
],
cArguments = (
GL_TEXTURE_2D,
0,
4,
200,
200,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
c_void_p(143694644),
)
)
./weather.py died, exit status 1


Could it be something with my openGL? Or could it be that I have widescreen (1680x1050)? Running gutsy on intel915gm...

SmSpillaz
November 20th, 2007, 01:30 PM
Yeah, I've got the same problem :(

azathothgr
November 20th, 2007, 05:28 PM
Hmm, maybe it's something to do with non-power-of-two sized textures..
Or perhaps they're too big.. I'll try modifying them.

azathothgr
November 20th, 2007, 09:12 PM
Ok, changed them all to power of two dimensions, and all smaller than 2048.
I think it should be this way from the start, sorry.

http://azathothgr.googlepages.com/weather-pt.tar.gz

I get those -window-id unrecognized options too, but it is actually recognized...

()va|_
November 24th, 2007, 10:57 AM
Nice, but i'm having flicker issues when using fullscreen with xwinwrap (your screensaver flickers, so u can see the desktop/windows)

Also is there a way to make it stop after moving mouse etc. just like real screensaver ?

azathothgr
November 24th, 2007, 02:38 PM
I'm guessing it's something wrong with the -window-id WID option, so it doesn't get set properly in the background.. Try running it from the run script, or modifying that to see what happens.
As for using it as a screensaver, there must be a way to add it to the normal screensaver list.
I'm afraid I don't know enough to help you. To be honest I was hoping someone more knowledgeable than me would improve it..

()va|_
November 25th, 2007, 12:04 PM
No problem mate :)

I've just realized that it's a nice wallpaper when u turn off compiz
If u don't like icons and such on desktop :) Looks very nice, keep up the good work.