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; }
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"); }
RnContext rnContextNew(void) { if (renderer == NULL) { Lock<MutexSys> lock(rendererMutex); if (renderer == NULL) renderer = PF_NEW(Renderer); } renderer->refInc(); return renderer; }
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>(); }
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(); }
GameFrame::GameFrame(int w, int h) { this->cam = PF_NEW(FPSCamera); this->event = PF_NEW(InputControl); }
GameFrame::GameFrame(GameFrame &previous) { this->cam = PF_NEW(FPSCamera, *previous.cam); this->event = PF_NEW(InputControl); }
RnObj rnObjNew(RnContext ctx, const Obj &obj) { RnObj renderObj = PF_NEW(RendererObj, *ctx, obj); renderObj->refInc(); renderObj->externalRefInc(); return renderObj; }
RnFrame rnFrameNew(RnContext ctx) { PF_ASSERT(ctx); RnFrame frame = PF_NEW(RendererFrame, *ctx); RendererObjectNew(frame); return frame; }
RnDisplayList rnDisplayListNew(RnContext ctx) { PF_ASSERT(ctx); RnDisplayList list = PF_NEW(RendererDisplayList, *ctx); RendererObjectNew(list); return list; }