Пример #1
0
MainLoop::MainLoop( Level* l, Player* p ):
    level(l), player(p), use_mouse(false), renderer(NULL), sound_system(NULL)
{

    key_forward= 'W';
    key_back= 'S';
    key_left= 'A';
    key_right= 'D';
    mouse_speed= 1.0f;
    screen_x= 1024;
    screen_y= 768;
    LoadConfig();

    current_main_loop= this;

    for( int i= 0; i< 256; i++ )
        keys[i]= false;
    mouse_keys[0]= mouse_keys[1]= false;

    InitOGL();
    GetGLFunctions();
    SetupOGLState();

    renderer= new Renderer( level, player );

    int t0= clock();
    renderer->Init();
    int dt= clock() - t0;
    const int delay= CLOCKS_PER_SEC*3;
    if( dt < delay )
#ifdef MW_OS_WINDOWS
        Sleep( (delay-dt)*1000/CLOCKS_PER_SEC );
#else
        usleep( (delay-dt)*1000000/CLOCKS_PER_SEC );
#endif
}
Пример #2
0
// Respond to paint events
void display(void) {
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  InitOGL(width, height);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();

  /*Angulo	ratio		znear, zfar*/
  gluPerspective(50.0, width / height, 1.0, 50000.0);

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  /*pos cam		pto central	vector up*/
  gluLookAt( -100, -100, 70,
		  	  0.0, 0.0, 0.0,
		  	  0.0, 0.0, 1.);


  glDisable(GL_TEXTURE_2D);

  glColor3f(0.6, 0.6, 0.6);
  glLineWidth(2.0f);
  glBegin(GL_LINES);

  for (int i = 0; i < ((int) MAXWORLD + 1); i++) {
      v3f(-(int) MAXWORLD * 10 / 2. + (float) i * 10, -(int) MAXWORLD * 10 / 2., 0.);
      v3f(-(int) MAXWORLD * 10 / 2. + (float) i * 10,  (int) MAXWORLD * 10 / 2., 0.);
      v3f(-(int) MAXWORLD * 10 / 2., -(int) MAXWORLD * 10 / 2. + (float) i * 10, 0.);
      v3f( (int) MAXWORLD * 10 / 2., -(int) MAXWORLD * 10 / 2. + (float) i * 10, 0.);
  }
  glEnd();


//  // absolute axis
//  glColor3f(0.7, 0., 0.);
//  glLineWidth(3.0f);
//  glBegin(GL_LINES);
//	  v3f(0.0, 0.0, 0.0);
//	  v3f(10.0, 0.0, 0.0);
//
//  glColor3f(0., 0.7, 0.);
//	  v3f(0.0, 0.0, 0.0);
//	  v3f(0.0, 10.0, 0.0);
//  glColor3f(0., 0., 0.7);
//	  v3f(0.0, 0.0, 0.0);
//	  v3f(0.0, 0.0, 10.0);
//  glEnd();

  //

  glPushMatrix();
  angle+=1;
//  glRotated(angle, 0, 0, 1);
  for(unsigned i = 0; i < modelos.size(); i++){
	  modelos[i]->Draw();
  }
  glPopMatrix();

  glutSwapBuffers();

}
Пример #3
0
	PlatformOGLDevice(void* _hwnd,const PlatformOGLDevice* parent)
	{
		hwnd = (HWND)((_hwnd == 0) ? createDummyWindow():_hwnd);
		InitOGL(this, parent);
	}