4cbdd7540f417496c2365e5ece00ad1ea376e786
[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          1  /* 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_USE_BLENDING     0  /* Use alpha feature to create see-through
24                                    * bubbles.
25                                  */
26 #define GLB_VERTICES_EPSILON 0.0005     /* How close are identical vertices? */
27
28 /* Configuration structure. */
29 struct glb_config {
30         int         subdivision_depth;  /* Controls how many triangles are in
31                                          * each bubble. 2 and 3 are good values.
32                                          */
33         int         nr_nudge_axes;      /* Number of directions in which each
34                                          * bubble gets stretched. Values between
35                                          * 3 and 7 seem to produce good results.
36                                          */
37         GLfloat     nudge_angle_factor;         /* Max. amount of rotation in nudge angles.
38                                                  * Controls the amount of `wobble' we see,
39                                                  * and 0.3 seems to work well.
40                                                  */
41         GLfloat     nudge_factor;       /* Max. displacement of any single nudge.
42                                          * Controls the amount of the wobble. Depends
43                                          * on NR_NUDGE_AXES, and must not exceed
44                                          * 1 / NR_NUDGE_AXES. 0.1 is good.
45                                          */
46         GLfloat     rotation_factor;    /* Max. amount by which bubbles rotate. */
47         int         create_bubbles_every;       /* How often to create new bubbles. */
48         int         max_bubbles;        /* Max. number of bubbles to create. */
49         double      p_bubble_group[4];  /* Probabilities of creating 1, 2, 3, 4
50                                          * bubbles in a group. Cumulative.
51                                          */
52         GLfloat     max_size;   /* Max. size. */
53         GLfloat     min_size;   /* Min. size of bubbles. */
54         GLfloat     max_speed;  /* Max. speed. */
55         GLfloat     min_speed;  /* Min. speed of bubbles. */
56         GLfloat     scale_factor;       /* Factor by which bubbles scale from bottom
57                                          * of screen to top. 1.5 - 2.0 are OK.
58                                          */
59         GLfloat     screen_bottom;      /* Bottom of screen. */
60         GLfloat     screen_top; /* Top of screen. */
61         GLfloat     bg_colour[4];       /* Background colour. */
62         GLfloat     bubble_colour[4];   /* Colour of the bubbles. */
63 };
64
65 extern struct glb_config glb_config;
66
67 #define glb_drand() ((double)LRAND() / (double)MAXRAND)
68
69 /*-- From glb_sphere.c. --*/
70 typedef GLfloat glb_vertex[3];
71 typedef GLuint glb_triangle[3];
72 extern void glb_sphere_init(void);
73 extern glb_vertex *glb_sphere_get_vertices(int *nr_vertices);
74 extern glb_triangle *glb_sphere_get_triangles(int *nr_triangles);
75 extern void glb_sphere_end(void);
76
77 /*-- From glb_bubble.c. --*/
78 extern void *glb_bubble_new(GLfloat x, GLfloat y, GLfloat z, GLfloat scale,
79                             GLfloat y_incr, GLfloat scale_incr);
80 extern void glb_bubble_delete(void *);
81 extern void glb_bubble_step(void *);
82 extern void glb_bubble_draw(void *);
83 extern GLfloat glb_bubble_get_y(void *);
84
85 /*-- From glb_draw.c. --*/
86 extern void *glb_draw_init(void);
87 extern void glb_draw_step(void *);
88 extern void glb_draw_end(void *);
89
90 #endif /* __bubbles3d_h__ */