Initial Import
[glAntsMech.git] / glants_mech / linux / src / stars.c
blob66ff0babb53cc1025ac0ec83729164b8a130b0e3
1 //
2 // stars.cpp
3 // - the ant object
4 //
6 #include <stdio.h>
7 #include <stdlib.h>
9 #include <GL/gl.h> // Header File For The OpenGL32 Library
10 #include <GL/glu.h> // Header File For The GLu32 Library
12 #include "objects.h"
13 #include "bot.h"
15 #undef CURRENT_OBJECT
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
27 // in objects.h
29 DriverObjects CURRENT_OBJECT =
31 init_stars, // init, must be called first
32 compile_stars, // compile
33 draw_stars, // draw
34 render_stars, // render to scene
35 0 // loaded by INIT
39 //=========================================================
40 //=========================================================
41 static void draw_stars(void)
44 int cnt = MAX_STARS;
45 double radius = STAR_RADIUS;
47 int step = cnt / 3;
48 int i;
50 glDisable(GL_LIGHTING);
51 glDisable(GL_TEXTURE_2D);
54 glColor3f(1.0, 1.0, 1.0);
55 glPointSize(0.5);
56 glBegin(GL_POINTS);
57 for (i = 0; i < step; i++) {
58 glColor3f(1.0, 1.0, 1.0);
59 glVertex3f(
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
65 glEnd();
66 glPointSize(1.0);
67 glBegin(GL_POINTS);
68 for (i = 0; i < step; i++) {
69 glVertex3f(
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
75 glEnd();
76 glPointSize(1.5);
77 glBegin(GL_POINTS);
78 for (i = 0; i < step; i++) {
79 glVertex3f(
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
85 glEnd();
87 glEnable(GL_LIGHTING);
89 } // end of the function
93 // init
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)
114 glPushMatrix();
116 glCallList(CURRENT_OBJECT.call_id);
118 glPopMatrix();
120 } // end of the function
122 //=========================================================
123 // compile
124 //=========================================================
125 static void compile_stars(void)
127 int id;
128 // setup a spot for display list for background
129 //object = getcurrentobject();
130 id = CURRENT_OBJECT.call_id;
132 // apply list
133 glNewList(id, GL_COMPILE);
135 // call drawing function
136 // but this may method make it a little better
137 CURRENT_OBJECT.draw();
139 glEndList();
141 } // end of the function