summaryrefslogtreecommitdiffstats
path: root/kscreensaver/kdesavers/fountain.h
blob: 5835e973ebbe7d800905d2530518322b3b6f7493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//-----------------------------------------------------------------------------
//
// kfountain - Partical Fountain Screen Saver for KDE 2
//
// Copyright (c)  Ian Reinhart Geiser 2001
//
/////
//NOTE:
// The base particle engine did not come from me, it was designed by Jeff Molofee <nehe@connect.ab.ca>
// I did some extensive modifications to make it work with QT's OpenGL but the base principal is about
// the same.
////

#ifndef __FOUNTAIN_H__
#define __FOUNTAIN_H__

#include <tqdialog.h>
#include <tqgl.h>
#ifdef TQ_WS_MACX
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#else
#include <GL/glu.h>
#include <GL/gl.h>
#endif
#include <kscreensaver.h>
#include <tqtimer.h>
#include <tqimage.h>
#include "fountaincfg.h"
#include <kinstance.h>
#include <tqfile.h>
#include <tqtextstream.h>

#define	MAX_PARTICLES	1000


class Fountain : public TQGLWidget
{
Q_OBJECT
  TQ_OBJECT
	class particles						// Create A Structure For Particle
	{
	public:
		bool	active;					// Active (Yes/No)
		float	life;					// Particle Life
		float	fade;					// Fade Speed
		float	r;					// Red Value
		float	g;					// Green Value
		float	b;					// Blue Value
		float	x;					// X Position
		float	y;					// Y Position
		float	z;					// Z Position
		float	xi;					// X Direction
		float	yi;					// Y Direction
		float	zi;					// Z Direction
		float	xg;					// X Gravity
		float	yg;					// Y Gravity
		float	zg;					// Z Gravity
		float	size;					// Particle Size
	};

public:
	Fountain( TQWidget * parent=0, const char * name=0 );
	~Fountain();
	void setSize( float newSize );
	void setStars( bool doStars );
protected:
	/** paint the GL view */
	void paintGL ();
	/** resize the gl view */
	void resizeGL ( int w, int h );
	/** setup the GL enviroment */
	void initializeGL ();


private:
	/** load the partical file */
	bool loadParticle();

	particles particle[MAX_PARTICLES];


	bool	rainbow;					// Rainbow Mode?
	bool	sp;						// Spacebar Pressed?
	bool	rp;						// Enter Key Pressed?

	float	slowdown;					// Slow Down Particles
	float	xspeed;						// Base X Speed (To Allow Keyboard Direction Of Tail)
	float	yspeed;						// Base Y Speed (To Allow Keyboard Direction Of Tail)
	float	zoom;					// Used To Zoom Out
	float	size;
	float	stars;
	GLuint	loop;						// Misc Loop Variable
	GLuint	col;						// Current Color Selection
	GLuint	delay;						// Rainbow Effect Delay
	GLuint	texture[1];
	TQImage  tex;
	float	index;
	float	transIndex;
	GLfloat scale;
	GLUquadricObj *obj;
};

class KFountainSaver : public KScreenSaver
{
Q_OBJECT
  TQ_OBJECT
public:
	KFountainSaver( WId drawable );
	virtual ~KFountainSaver();
	void readSettings();
public slots:
	void blank();
	void updateSize(int newSize);
	void doStars(bool starState);
//	void loadTextures(bool textures);
private:
	Fountain *fountain;
	TQTimer  *timer;
};

class KFountainSetup : public SetupUi
{
	Q_OBJECT
  TQ_OBJECT
public:
	KFountainSetup( TQWidget *parent = NULL, const char *name = NULL );

protected:
	void readSettings();

private slots:
	void slotOkPressed();
	void aboutPressed();
private:
	KFountainSaver *saver;
	float	size;
	float	stars;
};

#endif