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