Пример #1
0
int
main(void)
{

	grInit();
	grWindow* wind = grWindowInit(grWindowAlloc(), 1024, 1024);
	wind->userFunc = &ml;
	grShader* default_shader = grShaderInit(grShaderAlloc());
	grShaderCompile(default_shader, default_vert, default_frag);
	renderer = grRendererInit(grRendererAlloc(), grV2(1024, 1024));
	sprite = grSpriteInit(grSpriteAlloc(), "player_run.png", 0);
	grSpriteSetUpAnimation(sprite, 8, 1);
	sprite->speed = 300;
	sprite->size = grVec2Scale(sprite->size, 8.0);
	sprite->pos = grV2(400, 400);
	//renderer->camera->zoom.zoomTarget = 2;
	//quad = grQuadInit(grQuadAlloc(), grV2(4*64, 0), grV2(64, 64), sprite);
	grMat4 proj = grCameraGetProjectionMatrix(renderer->camera);
	renderer->shader = default_shader;
	grShaderUse(renderer->shader);
	grShaderSetInteger(renderer->shader, "image", 0);
	grShaderSetMat4(renderer->shader, "projection", proj);
	grMainLoop(wind);
	grDestroy(wind);
	return 1;
}
Пример #2
0
//the simulation loop...
void simulation_loop(int *argc, char *argv[])
{
#ifdef OGL_GRAPHICS
  grInit(argc, argv);
#else
  for (;;)
    {
      static int step=0;
      step++;

      if (step == 3000)
	exit(0);

      std::cout<<"Step no: "<<step<<"\n";
      for (polyObject *curr=list; curr != NULL; curr = curr->next)
	{
	  double ogl_trans[16];
	  curr->UpdateOneStep(ogl_trans);

	  double trans[4][4];

	  for (int i=0; i<4; i++)
	    for (int j=0; j<4; j++)
	      trans[i][j] = ogl_trans[4*j+i];

	  UpdatePolytope(curr->id, trans);
	}
      CollisionTestReportAndRespond();

    }
#endif
}
Пример #3
0
//the simulation_loop...
void simulation_loop(int *argc, char *argv[])
{
#ifdef OGL_GRAPHICS
  grInit(argc, argv);
#else
  for(;;)
    {
      static int step=1;
      
      cout<<"step = "<<step<<"\n";
      step++;
      
      char t;
      double time;
      
      fscanf(fp, "%c", &t);
      fscanf(fp, "t %lf", &time);
      
      double ogl_trans[16];
      
      if (time <5.57)
	{
	  int i;
	  for (i=0; i<num_of_polytopes; i++)
	    {
	      UpdatePolytope(i, ogl_trans);
	    }
	  CollisionTestAndReport();
	}
      else
	{
	  break;
	}
      
    }
#endif
}