Ejemplo n.º 1
0
  Task *TaskGameFrame::run(void)
  {
    // User pressed ESCAPE
    if (UNLIKELY(previous->event->getKey(27) == true)) {
      TaskingSystemInterruptMain();
      return NULL;
    }

    // Generate the current frame tasks
    GameFrame *current = PF_NEW(GameFrame, *previous);
    Task *eventTask = PF_NEW(TaskEvent, *current->event);
    Task *cameraTask = PF_NEW(TaskCamera, *current->cam, *current->event);
    Task *renderTask = PF_NEW(TaskGameRender, *current->cam, *current->event);
    eventTask->starts(cameraTask);
    cameraTask->starts(renderTask);
    renderTask->ends(this);
    cameraTask->scheduled();
    eventTask->scheduled();
    renderTask->scheduled();

    // Spawn the next frame. Right now there is no overlapping
    TaskGameFrame *next = PF_NEW(TaskGameFrame, *current);
    this->starts(next);
    next->scheduled();

    return NULL;
  }
Ejemplo n.º 2
0
 Renderer::Renderer(void)
 {
   this->driver = PF_NEW(RendererDriver);
   this->streamer = PF_NEW(TextureStreamer, *this);
   const TextureRequest req("Maps/default.tga", PF_TEX_FORMAT_PLAIN, GL_NEAREST, GL_NEAREST);
   Ref<Task> loadingTask = this->streamer->createLoadTask(req);
   loadingTask->scheduled();
   TaskingSystemWait(loadingTask);
   const TextureState state = this->streamer->getTextureState("Maps/default.tga");
   this->defaultTex = state.tex;
   FATAL_IF (defaultTex == false  || defaultTex->isValid() == false,
             "Default \"default.tga\" texture not found");
 }
Ejemplo n.º 3
0
RnContext rnContextNew(void) {
    if (renderer == NULL) {
        Lock<MutexSys> lock(rendererMutex);
        if (renderer == NULL)
            renderer = PF_NEW(Renderer);
    }
    renderer->refInc();
    return renderer;
}
Ejemplo n.º 4
0
 Ref<Task> HiZ::rayTrace(const RTCamera &cam, Ref<Intersector> intersector)
 {
   const size_t taskNum = this->pixelNum / TaskRayTraceHiZ::pixelNum;
   Ref<TaskRayTraceHiZ> task = PF_NEW(TaskRayTraceHiZ, taskNum);
   cam.createGenerator(task->gen, this->width, this->height);
   task->zBuffer = this;
   task->view = cam.view;
   task->intersector = intersector;
   task->taskXNum = this->width  / TaskRayTraceHiZ::width;
   task->taskYNum = this->height / TaskRayTraceHiZ::height;
   return task.cast<Task>();
 }
Ejemplo n.º 5
0
 void WinOpen(int w, int h) {
   int argc = 0;
   FATAL_IF(window, "A window is already opened");
   PF_MSG_V("GLUT: initialization");
   glutInitWindowSize(w, h);
   glutInitWindowPosition(64, 64);
   glutInit(&argc, NULL);
   glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
   glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
   PF_MSG_V("GLUT: creating window");
   window = glutCreateWindow("point-frag");
   previousInput = PF_NEW(InputControl);
   previousInput->processEvents();
 }
Ejemplo n.º 6
0
 GameFrame::GameFrame(int w, int h) {
   this->cam = PF_NEW(FPSCamera);
   this->event = PF_NEW(InputControl);
 }
Ejemplo n.º 7
0
 GameFrame::GameFrame(GameFrame &previous) {
   this->cam = PF_NEW(FPSCamera, *previous.cam);
   this->event = PF_NEW(InputControl);
 }
Ejemplo n.º 8
0
RnObj rnObjNew(RnContext ctx, const Obj &obj) {
    RnObj renderObj = PF_NEW(RendererObj, *ctx, obj);
    renderObj->refInc();
    renderObj->externalRefInc();
    return renderObj;
}
Ejemplo n.º 9
0
RnFrame rnFrameNew(RnContext ctx) {
    PF_ASSERT(ctx);
    RnFrame frame = PF_NEW(RendererFrame, *ctx);
    RendererObjectNew(frame);
    return frame;
}
Ejemplo n.º 10
0
RnDisplayList rnDisplayListNew(RnContext ctx) {
    PF_ASSERT(ctx);
    RnDisplayList list = PF_NEW(RendererDisplayList, *ctx);
    RendererObjectNew(list);
    return list;
}