//
// function is automatically called when window is resized
void window_resize_callback (GLFWwindow* window, int width, int height) {
	printf ("window addr.%p resized to %ix%i\n", (void*)window, width, height);
	gl_width = width;
	gl_height = height;
	// recalculate projection matrix here
	recalc_perspective ();
}
Пример #2
0
void
render_knot(void)
{
  glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glColor3f(0.9f, 0.9f, 0.9f);
  glDisable(GL_BLEND);
  glDisable(GL_NORMALIZE);
  glEnable(GL_DEPTH_TEST);
  glDisable(GL_TEXTURE_2D);
  if (!create_quadratic) {
    myquadratic = gluNewQuadric();
    gluQuadricNormals(myquadratic, GLU_SMOOTH);
    gluQuadricTexture(myquadratic, GL_TRUE);
    create_quadratic = TRUE;
  }
  recalc_perspective();
  glViewport(0, 0, point_general->WIDTH, point_general->HEIGHT);
}
Пример #3
0
void
draw_scene(void)
{
  if (point_general->changement) {
    recalc_perspective();
    if (point_general->effect > EFFECT_NUMBER - 1) {
      point_general->effect = 0;
      if (gen_gl_texture(knotbg))
        upload_gl_texture(background_image);
      use_gl_texture(knotbg);
    }
    if (point_general->effect == 4) {
      if (gen_gl_texture(tunnel))
        upload_gl_texture(tunnel_image);
      use_gl_texture(tunnel);
    }
    if (point_general->effect == 5) {
      if (gen_gl_texture(tentacle))
        upload_gl_texture(tentacle_image);
      use_gl_texture(tentacle);
    }
    if (point_general->effect == 6) {
      if (gen_gl_texture(twist))
        upload_gl_texture(twist_image);
      if (gen_gl_texture(twistbg))
		upload_gl_texture(background_image);
      use_gl_texture(twist);
    }
    if (point_general->effect == 7) {
      if (gen_gl_texture(texchild))
        upload_gl_texture(child_image);
      if (gen_gl_texture(childbg))
        upload_gl_texture(energy_image);
      use_gl_texture(texchild);
    }
    if (point_general->effect == 8) {
      if (gen_gl_texture(energy))
        upload_gl_texture(energy_image);
      use_gl_texture(energy);
    }
    point_general->changement = FALSE;
  }
  switch (point_general->effect) {
    case 0:
      if (!point_general->init)
        init_effect();
      glDisable(GL_LIGHTING);
      draw_knot();
      break;
    case 1:
      if (!point_general->init)
        init_effect();
      glDisable(GL_LIGHTING);
      draw_spectrum();
      break;
    case 2:
      if (!point_general->init)
        init_effect();
      glEnable(GL_LIGHTING);
      draw_face();
      break;
    case 3:
      if (!point_general->init)
        init_effect();
      glDisable(GL_LIGHTING);
      draw_glthreads();
      break;
    case 4:
      if (!point_general->init)
        init_effect();
      glDisable(GL_LIGHTING);
      draw_tunnel();
      break;
    case 5:
      if (!point_general->init)
        init_effect();
      glDisable(GL_LIGHTING);
      draw_tentacles();
      break;
    case 6:
      if (!point_general->init)
        init_effect();
      glDisable(GL_LIGHTING);
      draw_twist();
      break;
    case 7:
      if (!point_general->init)
        init_effect();
      glDisable(GL_LIGHTING);
      draw_child();
      break;
    case 8:
      if (!point_general->init)
        init_effect();
      glDisable(GL_LIGHTING);
      draw_energy();
      break;
    default:
      break;
  }
}
Пример #4
0
void
draw_background(int mode)
{
  int x, y;
  GLfloat xf, xf2, yf, yf2, angle;

  glEnable(GL_TEXTURE_2D);
  glBlendFunc(GL_SRC_ALPHA, GL_ONE);
  glEnable(GL_BLEND);
  glPushMatrix();
  if (!mode) {
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(135.0f, 4/3, 0.001f, 100.0f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glViewport(0, 0, point_general->WIDTH, point_general->HEIGHT);
    for (x = 0; x < 16; x++) {
      for (y = 0; y < 16; y++) {
          point[x][y][0] = 0;
          point[x][y][1] = 0;
          point[x][y][2] = 0;
      }
    }
  }
  else
    recalc_perspective();
  angle = (GLfloat)(last_time + elapsed_time)/2;
  angle = angle/4;
  last_time = elapsed_time;
  if (mode) {
    for (x = 0; x < 16; x++) {
      for (y = 0; y < 16; y++) {
          point[x][y][0] = x*2 - 16 + sin(angle/60 + x*10*PI/360)*2;
          point[x][y][1] = y*2 - 16 + cos(angle/95 + x*10*2*PI/360)*8;
          point[x][y][2] = sin(angle/180 + x*10*2*PI/360)*2;
      }
    }
  }
  glTranslatef(0.0f, 0.0f, -6.0f);
  glRotatef(-angle/5, 0.0f, 0.0f, 1.0f);
  glColor3f(1.0f, 1.0f, 1.0f);
  glBegin(GL_QUADS);
  for (x = 0; x < 15; x++) {
    xf = (GLfloat)x/16;
    xf2 = (GLfloat)(x+1)/16;
    for (y = 0; y < 15; y++) {
      yf = (GLfloat)y/16;
      yf2 = (GLfloat)(y+1)/16;
      glTexCoord2f(xf, yf);
      glVertex3f(point[x][y][0], point[x][y][1], point[x][y][2]);
      glTexCoord2f(xf, yf2);
      glVertex3f(point[x][y+1][0], point[x][y+1][1], point[x][y+1][2]);
      glTexCoord2f(xf2, yf2);
      glVertex3f(point[x+1][y+1][0], point[x+1][y+1][1], point[x+1][y+1][2]);
      glTexCoord2f(xf2, yf);
      glVertex3f(point[x+1][y][0], point[x+1][y][1], point[x+1][y][2]);
    }
  }    
  glEnd();
  if (!mode) {
    glTranslatef(0, 0, 5);
    glRotatef(angle/1.3f, 1.0f, 0.0f, 0.0f);
    glRotatef(angle/2, 0.0f, 1.0f, 0.0f);
    gluSphere(myquadratic, 1.3f, 32.0f, 32.0f);
  }
  glPopMatrix();
}