Example #1
0
	void begin_frame(context& gc) {
	  //glEnable(GL_CULL_FACE);
	  //glCullFace(GL_FRONT);
	  glDisable(GL_CULL_FACE);


	  glMatrixMode(GL_PROJECTION);
	  glLoadIdentity();

	  float ofsx = -gc.screen_size().width_/2.0f;
	  float ofsy = -gc.screen_size().height_/2.0f;
	  if (rotate_ == -999.0f) {
		// first time
		rotate_ = gc.rotate();
		ofsx_ = ofsx;
		ofsy_ = ofsy;
	  }

	  if (gc.rotate()- rotate_ > 180.0f) rotate_ += 360.0f;
	  if (gc.rotate() - rotate_ < -180.0f) rotate_ -= 360.0f;

	  rotate_ = rotate_  * 0.9f +  gc.rotate() * 0.1f;
	  ofsx_ = ofsx_ * 0.95f + ofsx * 0.05f;
	  ofsy_ = ofsy_ * 0.95f + ofsy * 0.05f;

	  //glOrthof(0.0f, (float)gc.screen_size_.width_, (float)gc.screen_size_.height_, 0.0f, -1.0f, 1.0f);
	  float w = (float)gc.device_screen_size().width_;
	  float h = (float)gc.device_screen_size().height_;
	  glOrthof(-1.0f, 1.0f, 1.0f, -1.0f,  -1.0f, 1000.0f);
	  glScalef(2.0f/w,  2.0f/h, 1.0f);

	  glRotatef(-rotate_, 0.0f,0.0f,1.0f);
	  glTranslatef(ofsx_, ofsy_, 0.0f);




	  glMatrixMode(GL_MODELVIEW);
	  glLoadIdentity();

#if 0
{
    const double t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
    const double a = t*90.0;
    glDisable(GL_DEPTH_TEST);
    glColor4d(1,1,1,1);
    glPushMatrix();
	glTranslated(400.0,300.0,0.0);
	glRotated(60,1,0,0);
	glRotated(a,0,0,1);
	glutSolidSphere(100,16,16);
    glPopMatrix();
}
#endif
	}