#define BEAM_RMIN 0.01
#define BEAM_RMAX 0.125
#define BEAM_ENERGY 0.02
+#define BEAM_LEN 16.0
static bool init();
static void cleanup();
static void light();
static void ground();
static void backdrop();
+static void xlogo();
static void display();
static void idle();
static float cam_theta = 45, cam_phi, cam_dist = 10;
static unsigned int sdr_curve_top, sdr_beam, sdr_sky;
static unsigned int start_time;
-static float beam_rot_speed = 0.1;
+static float anim_speed = 0.1;
+static unsigned int anim_stop_time;
+static unsigned int tmsec;
+
+static const float sil_color[] = {0.05, 0.02, 0.1, 1.0};
+static const float beam_color[] = {0.5, 0.4, 0.2, 1.0};
int main(int argc, char **argv)
{
static void faros()
{
- glColor3f(0, 0, 0);
+ glColor3fv(sil_color);
// kormos
glPushMatrix();
glScalef(1, 1, 0.45);
glutSolidCylinder(1, 1, 4, 16);
glPopMatrix();
-
+
bind_program(0);
}
glTranslatef(0, 4.65, 0.2);
bind_program(sdr_beam);
+ set_uniform_float(sdr_beam, "beam_len", BEAM_LEN);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
for(int i=0; i<BEAM_SHELLS; i++) {
float t = (float)i / (float)(BEAM_SHELLS - 1);
float rad = BEAM_RMIN + (BEAM_RMAX - BEAM_RMIN) * t;
- float alpha = BEAM_ENERGY / t;
+ float alpha = BEAM_ENERGY / (t * t);
- glColor4f(0.8, 0.8, 0.2, alpha);
+ glColor4f(beam_color[0], beam_color[1], beam_color[2], alpha);
- glutSolidCylinder(rad, 6, 10, 1);
+ glutSolidCylinder(rad, BEAM_LEN, 12, 1);
}
bind_program(0);
glTranslatef(0, -1.25, 0);
glScalef(1, 0.1, 1);
- glColor3f(0, 0, 0);
+ glColor3fv(sil_color);
glutSolidSphere(10, 32, 32);
glPopMatrix();
static void display()
{
- unsigned int tmsec = glutGet(GLUT_ELAPSED_TIME) - start_time;
+ if(anim_stop_time > 0) {
+ tmsec = anim_stop_time - start_time;
+ } else {
+ tmsec = glutGet(GLUT_ELAPSED_TIME) - start_time;
+ }
+
float tsec = (float)tmsec / 1000.0;
+ float tanim = tsec * anim_speed;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
backdrop();
glPushMatrix();
- float beam_angle = tsec * beam_rot_speed * 360;
+ float beam_angle = tanim * 360;
glRotatef(beam_angle, 0, 1, 0);
light();
gluPerspective(50, (float)x / (float)y, 0.5, 500);
}
+static unsigned int calc_timeshift(float prev_speed, float speed)
+{
+ return tmsec * speed - tmsec * prev_speed;
+}
+
static void keyboard(unsigned char c, int x, int y)
{
switch(c) {
case 27:
exit(0);
+ case ' ':
+ if(anim_stop_time > 0) {
+ start_time += glutGet(GLUT_ELAPSED_TIME) - anim_stop_time;
+ anim_stop_time = 0;
+ } else {
+ anim_stop_time = glutGet(GLUT_ELAPSED_TIME);
+ }
+ break;
+ case '=':
+ //printf("prin %u\n", glutGet(GLUT_ELAPSED_TIME) - start_time);
+ //start_time += calc_timeshift(anim_speed, anim_speed + 0.1);
+ anim_speed += 0.1;
+ break;
+ case '-':
+ //start_time += calc_timeshift(anim_speed, anim_speed - 0.1);
+ anim_speed -= 0.1;
+ if(anim_speed < 0)
+ anim_speed = 0;
+ break;
default:
break;
}