1 ///-----------------------------------------------------------------------------
3 // kgravity - Partical gravity Screen Saver for KDE 2
5 // Copyright (c) Ian Reinhart Geiser 2001
9 // The base particle engine did not come from me, it was designed by Jeff Molofee <nehe@connect.ab.ca>
10 // I did some extensive modifications to make it work with QT's OpenGL but the base principal is about
20 #include <OpenGL/glu.h>
21 #include <OpenGL/gl.h>
26 #include <kscreensaver.h>
29 #include "gravitycfg.h"
30 #include <kinstance.h>
32 #include <qtextstream.h>
34 #define MAX_PARTICLES 100
37 class Gravity
: public QGLWidget
40 class particles
// Create A Structure For Particle
43 bool active
; // Active (Yes/No)
44 float life
; // Particle Life
45 float fade
; // Fade Speed
47 float g
; // Green Value
48 float b
; // Blue Value
49 float x
; // X Position
50 float y
; // Y Position
51 float z
; // Z Position
52 float xo
; // X Position
53 float yo
; // Y Position
54 float zo
; // Z Position
57 float size
; // Particle Size
61 Gravity( QWidget
* parent
=0, const char * name
=0 );
63 void setSize( float newSize
);
64 void setStars( bool doStars
);
66 /** paint the GL view */
68 /** resize the gl view */
69 void resizeGL ( int w
, int h
);
70 /** setup the GL enviroment */
72 void buildParticle(int loop
);
75 /** load the partical file */
78 particles particle
[MAX_PARTICLES
];
81 bool rainbow
; // Rainbow Mode?
82 bool sp
; // Spacebar Pressed?
83 bool rp
; // Enter Key Pressed?
84 float slowdown
; // Slow Down Particles
85 float xspeed
; // Base X Speed (To Allow Keyboard Direction Of Tail)
86 float yspeed
; // Base Y Speed (To Allow Keyboard Direction Of Tail)
87 float zoom
; // Used To Zoom Out
90 GLuint loop
; // Misc Loop Variable
91 GLuint col
; // Current Color Selection
92 GLuint delay
; // Rainbow Effect Delay
101 class KGravitySaver
: public KScreenSaver
105 KGravitySaver( WId drawable
);
106 virtual ~KGravitySaver();
110 void updateSize(int newSize
);
111 void doStars(bool starState
);
112 // void loadTextures(bool textures);
118 class KGravitySetup
: public SetupUi
122 KGravitySetup( QWidget
*parent
= NULL
, const char *name
= NULL
);
129 void slotOkPressed();
132 KGravitySaver
*saver
;