Exemplo n.º 1
0
void draw(void)
{
    GLenum err;
    GLdouble secs, degrees;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    /* one revolution every 10 seconds... */
    secs = get_secs();
    secs = secs - 10.*trunc(secs / 10.);
    degrees = (secs/10.) * (360.);

    draw_room();

    glEnable(GL_BLEND);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_FRONT);
    draw_cone();
    draw_sphere(degrees);
    glCullFace(GL_BACK);
    draw_cone();
    draw_sphere(degrees);
    glDisable(GL_CULL_FACE);
    glDisable(GL_BLEND);

    err = glGetError();
    if (err != GL_NO_ERROR) printf("Error:  %s\n", gluErrorString(err));

    glutSwapBuffers();
}
Exemplo n.º 2
0
void draw(void)
{
    GLenum err;
    GLdouble secs;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    draw_room();
    draw_cone();

    /* draw the front and then the back faces (essentially sorts the
       polygons). */
    secs = get_secs();
    glEnable(GL_BLEND);
    glEnable(GL_CULL_FACE);
    glCullFace(GL_FRONT);
    draw_sphere(secs * 360. / 10.);
    glCullFace(GL_BACK);
    draw_sphere(secs * 360. / 10.);
    glDisable(GL_CULL_FACE);
    glDisable(GL_BLEND);

    err = glGetError();
    if (err != GL_NO_ERROR) printf("Error:  %s\n", gluErrorString(err));

    glutSwapBuffers();
}
Exemplo n.º 3
0
void ShZshapeManager::draw_shape(const char* content)
{
	if (content == "cube")
	{
		draw_cube();
	}

	if (content == "cylinder")
	{
		draw_cylinder();
	}

	if (content == "pipe")
	{
		draw_pipe();
	}

	if (content == "cone")
	{
		draw_cone();
	}

	if (content == "circle")
	{
		draw_circle();
	}

	if (content == "ring")
	{
		draw_ring();
	}

	if (content == "pyramid")
	{
		draw_pyramid();
	}

	if (content == "triangle")
	{
		draw_triangle();
	}

	if (content == "rectangle")
	{
		draw_rectangle();
	}

	if (content == "polygon")
	{
		draw_polygon();
	}

	if (content == "multigonalStar")
	{
		draw_multigonalStar();
	}
}
Exemplo n.º 4
0
void draw(void)
{
    GLenum err;
    GLdouble secs;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    draw_room();
    draw_cone();

    glEnable(GL_BLEND);
    secs = get_secs();
    draw_sphere(secs * 360. / 10.);
    glDisable(GL_BLEND);

    err = glGetError();
    if (err != GL_NO_ERROR) printf("Error:  %s\n", gluErrorString(err));

    glutSwapBuffers();
}
Exemplo n.º 5
0
void draw(void)
{
    GLenum err;
    GLdouble secs;

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    draw_room();
    draw_cone();
    secs = get_secs();

    /* draw the transparent object... */
    glEnable(GL_POLYGON_STIPPLE);
    draw_sphere(secs * 360. / 10.);
    glDisable(GL_POLYGON_STIPPLE);

    err = glGetError();
    if (err != GL_NO_ERROR) printf("Error:  %s\n", gluErrorString(err));

    glutSwapBuffers();
}
Exemplo n.º 6
0
void PositionArrows::draw()
{
    const static int cone_n = 6;

    int x_r = RED_R;
    int x_g = RED_G;
    int x_b = RED_B;

    int y_r = BLUE_R;
    int y_g = BLUE_G;
    int y_b = BLUE_B;

    int z_r = GREEN_R;
    int z_g = GREEN_G;
    int z_b = GREEN_B;

    switch (pan) {
        case X_CONE:
            x_r = x_g = x_b = 255;
            break;
        case Y_CONE:
            y_r = y_g = y_b = 255;
            break;
        case Z_CONE:
            z_r = z_g = z_b = 255;
            break;
    }

    glPushMatrix();
    glTranslatef(pos.x, pos.y, pos.z);
    glScalef(scale, scale, scale);

    glLineWidth(1.0f);
    glBegin(GL_LINES);

    glColor4ub(x_r, x_g, x_b, 255);
    glVertex3f(0, 0.0f, 0.0f);
    glVertex3f(LINE_LEN, 0.0f, 0.0f);

    glColor4ub(y_r, y_g, y_b, 255);
    glVertex3f(0.0f, 0, 0.0f);
    glVertex3f(0.0f, LINE_LEN, 0.0f);

    glColor4ub(z_r, z_g, z_b, 255);
    glVertex3f(0.0f, 0.0f, 0);
    glVertex3f(0.0f, 0.0f, LINE_LEN);
    glEnd();

    glColor4ub(x_r, x_g, x_b, 255);
    vec3 x_cone(LINE_LEN, 0.0f, 0.0f);
    draw_cone(x_cone, x_cone + vec3(CONE_HEIGHT, 0.0f, 0.0f), CONE_RADIUS,
              cone_n);

    glColor4ub(y_r, y_g, y_b, 255);
    vec3 y_cone(0.0f, LINE_LEN, 0.0f);
    draw_cone(y_cone, y_cone + vec3(0.0f, CONE_HEIGHT, 0.0f), CONE_RADIUS,
              cone_n);

    glColor4ub(z_r, z_g, z_b, 255);
    vec3 z_cone(0.0f, 0.0f, LINE_LEN);
    draw_cone(z_cone, z_cone + vec3(0.0f, 0.0f, CONE_HEIGHT), CONE_RADIUS,
              cone_n);

    glPopMatrix();
}
Exemplo n.º 7
0
void draw_scene(GLdouble secs, int passes, GLenum cullFace, 
		GLuint stencilVal, GLuint mirror)
{
  GLenum newCullFace;
  int passesPerMirror, passesPerMirrorRem;
  unsigned int curMirror, drawMirrors;
  int i;

  /* one pass to draw the real scene */
  passes--;

  /* only draw in my designated locations */
  glStencilFunc(GL_EQUAL, stencilVal, 0xffffffff);

  /* draw things which may obscure the mirrors first */
  draw_sphere(secs);
  draw_cone();

  /* now draw the appropriate number of mirror reflections.  for
   * best results, we perform a depth-first traversal by allocating
   * a number of passes for each of the mirrors. */
  if (mirror != 0xffffffff) {
    passesPerMirror = passes / (nMirrors - 1);
    passesPerMirrorRem = passes % (nMirrors - 1);
    if (passes > nMirrors - 1) drawMirrors = nMirrors - 1;
    else drawMirrors = passes;
  } else {
    /* mirror == -1 means that this is the initial scene (there was no 
     * mirror) */
    passesPerMirror = passes / nMirrors;
    passesPerMirrorRem = passes % nMirrors;
    if (passes > nMirrors) drawMirrors = nMirrors;
    else drawMirrors = passes;
  }
  for (i = 0; drawMirrors > 0; i++) {
    curMirror = i % nMirrors;
    if (curMirror == mirror) continue;
    drawMirrors--;

    /* draw mirror into stencil buffer but not color or depth buffers */
    glColorMask(0, 0, 0, 0);
    glDepthMask(0);
    glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); 
    draw_mirror(&mirrors[curMirror]);
    glColorMask(1, 1, 1, 1);
    glDepthMask(1);
    glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);

    /* draw reflected scene */
    newCullFace = reflect_through_mirror(&mirrors[curMirror], cullFace);
    if (passesPerMirrorRem) {
      draw_scene(secs, passesPerMirror + 1, newCullFace, stencilVal + 1, 
		 curMirror);      
      passesPerMirrorRem--;
    } else {
      draw_scene(secs, passesPerMirror, newCullFace, stencilVal + 1, 
		 curMirror);
    }
    undo_reflect_through_mirror(&mirrors[curMirror], cullFace);

    /* back to our stencil value */
    glStencilFunc(GL_EQUAL, stencilVal, 0xffffffff);    
  }

  draw_room(); 
}
Exemplo n.º 8
0
/* metoda ce adauga jucatorul in labirint */
void Player::add() {
	draw_sphere();
	draw_cone();
}