9 #include <GL/gl.h> // Header File For The OpenGL32 Library
10 #include <GL/glu.h> // Header File For The GLu32 Library
16 #define CURRENT_OBJECT stars
18 static void init_stars(int list_id
);
19 static void compile_stars(void);
20 static void draw_stars(void);
21 static void render_stars(void);
22 static void draw_stars(void);
25 // simple objects library
26 // - make sure to change the number of objects
29 DriverObjects CURRENT_OBJECT
=
31 init_stars
, // init, must be called first
32 compile_stars
, // compile
34 render_stars
, // render to scene
39 //=========================================================
40 //=========================================================
41 static void draw_stars(void)
45 double radius
= STAR_RADIUS
;
50 glDisable(GL_LIGHTING
);
51 glDisable(GL_TEXTURE_2D
);
54 glColor3f(1.0, 1.0, 1.0);
57 for (i
= 0; i
< step
; i
++) {
58 glColor3f(1.0, 1.0, 1.0);
60 radius
* ((float)(rand() % MAX_RAND
)/(MAX_RAND
)) - radius
/ 2.0,
61 radius
* ((float)(rand() % MAX_RAND
)/(MAX_RAND
)) - radius
/ 2.0,
62 radius
* ((float)(rand() % MAX_RAND
)/(MAX_RAND
)) - radius
/ 2.0
68 for (i
= 0; i
< step
; i
++) {
70 radius
* ((float)(rand() % MAX_RAND
)/(MAX_RAND
)) - radius
/ 2.0,
71 radius
* ((float)(rand() % MAX_RAND
)/(MAX_RAND
)) - radius
/ 2.0,
72 radius
* ((float)(rand() % MAX_RAND
)/(MAX_RAND
)) - radius
/ 2.0
78 for (i
= 0; i
< step
; i
++) {
80 radius
* ((float)(rand() % MAX_RAND
)/(MAX_RAND
)) - radius
/ 2.0,
81 radius
* ((float)(rand() % MAX_RAND
)/(MAX_RAND
)) - radius
/ 2.0,
82 radius
* ((float)(rand() % MAX_RAND
)/(MAX_RAND
)) - radius
/ 2.0
87 glEnable(GL_LIGHTING
);
89 } // end of the function
94 // - load anything special about the
95 // one important function
97 static void init_stars(int list_id
)
100 CURRENT_OBJECT
.visible
= 1;
102 // store the id through the function
103 // there is probably a better way to do this
104 CURRENT_OBJECT
.call_id
= list_id
;
106 } // end of the functino
109 //=========================================================
110 // Now the function to actually draw it
111 //=========================================================
112 static void render_stars(void)
116 glCallList(CURRENT_OBJECT
.call_id
);
120 } // end of the function
122 //=========================================================
124 //=========================================================
125 static void compile_stars(void)
128 // setup a spot for display list for background
129 //object = getcurrentobject();
130 id
= CURRENT_OBJECT
.call_id
;
133 glNewList(id
, GL_COMPILE
);
135 // call drawing function
136 // but this may method make it a little better
137 CURRENT_OBJECT
.draw();
141 } // end of the function