Ejemplo n.º 1
0
  void CrossDelegate::run(int width, int height, int aaSamples, int depthBits)
  {
    initInfo.windowInfo = WindowInfo(width, height, aaSamples, depthBits);

    performInit(); // TODO: HANDLE FAILURES
    performSetup();
    performResize(setupInfo.windowInfo.size);

    sketch->performStart(CrossSketch::START_REASON_VIEW_SHOWN);

    while (!glfwWindowShouldClose(window))
    {
      intern::instance->processMouseEvents();
      intern::instance->processKeyEvents();
      intern::instance->processWheelEvents();

      performUpdate();
      performDraw();

      glfwSwapBuffers(window);

      intern::instance->clearMouseEvents();
      intern::instance->clearKeyEvents();
      intern::instance->clearWheelEvents();
      glfwPollEvents();
    }

    sketch->performStop(CrossSketch::STOP_REASON_VIEW_HIDDEN);

    performShutdown();
    performUninit();
  }
Ejemplo n.º 2
0
int main(int argc, char* argv[])
{

  int sd, rc;
  unsigned int port = 0;
  unsigned int episode = 0;

  /* Check arguments, assign port and episode values */
  if(argc < 4)
  {
    printf("usage: %s <server> <port> <episode> [<agent-specific parameters>]\n", argv[0]);
    return 1;
  }
  else if((port = atoi(argv[2])) == 0)
  {
    printf("The port number is invalid\n");
    return 1;
  }
  else if((episode = atoi(argv[3])) == 0)
  {
    printf("The episode number is invalid\n");
    return 1;
  }

  rc = initSocket(argv[1], port, &sd);
  if(rc < 0)
  {
    printf("could not initialize socket ");
    return 1;

  }

  // Now start to send the data
  rc = performInit(sd, argc - 4, (const char**)&argv[4]);
  if(rc < 0)
  {
    perror("failed intialization of the agent");
    return 1;
  }
  for(unsigned int i = 0; i < episode; ++i)
  {
    rc = performEpisode(sd);
    if(rc < 0) break;
  }
  performCleanup();
  close(sd);

  if(rc >= 0)
  {
    return 0;
  }
  return rc;
}