コード例 #1
0
void DirectXGraphics::renderGame(Game *game)
{
	GameStateManager *gsm = game->getGSM();
	World *world = gsm->getWorld();
	GameText *text = game->getText();

	// CHECK TO SEE IF WE STILL HAVE THE GPU
	HRESULT result = graphicsDevice->TestCooperativeLevel();

	// IF WE HAVE THE GPU, RENDER THE GAME
	if (SUCCEEDED(result)) 
	{
		// NOW PREPARE TO RENDER THE LISTS USING
		// BATCH TEXTURE RENDERING
		startDirectXFrameRendering();	
		spriteHandler->Begin(D3DXSPRITE_ALPHABLEND);

		// RENDER THE WORLD RENDER LIST
		renderWorldRenderList();
				
		// RENDER THE GUI RENDER LIST
		renderGUIRenderList();

		// RENDER THE TEXT
		renderText(text);

		// WRAP UP RENDERING RESOURCES
		if (FAILED(spriteHandler->End()))
		{
			text->writeDebugOutput("\nspriteHandler->End(): FAILED");
		}

		endDirectXFrameRendering();

	}

	// WE'VE LOST THE GPU, SLEEP UNTIL WE GET IT BACK
	else if (result == D3DERR_DEVICELOST) 
	{ 
		spriteHandler->OnLostDevice();
		textFont->OnLostDevice();
		Sleep(100); 
	}

	// WE'VE GOT IT BACK, RELOAD EVERYTHING. NOTE THAT
	// WE'LL ONLY GET THIS MESSAGE ONCE.
	else if (result == D3DERR_DEVICENOTRESET)
	{ 
		if (FAILED(graphicsDevice->Reset(&presentParameters)))
		{
			game->getText()->writeDebugOutput("\ngraphicsDevice->Reset: FAILED - Reloading GPU images");
			game->reloadAllDevices();
		}
		else
		{
			spriteHandler->OnResetDevice();
			textFont->OnResetDevice();
		}
	}
}
コード例 #2
0
/*
	initText - Provides an example of how to render text to our screen every frame,
	allowing for the text to continually change. This method adds a text object
	to the text manager (GameText), which allows it to be updated each frame. This
	method should be called only once for each object.
*/
void DummyTextGenerator::initText(Game *game)
{
	// FIRST UPDATE THE TEXT THIS GENERATOR IS USING
	appendTargetFPS(game);

	// AND THEN HAND IT TO THE TEXT MANAGER, SPECIFYING WHERE IT SHOULD BE RENDERED
	GameText *text = game->getText();
	text->addText(&textToGenerate, 350, 50, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
}
コード例 #3
0
/*
	initText - Provides an example of how to render text to our screen every frame,
	allowing for the text to continually change. This method adds a text object
	to the text manager (GameText), which allows it to be updated each frame. This
	method should be called only once for each object.
*/
void BalloonEscapeTextGenerator::initText(Game *game)
{
    // FIRST UPDATE THE TEXT THIS GENERATOR IS USING
    appendMouseCoords(game);

    // AND THEN HAND IT TO THE TEXT MANAGER, SPECIFYING WHERE IT SHOULD BE RENDERED
    GameText *text = game->getText();
    text->addText(&textToGenerate, W_TEXT_X, W_TEXT_Y, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
}
コード例 #4
0
/*
	initText - Provides an example of how to render text to our screen every frame,
	allowing for the text to continually change. This method adds a text object
	to the text manager (GameText), which allows it to be updated each frame. This
	method should be called only once for each object.
*/
void StraightLineRPGTextGenerator::initText(Game *game)
{
	// FIRST UPDATE THE TEXT THIS GENERATOR IS USING
	appendPlayerHealth(game);

	// AND THEN HAND IT TO THE TEXT MANAGER, SPECIFYING WHERE IT SHOULD BE RENDERED
	GameText *text = game->getText();
	text->addText(&textHealth, W_TEXT_X, W_TEXT_Y, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());

	appendPlayerMP(game);
	text->addText(&textMP, W_TEXT_P_MP_X, W_TEXT_P_MP_Y, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());

	appendPlayerStr(game);
	text->addText(&textStr, W_TEXT_P_STR_X, W_TEXT_P_STR_Y, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());

	appendPlayerDef(game);
	text->addText(&textDefense, W_TEXT_P_DEF_X, W_TEXT_P_DEF_Y, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
}
コード例 #5
0
void OdysseyTextGenerator::initText(Game *game)
{
	GameText *text = game->getText();
	text->addText(&W_SPALSH_TEXT, 400, 350, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
	text->addText(&W_MAIN_TEXT_1, 430, 350, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
	text->addText(&W_MAIN_TEXT_2, 455, 370, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
	text->addText(&W_MAIN_TEXT_3, 455, 390, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
	text->addText(&W_MAIN_TEXT_4, 475, 410, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
	text->addText(&textToGenerate, 500, 2, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
	text->addText(&W_PAUSE_TEXT_1, 500, 610, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
	text->addText(&W_PAUSE_TEXT_2, 500, 640, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
	text->addText(&W_CONT_TEXT, 500, 550, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());
	text->addText(&W_GAME_OVER_QUIT, 500, 570, game->getGraphics()->getScreenWidth(), game->getGraphics()->getScreenHeight());

}
コード例 #6
0
/*
	createDirectXDeviceAndSpriteHandler - THIS METHOD CREATES OUR GPU AND
	SPRITE HANDLER (used for batch rendering textures) USING THE COLOR
	FORMAT AND SCREEN RESOLUTION OF OUR CHOICE.
*/
HRESULT DirectXGraphics::createDirectXDeviceAndSpriteHandler()
{
	HRESULT result;
	GameText *text = game->getText();

	// CREATE OUR GPU
    result = d3d->CreateDevice(D3DADAPTER_DEFAULT,
						D3DDEVTYPE_HAL,
						presentParameters.hDeviceWindow,
						D3DCREATE_HARDWARE_VERTEXPROCESSING,
						&presentParameters,
						&graphicsDevice);
	
	// IF GPU CREATION WAS SUCCESSFUL
	if (SUCCEEDED(result))
	{
		text->writeDebugOutput("SUCCEEDED");

		text->writeDebugOutput("\nD3DXCreateSprite(): ");

		// CREATE OUR SPRITE HANDLER
	    result = D3DXCreateSprite(graphicsDevice, &spriteHandler);
		if (SUCCEEDED(result))
		{
			text->writeDebugOutput("SUCCEEDED");
		}
		else
			text->writeDebugOutput("FAILED");

		this->initTextFont(20);
	}
	else
		text->writeDebugOutput("FAILED");

	return result;
}