void draw_grid(int i,int j,int k)                       //This draws the grid and changes the color the grid according to the player
{   beginFrame();
    Line h1(0,0,600,0),h2(0,100,600,100),               // "h" is the horizontal lines and "v" is the vertical lines
    h3(0,200,600,200),h4(0,300,600,300),
    h5(0,400,600,400),h6(0,500,600,500),
    h7(0,600,600,600),h8(0,700,600,700),
    h9(0,800,600,800);
    Line v1(0,0,0,800),v2(100,0,100,800),
    v3(200,0,200,800),v4(300,0,300,800),
    v5(400,0,400,800),v6(500,0,500,800),
    v7(600,0,600,800);
    h1.setColor(COLOR(255*i,255*j,255*k)),h2.setColor(COLOR(255*i,255*j,255*k)),
    h3.setColor(COLOR(255*i,255*j,255*k)),h4.setColor(COLOR(255*i,255*j,255*k)),
    h5.setColor(COLOR(255*i,255*j,255*k)),h6.setColor(COLOR(255*i,255*j,255*k)),
    h7.setColor(COLOR(255*i,255*j,255*k)),h8.setColor(COLOR(255*i,255*j,255*k)),
    h9.setColor(COLOR(255*i,255*j,255*k));
    v1.setColor(COLOR(255*i,255*j,255*k)),v2.setColor(COLOR(255*i,255*j,255*k)),
    v3.setColor(COLOR(255*i,255*j,255*k)),v4.setColor(COLOR(255*i,255*j,255*k)),
    v5.setColor(COLOR(255*i,255*j,255*k)),v6.setColor(COLOR(255*i,255*j,255*k)),
    v7.setColor(COLOR(255*i,255*j,255*k));
    h1.imprint(),h2.imprint(),
    h3.imprint(),h4.imprint(),
    h5.imprint(),h6.imprint(),
    h7.imprint(),h8.imprint(),h9.imprint();
    v1.imprint(),v2.imprint(),
    v3.imprint(),v4.imprint(),
    v5.imprint(),v6.imprint(),v7.imprint();
    endFrame();
}
Exemplo n.º 2
0
void Logger::execute()
{
  if(parameters.enabled)
  {
    if(Blackboard::getInstance().getVersion() != blackboardVersion)
    {
      loggables.clear();
      for(const std::string& representation : parameters.representations)
        if(Blackboard::getInstance().exists(representation.c_str()))
        {
          int i;
          for(i = 0; i < numOfDataMessageIDs; ++i)
            if(getName((MessageID) i) == "id" + representation)
            {
              loggables.push_back(Loggable(&Blackboard::getInstance()[representation.c_str()], (MessageID) i));
              break;
            }
          if(i == numOfDataMessageIDs)
            OUTPUT_WARNING("Logger: " << representation << " has no message id.");
        }
        else
        { // This pair of braces avoids strange bug in VS2013
          OUTPUT_WARNING("Logger: " << representation << " is not available in blackboard.");
        }

      blackboardVersion = Blackboard::getInstance().getVersion();
    }

    beginFrame(SystemCall::getCurrentSystemTime());
    Cabsl<Logger>::execute(OptionInfos::getOption("Root"));
    endFrame();
  }
}
void explode(int playerState[8][6],int orbCount[8][6],int x,int y,int player)
{
    beginFrame();
    if(orbCount[x][y]>criticalMass[x][y])                                   // orbCount[x][y] refers to the no. of orbs in the cell of "x"th row and "y"th column
    {                                                                       //if orbCount[x][y] exceeds the critical mass the the cell becomes empty and the orbs goes to
        orbCount[x][y]=0;playerState[x][y]=0;                               //   vertical and horizontal directions and encapulate the other orbs chages to the current players
        Rectangle h(y*100+50,x*100+50,90,90);                               //    color.
        h.setColor(COLOR(255,255,255));
        h.setFill();
        h.imprint();
        if(x-1>=0) {orbCount[x-1][y]++;playerState[x-1][y]=player;}         // the orbs will explode to possible vertical and horizontol directions
        if(x+1<=7) {orbCount[x+1][y]++;playerState[x+1][y]=player;}
        if(y-1>=0) {orbCount[x][y-1]++;playerState[x][y-1]=player;}
        if(y+1<=5) {orbCount[x][y+1]++;playerState[x][y+1]=player;}
        if((x-1)>=0&&orbCount[x-1][y]>criticalMass[x-1][y])                 // after explosion the adjacent cells will explode or expand according to the respective crutical mass
            explode(playerState,orbCount,x-1,y,player);
        else if((x-1)>=0&&orbCount[x-1][y]<=criticalMass[x-1][y])
            expand(playerState,orbCount,x-1,y,player);
         if((x+1)<=7&&orbCount[x+1][y]>criticalMass[x+1][y])
            explode(playerState,orbCount,x+1,y,player);
        else if((x+1)>=0&&orbCount[x+1][y]<=criticalMass[x+1][y])
            expand(playerState,orbCount,x+1,y,player);
         if((y-1)>=0&&orbCount[x][y-1]>criticalMass[x][y-1])
            explode(playerState,orbCount,x,y-1,player);
        else if((y-1)>=0&&orbCount[x][y-1]<=criticalMass[x][y-1])
            expand(playerState,orbCount,x,y-1,player);
        if((y+1)<=5&&orbCount[x][y+1]>criticalMass[x][y+1])
            explode(playerState,orbCount,x,y+1,player);
        else if((y+1)<=5&&orbCount[x][y+1]<=criticalMass[x][y+1])
            expand(playerState,orbCount,x,y+1,player);
    }
    endFrame();
}
Exemplo n.º 4
0
bool CCThreadProxy::compositeAndReadback(void *pixels, const IntRect& rect)
{
    TRACE_EVENT("CCThreadPRoxy::compositeAndReadback", this, 0);
    ASSERT(isMainThread());
    ASSERT(m_layerTreeHost);

    if (!m_layerRendererInitialized) {
        TRACE_EVENT("compositeAndReadback_EarlyOut_LR_Uninitialized", this, 0);
        return false;
    }


    // Perform a synchronous commit.
    CCCompletionEvent beginFrameCompletion;
    CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::forceBeginFrameOnImplThread, AllowCrossThreadAccess(&beginFrameCompletion)));
    beginFrameCompletion.wait();
    beginFrame();

    // Perform a synchronous readback.
    ReadbackRequest request;
    request.rect = rect;
    request.pixels = pixels;
    CCProxy::implThread()->postTask(createCCThreadTask(this, &CCThreadProxy::requestReadbackOnImplThread, AllowCrossThreadAccess(&request)));
    request.completion.wait();
    return request.success;
}
Exemplo n.º 5
0
  XDEBUG_NOTIMPLEMENTED

static Variant HHVM_FUNCTION(xdebug_start_trace,
                             const Variant& traceFileVar,
                             int64_t options /* = 0 */) {
  // Allowed to pass null.
  folly::StringPiece trace_file;
  if (traceFileVar.isString()) {
    // We're not constructing a new String, we're just using the one in
    // traceFileVar, so this is safe.
    trace_file = traceFileVar.toString().slice();
  }

  // Initialize the profiler if it isn't already.
  if (!XDEBUG_GLOBAL(ProfilerAttached)) {
    attach_xdebug_profiler();
  }

  // php5 xdebug returns false when tracing already started.
  auto profiler = xdebug_profiler();
  if (profiler->isTracing()) {
    return false;
  }

  // Start tracing, then grab the current begin frame
  start_tracing(profiler, trace_file, options);
  profiler->beginFrame(nullptr);
  return HHVM_FN(xdebug_get_tracefile_name)();
}
Exemplo n.º 6
0
void FeatureDemo::onFrameRender()
{
    beginTestFrame();
    
    if (mpSceneRenderer)
    {
        beginFrame();

        {
            PROFILE(updateScene);
            mpSceneRenderer->update(mCurrentTime);
        }

        depthPass();
        shadowPass();
        mpState->setFbo(mpMainFbo);
        renderSkyBox();
        lightingPass();
        antiAliasing();
        postProcess();
        ambientOcclusion();
        endFrame();
    }
    else
    {
        mpRenderContext->clearFbo(mpDefaultFBO.get(), vec4(0.2f, 0.4f, 0.5f, 1), 1, 0);
    }

    endTestFrame();
}
Exemplo n.º 7
0
void Sprite::setZIndex(float new_z_index){
  beginFrame();
  removeSprite(this);
  z_index = new_z_index;
  addSprite(this);
  endFrame();
}
void expand(int playerState[8][6],int orbCount[8][6],int x, int y,int player)
{
    beginFrame();

    if(orbCount[x][y]==1)
    {
            playerState[x][y]=player;                   // After the explosion if the adjacent cell is empty then the orb will occupy it.
            Circle g(y*100+50,x*100+50,15);
             g.setColor(COLOR(255*(player%2),255*((player/2)%2),255*(((player/2)/2)%2)));
             g.setFill();
             g.imprint();
    }

   if(orbCount[x][y]==2||orbCount[x][y]==3)
   {                                                // for expantion this will remove the single orb and replaces with double or triple orbs
    playerState[x][y]=0;
    Rectangle w(y*100+50,x*100+50,90,90);
    w.setColor(COLOR(255,255,255));
    w.setFill();
    w.imprint();
   }

   if(((x>=1&&x<=6)||(y>=1&&y<=4))&&orbCount[x][y]==2)
    {
        Circle c1(y*100+40,x*100+50,15);
        Circle c2(y*100+60,x*100+50,15);
        playerState[x][y]=player;
        c2.setColor(COLOR(255*(player%2),255*((player/2)%2),255*(((player/2)/2)%2)));
        c1.setColor(COLOR(255*(player%2),255*((player/2)%2),255*(((player/2)/2)%2)));
        c1.setFill();
        c2.setFill();
        c1.imprint();
        c2.imprint();
    }

   else if(((x>=1&&x<=6)&&(y>=1&&y<=4))&&orbCount[x][y]==3)
    {
       Circle a1(y*100+50,x*100+40,15);
       Circle a2(y*100+40,x*100+60,15);
       Circle a3(y*100+60,x*100+60,15);
        playerState[x][y]=player;
        a3.setColor(COLOR(255*(player%2),255*((player/2)%2),255*(((player/2)/2)%2)));
        a2.setColor(COLOR(255*(player%2),255*((player/2)%2),255*(((player/2)/2)%2)));
        a1.setColor(COLOR(255*(player%2),255*((player/2)%2),255*(((player/2)/2)%2)));
        a1.setFill();
        a2.setFill();
        a3.setFill();
        a1.imprint();
        a2.imprint();
        a3.imprint();
    }

    if(orbCount[x][y]>criticalMass[x][y])                       // afer placing the orbs if the cell reache the critical mass if the extra orb is placed by the corresponding
        explode(playerState,orbCount,x,y,player);               //   player then it will call the explode funtion.

}
    /**
     * Executes one behavior cycle.
     * @param roots A set of root options. They must be parameterless.
     */
    void execute(const std::vector<OptionInfos::Option>& roots)
    {
      theOwnTeamInfo = BehaviorControl2013Base::theOwnTeamInfo;
      theRobotInfo = BehaviorControl2013Base::theRobotInfo;
      theGameInfo = BehaviorControl2013Base::theGameInfo;

      beginFrame(theFrameInfo.time);
      preProcessLibraries();

      for(std::vector<Behavior::OptionInfos::Option>::const_iterator i = roots.begin(); i != roots.end(); ++i)
      Cabsl<Behavior>::execute(*i);

      postProcessLibraries();
      endFrame();
    }
Exemplo n.º 10
0
void BaseApp::makeFrame(){
	if (!configDialog->isVisible()) controls();

	renderer->resetStatistics();

#ifdef PROFILE
	if (keys[KEY_F11]){
		renderer->profileFrameStart(frameTime);
	}
#endif

	beginFrame();
		drawFrame();
		//drawGUI();
	endFrame();

#ifdef PROFILE
	renderer->profileFrameEnd();
#endif


#define SAMPLE_INTERVAL 0.1f

	// Output frameTimes if enabled
	static float accTime = 0;
	static int nFrames = 0;

	if (benchMarkFile){
		accTime += frameTime;
		nFrames++;

		if (accTime >= SAMPLE_INTERVAL){
			fprintf(benchMarkFile, "%f\n", nFrames / accTime);

			nFrames = 0;
			accTime = 0;
		}
	} else {
		nFrames = 0;
		accTime = 0;
	}
}
Exemplo n.º 11
0
int main(int argc, char** argv) {

	if (initialize()) {
		while (running) {
			beginFrame();

			updateInput();

			updateGame();

			updateRender();

			endFrame();
		} 
		end();
	}
	else
		Logger::log("CRITICAL ERROR: Could not initialize.");

	return 0;
}
Exemplo n.º 12
0
void TestWindow::draw() {
    if (_aboutToQuit) {
        return;
    }

    // Attempting to draw before we're visible and have a valid size will
    // produce GL errors.
    if (!isVisible() || _size.width() <= 0 || _size.height() <= 0) {
        return;
    }

    if (!_glContext.makeCurrent(this)) {
        return;
    }

    static std::once_flag once;
    std::call_once(once, [&] { initGl(); });
    beginFrame();

    renderFrame();

    endFrame();
}
Exemplo n.º 13
0
int main(){
  initCanvas("Car",800,800);

  Car c(200,300,COLOR("blue")), d(200,600,COLOR("red"));
  d.scale(0.5);

  getClick();

  for(int i=0; i<400; i++){
    beginFrame();
    c.forward(1); d.forward(1);
    endFrame();
  }
  getClick();

  for(int i=0; i<90; i++){
    beginFrame();
    d.forward(-1);
    endFrame();
    beginFrame();
    d.forward(-1);
    endFrame();
    beginFrame();
    d.forward(-1);
    endFrame();
    beginFrame();
    d.forward(-1);
    endFrame();
    beginFrame();
    d.forward(-1);
    d.right(1);
    endFrame();
  }
  getClick();

}
Exemplo n.º 14
0
FenceManager::~FenceManager()
{
	beginFrame();
	for (auto &fence : fences)
		vkDestroyFence(device, fence, nullptr);
}
Exemplo n.º 15
0
void ParallelComposer::composeViewport(ViewportPtr port)
{
#ifdef OSG_WITH_PARALLEL
    // setup viewport
    GLint 
        pl=port->getPixelLeft(), 
        pr=port->getPixelRight(),
        pb=port->getPixelBottom(), 
        pt=port->getPixelTop();
    if(_wWidth != pr-pl+1 || _wHeight != pt-pb+1)
    {
        _wWidth = pr-pl+1;
        _wHeight= pt-pb+1;
        _createContext = true;
    }
    bool full = port->isFullWindow();
    glViewport(pl, pb, _wWidth, _wHeight);
    glScissor(pl, pb, _wWidth, _wHeight);
    if(! full)
        glEnable(GL_SCISSOR_TEST);

    GLboolean depth = glIsEnabled(GL_DEPTH_TEST);
    GLboolean blend = glIsEnabled(GL_BLEND);

    glDisable(GL_DEPTH_TEST);
    glPushMatrix();
    glLoadIdentity();
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0, port->getPixelWidth(),
            0, port->getPixelHeight(),-1,1);

    if(_createContext)
    {
        createCtx(port);
        _createContext = false;
    }

    if(getAlpha())
    {
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    }

    if(isClient())
    {
        UInt32 id = beginFrame();
        renderRead();
        endFrame(id);
        drawFrame();
    }
    else
    {
        if(clusterId() < _usableServers)
        {
            UInt32 id = beginFrame();
            renderRead();
            endFrame(id);
            //drawFrame();
        }
    }
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
    glEnable(GL_DEPTH_TEST);

    // reset state
    if(depth && !glIsEnabled(GL_DEPTH_TEST))
        glEnable(GL_DEPTH_TEST);
    if(!blend && glIsEnabled(GL_BLEND))
        glDisable(GL_BLEND);
#endif
}
Exemplo n.º 16
0
static void
endFrame(
	_VGContext* Context
	)
{
    int i;
    gctUINT32 totalVGCalls = 0;
    gctUINT32 totalVGDrawCalls = 0;
    gctUINT32 totalVGStateChangeCalls = 0;
	gctUINT32 maxrss, ixrss, idrss, isrss;

	if (Context->profiler.enable)
	{
    	beginFrame(Context);

        if (Context->profiler.timeEnable)
        {
#if gcdNEW_PROFILER_FILE
            gcmWRITE_CONST(VPG_TIME);

            gcmWRITE_COUNTER(VPC_ELAPSETIME, Context->profiler.frameEndTimeusec
                - Context->profiler.frameStartTimeusec);
            gcmWRITE_COUNTER(VPC_CPUTIME, Context->profiler.frameEndCPUTimeusec
                - Context->profiler.frameStartCPUTimeusec);

            gcmWRITE_CONST(VPG_END);
#else
			_Print(Context, "<Time>\n");

			_Print(Context, "<ElapseTime value=\"%llu\"/>\n",
        		   ( Context->profiler.frameEndTimeusec
    	    	   - Context->profiler.frameStartTimeusec
	        	   ));

			_Print(Context, "<CPUTime value=\"%llu\"/>\n",
				   Context->profiler.frameEndCPUTimeusec
				   - Context->profiler.frameStartCPUTimeusec);

			_Print(Context, "</Time>\n");
#endif
		}

        if (Context->profiler.memEnable)
        {
#if gcdNEW_PROFILER_FILE
            gcoOS_GetMemoryUsage(&maxrss, &ixrss, &idrss, &isrss);

            gcmWRITE_CONST(VPG_MEM);

            gcmWRITE_COUNTER(VPC_MEMMAXRES, maxrss);
            gcmWRITE_COUNTER(VPC_MEMSHARED, ixrss);
            gcmWRITE_COUNTER(VPC_MEMUNSHAREDDATA, idrss);
            gcmWRITE_COUNTER(VPC_MEMUNSHAREDSTACK, isrss);

            gcmWRITE_CONST(VPG_END);
#else
			_Print(Context, "<Memory>\n");

			gcoOS_GetMemoryUsage(&maxrss, &ixrss, &idrss, &isrss);
			_Print(Context, "<MemMaxResidentSize value=\"%lu\"/>\n", maxrss);
			_Print(Context, "<MemSharedSize value=\"%lu\"/>\n", ixrss);
			_Print(Context, "<MemUnsharedDataSize value=\"%lu\"/>\n", idrss);
			_Print(Context, "<MemUnsharedStackSize value=\"%lu\"/>\n", isrss);

			_Print(Context, "</Memory>\n");
#endif
		}

        if (Context->profiler.drvEnable)
        {
#if gcdNEW_PROFILER_FILE
            gcmWRITE_CONST(VPG_VG11);
#else
			_Print(Context, "<VGCounters>\n");
#endif

    	for (i = 0; i < NUM_API_CALLS; ++i)
    	{
        	if (Context->profiler.apiCalls[i] > 0)
        	{
#if gcdNEW_PROFILER_FILE
                    gcmWRITE_COUNTER(VPG_VG11 + 1 + i, Context->profiler.apiCalls[i]);
#else
				_Print(Context, "<%s value=\"%d\"/>\n",
					   apiCallString[i], Context->profiler.apiCalls[i]);
#endif

            	totalVGCalls += Context->profiler.apiCalls[i];

            	/* TODO: Correctly place function calls into bins. */
            	switch(i + APICALLBASE)
            	{
                case VGDRAWPATH:
                case VGDRAWIMAGE:
				case VGDRAWGLYPH:
                    totalVGDrawCalls += Context->profiler.apiCalls[i];
                    break;

                case VGFILLMASKLAYER:
                case VGLOADIDENTITY:
                case VGLOADMATRIX:
                case VGMASK:
                case VGMULTMATRIX:
                case VGRENDERTOMASK:
                case VGROTATE:
                case VGSCALE:
                case VGSETCOLOR:
                case VGSETF:
                case VGSETFV:
                case VGSETI:
                case VGSETIV:
                case VGSETPAINT:
                case VGSETPARAMETERF:
                case VGSETPARAMETERFV:
                case VGSETPARAMETERI:
                case VGSETPARAMETERIV:
                case VGSHEAR:
                case VGTRANSLATE:
                    totalVGStateChangeCalls += Context->profiler.apiCalls[i];
                    break;

				default:
                    break;
            	}
			}

				/* Clear variables for next frame. */
				Context->profiler.apiCalls[i] = 0;
	    	}

#if gcdNEW_PROFILER_FILE
            gcmWRITE_COUNTER(VPC_VG11CALLS, totalVGCalls);
            gcmWRITE_COUNTER(VPC_VG11DRAWCALLS, totalVGDrawCalls);
            gcmWRITE_COUNTER(VPC_VG11STATECHANGECALLS, totalVGStateChangeCalls);

            gcmWRITE_COUNTER(VPC_VG11FILLCOUNT, Context->profiler.drawFillCount);
            gcmWRITE_COUNTER(VPC_VG11STROKECOUNT, Context->profiler.drawStrokeCount);

            gcmWRITE_CONST(VPG_END);
#else
	    	PRINT_XML2(totalVGCalls);
    		PRINT_XML2(totalVGDrawCalls);
    		PRINT_XML2(totalVGStateChangeCalls);

	    	PRINT_XML(drawFillCount);
    		PRINT_XML(drawStrokeCount);

    		_Print(Context, "</VGCounters>\n");
#endif
		}

    	gcoPROFILER_EndFrame(Context->hal);

#if gcdNEW_PROFILER_FILE
        gcmWRITE_CONST(VPG_END);
#else
    	_Print(Context, "</Frame>\n\n");
#endif

		gcoPROFILER_Flush(Context->hal);

    	/* Clear variables for next frame. */
    	Context->profiler.drawFillCount   = 0;
    	Context->profiler.drawStrokeCount = 0;
        if (Context->profiler.timeEnable)
        {
	    	Context->profiler.frameStartCPUTimeusec =
    			Context->profiler.frameEndCPUTimeusec;
	    	gcoOS_GetTime(&Context->profiler.frameStartTimeusec);
		}

    	/* Next frame. */
		Context->profiler.frameNumber++;
    	Context->profiler.frameBegun = 0;
	}
}
Exemplo n.º 17
0
int main(int argc, char* argv[])
{
  sSdlWrapper* wrap = initializeSDLWrapper("Snake", 800, 600, 32, 1, 1);
  game* gameEngine  = initGame(wrap, 32, 24);
  int Selection = 0;
  sTextGFX* startUnsel = createText(wrap, "Start Game", 0xFFFFFFFF);
  sTextGFX* startSel   = createText(wrap, "Start Game", 0xFFFFF000);
  sTextGFX* exitUnsel  = createText(wrap, "Exit Game" , 0xFFFFFFFF);
  sTextGFX* exitSel    = createText(wrap, "Exit Game" , 0xFFFFF000);
  sLinkedList* titleList = 0;
  FILE* titleFile = fopen("snake.pic", "r");
  listInitialize(&titleList, sizeofPoint(), NULL);
  for(int x = 0; x < 32; x++)
    for(int y = 0; y < 24; y++)
      if(x == 0 || x == (31) || y == 0 || y == (23))
      {
	point* toAdd = createPoint(x,y);
	listPushFront(titleList, (void*)toAdd);
	free(toAdd);
      }
  while(isRunning(wrap))
  {
    beginFrame(wrap);
    if(State == -1)
    {
      readTitleFile(titleList, titleFile);
      renderList(titleList, wrap);
    }
    else if(State == 1)
      tick(gameEngine);
    else
    {
      if(Selection == 0)
      {
	renderText(wrap, startSel, 400, 300);
	renderText(wrap, exitUnsel, 400, 325);
      }
      else
      {
	renderText(wrap, startUnsel, 400, 300);
	renderText(wrap, exitSel, 400, 325);
      }
      if(keyDown(wrap, SDLK_DOWN))
	Selection = 1;
      if(keyDown(wrap,SDLK_UP))
	Selection = 0;
      if(keyDown(wrap, SDLK_RETURN))
      {
	if(Selection == 0)
	{
	  State = 1;
	  setupGame(gameEngine);
	}
	else
	  toggleRunning(wrap);
      }
      renderList(titleList, wrap);
    }
    if(keyPressed(wrap, SDLK_ESCAPE))
      toggleRunning(wrap);
    endFrame(wrap);
  }
  listClear(titleList);
  free(titleList);
  destroyText(startUnsel);
  destroyText(startSel);
  destroyText(exitUnsel);
  destroyText(exitSel);
  deinitializeWrapper(wrap);
  destroyGame(gameEngine);
  free(wrap);
  return 0;
}
Exemplo n.º 18
0
//-------------------------------------------------------------------------
void mainLoop()
{
	beginFrame();
	readKeys();

	switch(m_gameState)
	{
		case GSTATE_PreFrontEnd:
			m_scrollText = 0;
			m_userKeyBits = 0;
			m_timer = 0;
			m_lives = 3;
			m_willy.position.x = 29*8;
			m_willy.position.y = 64+8;
			m_willy.direction = 1;
			m_score = 0;
			m_oldScore = 0;
			m_gameState = GSTATE_FrontEnd;
			renderFrontEnd(FERState_PreRender);
			drawScores();
			
		case GSTATE_FrontEnd:
		{
			char feState;

			if(!m_userKeyBits)
			{
				if(++m_timer > FETime)
				{
					m_timer = 0;
					m_gameState = GSTATE_TextScroll;
					m_scrollText = (char*)szIntroText;
					feState = FERState_PreTextScroll;
				}
				else
				{
					feState = FERState_TitleFlash;
				}
			}
			else
			{
				m_gameState = GSTATE_PrePreIngame;
				feState = FERState_Cleanup;
			}

			renderFrontEnd(feState);
			
			break;
		}
			
		case GSTATE_TextScroll:
		{
			char feState = FERState_NOP;
			
			if(!m_userKeyBits)
			{
				if(++m_timer > ScrollTimer)
				{
					if(!*(++m_scrollText))
					{
						m_gameState = GSTATE_PreDemo;
						feState = FERState_Cleanup;
					}
					m_timer = 0;
				}
			}
			else 
			{
				m_gameState = GSTATE_PrePreIngame;
				feState = FERState_Cleanup;
			}

			renderFrontEnd(feState);
			
			break;
		}
			
		case GSTATE_PreDemo:
			m_timer = 0;
			m_level = LEVEL_Central_Cavern;
			prepLevel();
			m_gameState = GSTATE_Demo;
			
		case GSTATE_Demo:
		{
			if(m_userKeyBits)
				m_gameState = GSTATE_PreFrontEnd;
			else
			{
				runGame();
				if(++m_timer > DemoTime)
				{
					m_timer = 0;
					if(LEVEL_The_Final_Barrier < ++m_level)
						m_gameState = GSTATE_PreFrontEnd;
					else
						prepLevel();
				}	
			}
			break;
		}
			
		case GSTATE_PrePreIngame:
			m_level = LEVEL_Central_Cavern;
			m_gameState = GSTATE_PreIngame;
			
		case GSTATE_PreIngame:
			m_userKeyBits = 0;
			m_hMotion = 0;
			prepLevel();
			m_gameState = GSTATE_Ingame;
			
		case GSTATE_Ingame:
		{
			char state = runGame();
			if(ColDie == state)
				m_gameState = GSTATE_PreDied;
			else if(ColDoor == state)
				m_gameState = GSTATE_PreBeatLevel;
			break;
		}
			
		case GSTATE_PreBeatLevel:
			m_gameState = GSTATE_BeatLevel;
	
		case GSTATE_BeatLevel:
			m_score += 24;
			drawScores();
			m_airAmount -= 2 * AirScaler; 
			if(m_airAmount <= 0)
			{
				m_airAmount = 0;
				if(LEVEL_The_Final_Barrier != m_level)
				{
					++m_level;
					m_gameState = GSTATE_PreIngame;
				}
				else
				{
					m_gameState = GSTATE_Won;
				}
			}
			renderFrame();
			break;
			
		case GSTATE_PreDied:
			--m_lives;
			undrawLife();
			renderFrontEnd(FERState_FlashColour);
			if(!m_lives)
				m_gameState = GSTATE_PreLost;
			else
				m_gameState = GSTATE_PreIngame;
			break;
			
		case GSTATE_PreLost:
			m_level = LEVEL_The_Final_Barrier+1;
			setupLostScreen();
			prepLevel();
			m_gameState = GSTATE_Lost;
			
		case GSTATE_Lost:
			if(renderLostScreen())		
				m_gameState = GSTATE_PreFrontEnd;
			break;
			
		case GSTATE_Won:
			m_gameState = GSTATE_PreFrontEnd;
			break;
	}
	syncEndFrame();
}
Exemplo n.º 19
0
bool fboRecorder::endFrame(bool _showBuffer){
	if(!isRecording()) return false;
	
	if(!useGrabScreen){
		if(!bFrameStarted) return false;
		fbo.end();
		//fbo.getTexture().getTextureData().bFlipTexture = false;
		bFrameStarted=false;
	}
	
	static ofTexture tmpTex;
	int w = ofGetWidth();
	int h = ofGetHeight();
	if(!tmpTex.isAllocated()){
		tmpTex.allocate( w, h, GL_RGBA );
	}
	
	switch(fboRecMode){
		case VIDEOREC_MODE_FILE_H264 :
		case VIDEOREC_MODE_FILE_PNG : {
			ofPixels pix;
			pix.allocate(fbo.getWidth(),fbo.getHeight(), ofGetImageTypeFromGLType(GL_RGB));
			
			if(useGrabScreen){
				tmpTex.loadScreenData(0, 0, w, h);
				tmpTex.readToPixels(pix);
			}
			else {
				fbo.readToPixels(pix);
			}
			ofxVideoRecorder::addFrame(pix);
			
			break;
		}
			
#ifdef KM_ENABLE_SYPHON
		case VIDEOREC_MODE_SYPHON: {
			//fbo.updateTexture( fbo.getTexture().texData.textureID );
			if( useGrabScreen ){
				//syphonServer.publishScreen();
				tmpTex.loadScreenData(0, 0, ofGetWidth(), ofGetHeight());
				//tmpTex = fbo.getTexture();
				syphonServer.publishTexture( &tmpTex );
			}
			else {
				//tmpTex = fbo.getTexture();
				syphonServer.publishTexture( &fbo.getTexture() );
			}
			
			break;
		}
#endif
			
		default:
			return false;
			break;
	}
	
	// flush
	tmpTex.clear();
	
	if(_showBuffer){
		if(!useGrabScreen){
#ifdef KM_ENABLE_SYPHON
			if( fboRecMode==VIDEOREC_MODE_SYPHON ){
#else
			if(false){
#endif
				fbo.draw(0, 0, fbo.getWidth(), fbo.getHeight()); // show recorded image
			}
			else {
				fbo.draw(0, fbo.getHeight(),fbo.getWidth(), -fbo.getHeight()); // show recorded image
			}
		}
	}
	
	return true;
}

// LISTENERS
void fboRecorder::beforeDraw(  karmaControllerDrawEventArgs& _args ){
	
	beginFrame();
}

void fboRecorder::afterDraw(  karmaControllerDrawEventArgs& _args ){
	
	endFrame(videoRecShowOutput);
}
Exemplo n.º 20
0
void Renderer::draw(const double time) {
	beginFrame();
	pushPopped([this] { drawGround(); });
	pushPopped([this] { drawMan(); });
	pushPopped([this] { drawManBodyCenter(); });
}