Back to index

kdeartwork  4.3.2
fountain.h
Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 // kfountain - Partical Fountain Screen Saver for KDE 2
00004 //
00005 // Copyright (c)  Ian Reinhart Geiser 2001
00006 //
00008 //NOTE:
00009 // The base particle engine did not come from me, it was designed by Jeff Molofee <nehe@connect.ab.ca>
00010 // I did some extensive modifications to make it work with QT's OpenGL but the base principal is about
00011 // the same.
00013 
00014 #ifndef FOUNTAIN_H
00015 #define FOUNTAIN_H
00016 
00017 #include <qdialog.h>
00018 #include <qgl.h>
00019 #ifdef Q_WS_MACX
00020 #include <OpenGL/gl.h>
00021 #include <OpenGL/glu.h>
00022 #else
00023 #include <GL/glu.h>
00024 #include <GL/gl.h>
00025 #endif
00026 #include <kscreensaver.h>
00027 #include <qtimer.h>
00028 #include <qimage.h>
00029 #include "ui_fountaincfg.h"
00030 #include <kcomponentdata.h>
00031 #include <qfile.h>
00032 #include <qtextstream.h>
00033 
00034 #define       MAX_PARTICLES 1000
00035 
00036 
00037 class Fountain : public QGLWidget
00038 {
00039 Q_OBJECT
00040        class particles                                         // Create A Structure For Particle
00041        {
00042        public:
00043               bool   active;                                   // Active (Yes/No)
00044               float  life;                              // Particle Life
00045               float  fade;                              // Fade Speed
00046               float  r;                                 // Red Value
00047               float  g;                                 // Green Value
00048               float  b;                                 // Blue Value
00049               float  x;                                 // X Position
00050               float  y;                                 // Y Position
00051               float  z;                                 // Z Position
00052               float  xi;                                // X Direction
00053               float  yi;                                // Y Direction
00054               float  zi;                                // Z Direction
00055               float  xg;                                // X Gravity
00056               float  yg;                                // Y Gravity
00057               float  zg;                                // Z Gravity
00058               float  size;                              // Particle Size
00059        };
00060 
00061 public:
00062        Fountain( QWidget * parent=0 );
00063        ~Fountain();
00064        void setSize( float newSize );
00065        void setStars( bool doStars );
00066 protected:
00068        void paintGL ();
00070        void resizeGL ( int w, int h );
00072        void initializeGL ();
00073 
00074 
00075 private:
00077        bool loadParticle();
00078 
00079        particles particle[MAX_PARTICLES];
00080 
00081 
00082        bool   rainbow;                                  // Rainbow Mode?
00083        bool   sp;                                       // Spacebar Pressed?
00084        bool   rp;                                       // Enter Key Pressed?
00085 
00086        float  slowdown;                                 // Slow Down Particles
00087        float  xspeed;                                          // Base X Speed (To Allow Keyboard Direction Of Tail)
00088        float  yspeed;                                          // Base Y Speed (To Allow Keyboard Direction Of Tail)
00089        float  zoom;                              // Used To Zoom Out
00090        float  size;
00091        float  stars;
00092        GLuint loop;                                     // Misc Loop Variable
00093        GLuint col;                                      // Current Color Selection
00094        GLuint delay;                                    // Rainbow Effect Delay
00095        GLuint texture[1];
00096        QImage  tex;
00097        float  index;
00098        float  transIndex;
00099        GLfloat scale;
00100        GLUquadricObj *obj;
00101 };
00102 
00103 class KFountainSaver : public KScreenSaver
00104 {
00105 Q_OBJECT
00106 public:
00107        KFountainSaver( WId drawable );
00108        virtual ~KFountainSaver();
00109        void readSettings();
00110 public slots:
00111        void blank();
00112        void updateSize(int newSize);
00113        void doStars(bool starState);
00114 //     void loadTextures(bool textures);
00115 private:
00116        Fountain *fountain;
00117        QTimer  *timer;
00118 };
00119 
00120 class KFountainSetup : public QDialog, public Ui::SetupUi
00121 {
00122        Q_OBJECT
00123 public:
00124        KFountainSetup( QWidget *parent =0L);
00125 
00126 protected:
00127        void readSettings();
00128 
00129 private slots:
00130        void slotOkPressed();
00131        void aboutPressed();
00132 private:
00133        KFountainSaver *saver;
00134        float  size;
00135        float  stars;
00136 };
00137 
00138 #endif
00139 
00140