Ejemplo n.º 1
0
void display()
{
  glDrawBuffer(GL_FRONT);
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  xx-=0.001;
  int c,l;
  for (c = -1; c < 12;c++)
    for (l = -1; l < 12;l++)
      display_cube(c,l);
  glFlush();
}
Ejemplo n.º 2
0
/**
 * \brief This function displays 3d scene
 */
static void glut_on_display(void)
{
	float cube_pos[3] = {1.1, 1.1, 1.1};
/*	const float eps = 1.0e-6;*/

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glViewport(0, 0, ctx->display->window.width, ctx->display->window.height);

#if 0
	/* Draw background gradient */
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-1.0, 1.0, -1.0, 1.0, 1.0, -1.0);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glShadeModel(GL_SMOOTH);
	glDepthFunc(GL_ALWAYS);
	glBegin(GL_QUADS);
	glColor4fv(ctx->display->canvas.bg_col_grad_bottom);
	glVertex3f(-1.0f, -1.0f, -1.0f + eps);
	glColor4fv(ctx->display->canvas.bg_col_grad_bottom);
	glVertex3f( 1.0f, -1.0f, -1.0f + eps);
	glColor4fv(ctx->display->canvas.bg_col_grad_top);
	glVertex3f( 1.0f,  1.0f, -1.0f + eps);
	glColor4fv(ctx->display->canvas.bg_col_grad_top);
	glVertex3f(-1.0f,  1.0f, -1.0f + eps);
	glEnd();
#endif

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(0, ctx->display->window.width, 0, ctx->display->window.height);
	glScalef(1, -1, 1);
	glTranslatef(0, -ctx->display->window.height, 0);

	/* BEGIN: Drawing of 2D stuff */

	display_text_info();

	/* END: Drawing of 2D stuff */

	/* Set projection matrix for 3D stuff here */
	glMatrixMode(GL_PROJECTION);

	glPushMatrix();
	glLoadIdentity();
	gluPerspective(ctx->display->camera.field_of_view,
			(double)ctx->display->window.width/(double)ctx->display->window.height,
			ctx->display->camera.near_clipping_plane,
			ctx->display->camera.far_clipping_plane);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	gluLookAt(ctx->display->camera.pos[0], ctx->display->camera.pos[1], ctx->display->camera.pos[2],
			ctx->display->camera.target[0], ctx->display->camera.target[1], ctx->display->camera.target[2],
			ctx->display->camera.up[0], ctx->display->camera.up[1], ctx->display->camera.up[2]);
	glPushMatrix();

	/* BEGIN: Drawing of 3d staff */

	display_string_3d("Cube", cube_pos, white_col);

	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);

	display_cube();

	glDisable(GL_LIGHT0);
	glDisable(GL_LIGHTING);

	/* END: Drawing of 3d staff */

	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);

	glFlush();
	glutSwapBuffers();
}