Esempio n. 1
0
int main(int argc, char* argv[])
{
	// Get device singleton instance.
	auto device = RenderDevice::getInstance();
	
	device->init();
	
	device->setQuitOnStart(true);
	
	Text text(20.0f);
	
	text.setPosition(0, 0);
	text.setColor(Color::White);
	text.setString("Hello Text");
	
	// Create the render texture, make it 100x100
	RenderTexture renderTexture;
	renderTexture.create(100, 100);
	// Start drawing on the texture
	renderTexture.startFrame();
	// Draw the text
	text.draw();
	// End drawing to the texture
	renderTexture.endFrame();
	
	// Save the render texture to a file
	renderTexture.save("out.png");
	
	// Main loop
	while(device->isRunning())
	{
		device->setTargetScreen(Screen::Top);
		device->clear(Color::Black);
		device->startFrame();
		// Draw the text
		text.draw();
		device->endFrame();
		
		device->setTargetScreen(Screen::Bottom);
		device->clear(Color::Black);
		device->startFrame();
		device->endFrame();
		
		device->swapBuffers();
	}
	
	// DON'T FORGET TO CALL THIS OR THE 3DS WILL CRASH AT EXIT
	device->destroy();
	
	return 0;
}
Esempio n. 2
0
void draw() {
	startFrame();
	sceGuDisable(GU_TEXTURE);

	// Different formats - throughmode.
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_TRANSFORM_2D, 4, NULL, vertices_nofmt);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_8BIT | GU_TRANSFORM_2D, 4, NULL, vertices_s8);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 4, NULL, vertices_s16);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 4, NULL, vertices_f32);

	// Different formats - transform.
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_TRANSFORM_3D, 4, NULL, vertices_nofmt);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_8BIT | GU_TRANSFORM_3D, 4, NULL, vertices_s8x);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 4, NULL, vertices_s16x);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, NULL, vertices_f32x);

	// Wrong order (CCW.)
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 4, NULL, vertices_rev);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 4, NULL, vertices_revx);

	// Incomplete (only one prim.)
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 1, NULL, vertices_incomp);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 1, NULL, vertices_incompx);

	endFrame();
}
Esempio n. 3
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();
  }
}
Esempio n. 4
0
void Sprite::setZIndex(float new_z_index){
  beginFrame();
  removeSprite(this);
  z_index = new_z_index;
  addSprite(this);
  endFrame();
}
Esempio n. 5
0
void Vigasoco::mainLoop()
{
	// start async game logic
	_asyncThread->start();

	// main sync loop
	while (true){
		// call template method to process any platform specific events
		if (!processEvents()){
			// if we've received the quit message, exit

			return;
		}

		// waits if necessary before processing this interrupt
		_timingHandler->waitThisInterrupt();

		bool processVideo = _timingHandler->processVideoThisInterrupt();
		bool processLogic = _timingHandler->processLogicThisInterrupt();

		// if we have to process game logic
		if (processLogic){
			// execute sync game logic
			_driver->runSync();
		}

		// if we have to process video
		if (processVideo){
			// calls template method to notify of the start of a frame
			initFrame();

			// process inputs
			_inputHandler->process();

			// change core state if necessary
			processCoreInputs();

			bool skipVideo = _timingHandler->skipVideoThisInterrupt();

			if (!skipVideo){
				// render game screen
				_driver->render(_drawPlugin);
				_driver->showGameLogic(_drawPlugin);
			}

			showFPS(skipVideo);

			if (!skipVideo){
				// render game screen to our screen
				_drawPlugin->render(_timingHandler->isThrottling());
			}

			// call template method to notify the end of a frame
			endFrame();
		}

		// end this interrupt processing
		_timingHandler->endThisInterrupt();
	}
}
Esempio n. 6
0
void drawLine(int xSource, int ySource, int xDest, int yDest)	{
	SDL_Simplewin sw = getSw(NULL);
	SDL_SetRenderDrawColor(sw->renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
	SDL_RenderDrawLine(sw->renderer,xSource,ySource,xDest,yDest);
	//SDL_Delay(20);
	endFrame();
}
Esempio n. 7
0
//読み取り後の計算
int InstancePartStatus::getFrame(int frame) const
{
	int	reftime = static_cast<int>(frame * m_refSpeed) - m_refKeyframe; //開始から現在の経過時間
	if(reftime < 0){ return frame; }									   //そもそも生存時間に存在していない

	int inst_scale = (m_refEndframe - m_refStartframe) + 1; //インスタンスの尺
	if (inst_scale <= 0){ return frame; }					//尺が0もしくはマイナス(あり得ない

	int	nowloop = reftime / inst_scale;		//現在までのループ数
	int nowframe = reftime % inst_scale;	//ループを加味しないインスタンスアニメ内のフレーム
	

	//無限ループで無い時にループ数をチェック
	if (!m_infinity){
		//回数制限があるので終端チェックをする
		int checkloopnum = m_refloopNum;		//ループ終了数
		if (m_pingpong){ checkloopnum *= 2; }	//pingpongの場合では2倍にする

		if (nowloop >= checkloopnum){
			return endFrame();		//ループ終了のときは終わりのフレームを返す
		}
	}

	//現在の再生フレームの計算
	bool isReverse = m_reverse;
	if (m_pingpong && (nowloop % 2 == 1)){
		isReverse = !isReverse;	//反転
	}

	if (isReverse){
		return m_refEndframe - nowframe;	//リバースの時
	}
	return nowframe + m_refStartframe;	//通常時
}
Esempio n. 8
0
//! End the current benchmark
static void end() {
	
	if(!g_enabled || g_currentStatus == None) {
		return;
	}
	
	if(g_currentStatus != None && g_startTime > SkipFrames) {
		
		if(isFrame(g_currentStatus)) {
			// Skip the last frame - it may not be reperasentative
		} else {
			endFrame();
		}
		
		display(g_currentStatus, g_current);
		
		arx_assert(size_t(g_currentStatus) < ARRAY_SIZE(g_results));
		g_results[g_currentStatus] += g_current;
		if(isNormalFrame(g_currentStatus)) {
			g_results[0] += g_current;
		}
		
	}
	
	g_currentStatus = None;
	g_startTime = 0;
	g_current = Result();
	
}
Esempio n. 9
0
void begin(Status status) {
	
	if(!g_enabled || status == None) {
		return;
	}
	
	if(status != g_currentStatus) {
		end();
		g_currentStatus = status;
	}
	
	if(g_startTime < SkipFrames && isFrame(status)) {
			// Skip the first frames - they may not be reperasentative
		g_startTime++;
	} else if(g_startTime <= SkipFrames) {
		g_startTime = platform::getTimeUs();
	} else {
		endFrame();
	}
	
	if(g_timeLimit != std::numeric_limits<u64>::max() && isNormalFrame(g_currentStatus)
	   && g_results[0].m_totalTime + g_current.m_totalTime >= g_timeLimit) {
		mainApp->quit();
	}
	
}
Esempio n. 10
0
void draw() {
    startFrame();
    setSimpleTexture();

    // Different formats - throughmode.
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_TRANSFORM_2D, 2, NULL, vertices_nofmt);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_8BIT | GU_TRANSFORM_2D, 2, NULL, vertices_s8);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, vertices_s16);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, NULL, vertices_f32);

    // Different formats - transform.
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_TRANSFORM_3D, 2, NULL, vertices_nofmt);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_8BIT | GU_TRANSFORM_3D, 2, NULL, vertices_s8x);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 2, NULL, vertices_s16x);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 2, NULL, vertices_f32x);

    // Rotated (not TL - BR.)
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, NULL, vertices_trbl);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 2, NULL, vertices_brtl);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 2, NULL, vertices_trblx);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 2, NULL, vertices_brtlx);

    // Incomplete (only one prim.)
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_2D, 1, NULL, vertices_incomp);
    sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_VERTEX_32BITF | GU_TRANSFORM_3D, 1, NULL, vertices_incompx);

    endFrame();
}
Esempio n. 11
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();
}
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();
}
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();
}
Esempio n. 14
0
int main(int argc, char* argv[])
{
	auto device = RenderDevice::getInstance();
	
	device->init();
	device->setQuitOnStart(true);
	
	Text text(30.0f);
	text.setString("Random color");
	
	// Create a thread that changes the text color every second
	Thread thread([&](void*)
	{
		while(device->isRunning())
		{
			text.setColor(Color::Random());
			Thread::sleep(Time::seconds(1));
		}
	});
	
	// Start the thread
	thread.start();
	
	while(device->isRunning())
	{
		device->setTargetScreen(Screen::Top);
		device->clear(Color::Black);
		device->startFrame();
		text.draw();
		device->endFrame();
		
		device->setTargetScreen(Screen::Bottom);
		device->clear(Color::Black);
		device->startFrame();
		device->endFrame();
		
		device->swapBuffers();
	}
	
	// Wait the thread end
	thread.join();
	
	// DON'T FORGET TO CALL THIS OR THE 3DS WILL CRASH AT EXIT
	device->destroy();
	
	return 0;
}
Esempio n. 15
0
int main(int argc, char* argv[])
{
	// Get device singleton instance.
	auto device = RenderDevice::getInstance();
	
	device->init();
	
	device->setQuitOnStart(true);
	
	// Create a rectangle shape
	RectangleShape rect(100, 60, 100, 100);
	// And we set it's color to blue
	rect.setColor(Color::Blue);
	
	rect.setOutlineColor(Color::Red);
	rect.setOutlineThickness(2);
	
	// Create a line
	LineShape line(0, 0, BOTTOM_SCREEN_WIDTH, BOTTOM_SCREEN_HEIGHT);
	// And set its color to yellow
	line.setColor(Color::Yellow);
	
	// Main loop
	while(device->isRunning())
	{
		device->setTargetScreen(Screen::Top);
		device->clear(Color::Black);
		device->startFrame();
		// Draw the rectangle to top screen
		rect.draw();
		device->endFrame();
		
		device->setTargetScreen(Screen::Bottom);
		device->clear(Color::Black);
		device->startFrame();
		// Draw a diagonal line on bottom screen
		line.draw();
		device->endFrame();
		
		device->swapBuffers();
	}
	
	// DON'T FORGET TO CALL THIS OR THE 3DS WILL CRASH AT EXIT
	device->destroy();
	
	return 0;
}
Esempio n. 16
0
void SaslServer::completed(bool succeeded)
{
    void* frameToken = startFrame();

    void* listToken = encoder.startList8(&SASL_OUTCOME);
    encoder.writeUByte(succeeded ? 0 : 1);
    encoder.endList8(1, listToken);

    endFrame(frameToken);
    QPID_LOG_CAT(debug, protocol, id << " Sent SASL-OUTCOME(" << (succeeded ? 0 : 1) << ") " << encoder.getPosition());
}
Esempio n. 17
0
void SaslClient::response(const std::string* r)
{
    void* frame = startFrame();

    void* token = encoder.startList32(&SASL_RESPONSE);
    if (r) encoder.writeBinary(*r);
    else encoder.writeNull();
    encoder.endList32(1, token);

    endFrame(frame);
    QPID_LOG_CAT(debug, protocol, id << " Sent SASL-RESPONSE(" << (r ? *r : "null") << ")");
}
Esempio n. 18
0
void SaslServer::challenge(const std::string* c)
{
    void* frameToken = startFrame();

    void* listToken = encoder.startList32(&SASL_CHALLENGE);
    if (c) encoder.writeBinary(*c);
    else encoder.writeNull();
    encoder.endList32(1, listToken);

    endFrame(frameToken);
    QPID_LOG_CAT(debug, protocol, id << " Sent SASL-CHALLENGE(" << (c ? *c : NULL_) << ") " << encoder.getPosition());
}
Esempio n. 19
0
void SaslClient::init(const std::string& mechanism, const std::string* response, const std::string* hostname)
{
    void* frame = startFrame();

    void* token = encoder.startList32(&SASL_INIT);
    encoder.writeSymbol(mechanism);
    if (response) encoder.writeBinary(*response);
    else encoder.writeNull();
    if (hostname) encoder.writeString(*hostname);
    else encoder.writeNull();
    encoder.endList32(3, token);

    endFrame(frame);
    QPID_LOG_CAT(debug, protocol, id << " Sent SASL-INIT(" << mechanism << ", " << (response ? *response : "null") << ", " << (hostname ? *hostname : "null") << ")");
}
    /**
     * 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();
    }
Esempio n. 21
0
void draw() {
	startFrame();
	sceGuDisable(GU_TEXTURE);

	sceGuDrawArray(GU_POINTS, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices1);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices1 + 1);
	sceGuDrawArray(GU_POINTS, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices1x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices1x + 1);

	sceGuDrawArray(GU_LINES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices2);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices2 + 1);
	sceGuDrawArray(GU_LINES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices2x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices2x + 1);

	sceGuDrawArray(GU_LINE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices3);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices3 + 1);
	sceGuDrawArray(GU_LINE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices3x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices3x + 1);

	sceGuDrawArray(GU_TRIANGLES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices4);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices4 + 1);
	sceGuDrawArray(GU_TRIANGLES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices4x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices4x + 1);

	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices5);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices5 + 1);
	sceGuDrawArray(GU_TRIANGLE_STRIP, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices5x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices5x + 1);

	sceGuDrawArray(GU_TRIANGLE_FAN, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices6);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, vertices6 + 1);
	sceGuDrawArray(GU_TRIANGLE_FAN, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices6x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, vertices6x + 1);

	sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices7);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices7 + 1);
	sceGuDrawArray(GU_SPRITES, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices7x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices7x + 1);

	// Verify that it also works when auto-increasing the vertex pointer.
	sceGuDrawArray(GU_TRIANGLE_FAN, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 1, NULL, vertices8);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 3, NULL, NULL);
	sceGuDrawArray(GU_TRIANGLE_FAN, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 1, NULL, vertices8x);
	sceGuDrawArray(GU_CONTINUE, GU_COLOR_8888 | GU_VERTEX_16BIT | GU_TRANSFORM_3D, 3, NULL, NULL);

	endFrame();
}
Esempio n. 22
0
  XDEBUG_NOTIMPLEMENTED

static Variant HHVM_FUNCTION(xdebug_stop_trace) {
  if (!XDEBUG_GLOBAL(ProfilerAttached)) {
    return false;
  }

  auto profiler = xdebug_profiler();
  if (!profiler->isTracing()) {
    return false;
  }

  // End with xdebug_stop_trace()
  profiler->endFrame(init_null().asTypedValue(), nullptr, false);
  auto filename = profiler->getTracingFilename();
  profiler->disableTracing();
  detach_xdebug_profiler_if_needed();
  return filename;
}
Esempio n. 23
0
EventBase* WaveEventBase::mid(unsigned b, unsigned e)
{
    WaveEventBase* ev = new WaveEventBase(*this);
    unsigned fr = frame();
    unsigned start = fr - b;
    if (b > fr)
    {
        start = 0;
        ev->setSpos(spos() + b - fr);
    }
    unsigned end = endFrame();

    if (e < end)
        end = e;

    ev->setFrame(start);
    ev->setLenFrame(end - b - start);
    return ev;
}
Esempio n. 24
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;
	}
}
Esempio n. 25
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;
}
Esempio n. 26
0
bool CDVDSubtitleParserMPL2::Open(CDVDStreamInfo &hints)
{
  if (!CDVDSubtitleParserText::Open())
    return false;

  // MPL2 is time-based, with 0.1s accuracy
  m_framerate = DVD_TIME_BASE / 10.0;

  char line[1024];

  CRegExp reg;
  if (!reg.RegComp("\\[([0-9]+)\\]\\[([0-9]+)\\]"))
    return false;
  CDVDSubtitleTagMicroDVD TagConv;

  while (m_pStream->ReadLine(line, sizeof(line)))
  {
    if ((strlen(line) > 0) && (line[strlen(line) - 1] == '\r'))
      line[strlen(line) - 1] = 0;

    int pos = reg.RegFind(line);
    if (pos > -1)
    {
      const char* text = line + pos + reg.GetFindLen();
      std::string startFrame(reg.GetMatch(1));
      std::string endFrame  (reg.GetMatch(2));
      CDVDOverlayText* pOverlay = new CDVDOverlayText();
      pOverlay->Acquire(); // increase ref count with one so that we can hold a handle to this overlay

      pOverlay->iPTSStartTime = m_framerate * atoi(startFrame.c_str());
      pOverlay->iPTSStopTime  = m_framerate * atoi(endFrame.c_str());

      TagConv.ConvertLine(pOverlay, text, strlen(text));
      m_collection.Add(pOverlay);
    }
  }

  return true;
}
Esempio n. 27
0
void SaslServer::mechanisms(const std::string& mechanisms)
{
    void* frameToken = startFrame();

    std::vector<std::string> parts = split(mechanisms, SPACE);
    void* listToken = encoder.startList32(&SASL_MECHANISMS);
    if (parts.size() > 1) {
        void* arrayToken = encoder.startArray8(Constructor(SYMBOL8));
        for (std::vector<std::string>::const_iterator i = parts.begin();i != parts.end(); ++i) {
            uint8_t size = i->size() > std::numeric_limits<uint8_t>::max() ? std::numeric_limits<uint8_t>::max() : i->size();
            encoder.write(size);
            encoder.writeBytes(i->data(), size);
        }
        encoder.endArray8(parts.size(), arrayToken);
    } else {
        encoder.writeSymbol(mechanisms);
    }
    encoder.endList32(1, listToken);

    endFrame(frameToken);
    QPID_LOG_CAT(debug, protocol, id << " Sent SASL-MECHANISMS(" << mechanisms << ") " << encoder.getPosition());
}
Esempio n. 28
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();
}
Esempio n. 29
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();

}
Esempio n. 30
0
int main(int argc, char* argv[])
{
    // Get device singleton instance.
    auto device = RenderDevice::getInstance();
    // We use a class called InputManager for checking input.
    // It's a singleton so we need to get the instance.
    auto input = InputManager::getInstance();

    device->init();

    Text text(20.0f);

    text.setPosition(100, 100);
    text.setColor(Color::White);

    // Main loop
    while(device->isRunning())
    {
        std::string key;

        if(input->isKeyDown(Keys::A))
        {
            key = "A";
        } else if(input->isKeyDown(Keys::B))
        {
            key = "B";
        } else if(input->isKeyDown(Keys::X))
        {
            key = "X";
        } else if(input->isKeyDown(Keys::Y))
        {
            key = "Y";
        } else if(input->isKeyDown(Keys::L))
        {
            key = "L";
        } else if(input->isKeyDown(Keys::R))
        {
            key = "R";
        } else if(input->isKeyDown(Keys::Select))
        {
            key = "Select";
        } else // ... You should check other buttons too
        {
            key = "Nothing";
        }

        // Quit if the start button is pressed
        if(input->isKeyDown(Keys::Start))
        {
            device->quit();
        }

        text.setString(key + " pressed.");

        device->setTargetScreen(Screen::Top);
        device->clear(Color::Black);
        device->startFrame();
        text.draw();
        device->endFrame();

        device->setTargetScreen(Screen::Bottom);
        device->clear(Color::Black);
        device->startFrame();
        device->endFrame();

        device->swapBuffers();
    }

    // DON'T FORGET TO CALL THIS OR THE 3DS WILL CRASH AT EXIT
    device->destroy();

    return 0;
}