ftp://ftp.krokus.ru/pub/OpenBSD/distfiles/xscreensaver-4.22.tar.gz
[xscreensaver] / hacks / glx / bubble3d.h
1 /* GLBUBBLES (C) 1998 Richard W.M. Jones. */
2
3 #ifndef __bubbles3d_h__
4 #define __bubbles3d_h__
5
6 #include <X11/Intrinsic.h>
7
8 #ifdef STANDALONE
9 # include <math.h>
10 # include "xlockmoreI.h"        /* from the xscreensaver distribution */
11 #else /* !STANDALONE */
12 # include "xlock.h"             /* from the xlockmore distribution */
13 #endif /* !STANDALONE */
14
15 #include <GL/gl.h>
16 #include <GL/glu.h>
17
18 /* Static configuration. */
19 #define GLB_SLOW_GL          0  /* Set this if you have a slow GL
20                                    * implementation. If you have an accelerated
21                                    * graphics card, set this to 0.
22                                  */
23 #define GLB_VERTICES_EPSILON 0.0005     /* How close are identical vertices? */
24
25 /* Configuration structure. */
26 struct glb_config {
27         int         transparent_p;      /* Whether to use alpha blending */
28
29         int         subdivision_depth;  /* Controls how many triangles are in
30                                          * each bubble. 2 and 3 are good values.
31                                          */
32         int         nr_nudge_axes;      /* Number of directions in which each
33                                          * bubble gets stretched. Values between
34                                          * 3 and 7 seem to produce good results.
35                                          */
36         GLfloat     nudge_angle_factor;         /* Max. amount of rotation in nudge angles.
37                                                  * Controls the amount of `wobble' we see,
38                                                  * and 0.3 seems to work well.
39                                                  */
40         GLfloat     nudge_factor;       /* Max. displacement of any single nudge.
41                                          * Controls the amount of the wobble. Depends
42                                          * on NR_NUDGE_AXES, and must not exceed
43                                          * 1 / NR_NUDGE_AXES. 0.1 is good.
44                                          */
45         GLfloat     rotation_factor;    /* Max. amount by which bubbles rotate. */
46         int         create_bubbles_every;       /* How often to create new bubbles. */
47         int         max_bubbles;        /* Max. number of bubbles to create. */
48         double      p_bubble_group[4];  /* Probabilities of creating 1, 2, 3, 4
49                                          * bubbles in a group. Cumulative.
50                                          */
51         GLfloat     max_size;   /* Max. size. */
52         GLfloat     min_size;   /* Min. size of bubbles. */
53         GLfloat     max_speed;  /* Max. speed. */
54         GLfloat     min_speed;  /* Min. speed of bubbles. */
55         GLfloat     scale_factor;       /* Factor by which bubbles scale from bottom
56                                          * of screen to top. 1.5 - 2.0 are OK.
57                                          */
58         GLfloat     screen_bottom;      /* Bottom of screen. */
59         GLfloat     screen_top; /* Top of screen. */
60         GLfloat     bg_colour[4];       /* Background colour. */
61         GLfloat     bubble_colour[4];   /* Colour of the bubbles. */
62
63         int         polygon_count;
64 };
65
66 extern struct glb_config glb_config;
67
68 #define glb_drand() ((double)LRAND() / (double)MAXRAND)
69
70 /*-- From glb_sphere.c. --*/
71 typedef GLfloat glb_vertex[3];
72 typedef GLuint glb_triangle[3];
73 extern void glb_sphere_init(void);
74 extern glb_vertex *glb_sphere_get_vertices(int *nr_vertices);
75 extern glb_triangle *glb_sphere_get_triangles(int *nr_triangles);
76 extern void glb_sphere_end(void);
77
78 /*-- From glb_bubble.c. --*/
79 extern void *glb_bubble_new(GLfloat x, GLfloat y, GLfloat z, GLfloat scale,
80                             GLfloat y_incr, GLfloat scale_incr);
81 extern void glb_bubble_delete(void *);
82 extern void glb_bubble_step(void *);
83 extern void glb_bubble_draw(void *);
84 extern GLfloat glb_bubble_get_y(void *);
85
86 /*-- From glb_draw.c. --*/
87 extern void *glb_draw_init(void);
88 extern void glb_draw_step(void *);
89 extern void glb_draw_end(void *);
90
91 #endif /* __bubbles3d_h__ */