コード例 #1
0
//--------------------------------------------------------------------------------
void GLWidget::resizeGL(int width, int height)
{
  glViewport(0, 0, width, height);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glPerspective(scene.camera.FovY(), (double) width / (double) height, scene.camera.ZNear(), scene.camera.ZFar());

  glMatrixMode(GL_MODELVIEW);
}
コード例 #2
0
void draw::use3D()
{
  // Set up depth
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_CULL_FACE);
  glFrontFace(GL_CCW);
  glCullFace(GL_BACK);
  glDepthFunc(GL_LEQUAL);
  glClearDepth(1.0f);
  glClear(GL_DEPTH_BUFFER_BIT);

	// Set up lighting
	glEnable(GL_LIGHTING);
	glEnable(GL_LIGHT0);

  // Set up camera frustrum
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glPerspective(GL_VIEW_FIELD, global::viewport.x/global::viewport.y, GL_Z_NEAR, GL_Z_FAR);

  // Clean the slate
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
}