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