//--------------------------------------------------------------------------------------
// Create any D3D11 resources that aren't dependant on the back buffer
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnD3D11CreateDevice( ID3D11Device* pd3dDevice, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc,
									  void* pUserContext )
{
	vegetationRendering = new VegetationRendering();

	Window::setHandle(DXUTGetHWND());

	ID3D11DeviceContext* deviceContext = DXUTGetD3D11DeviceContext();
	dialogResourceManager.OnD3D11CreateDevice(pd3dDevice, deviceContext);
	textHelper = CDXUTTextHelper(pd3dDevice, deviceContext, &dialogResourceManager, 30);

	vegetationRendering->init(pd3dDevice);

	return S_OK;
}
Example #2
0
void HUD::init(ID3D11Device* graphicsDevice, Game* game)
{
	dialog.Init(&dialogResourceManager);
	dialog.SetCallback(HUD::onGuiEvent, game);

	ID3D11DeviceContext* deviceContext = DXUTGetD3D11DeviceContext();

	Terrain* terrain = game->terrain;
	Camera* camera = game->camera;

	textVisible = true;

	textHelper = CDXUTTextHelper(graphicsDevice, deviceContext, &dialogResourceManager, 15);

	unsigned width = 200;
	unsigned height = 20;
	unsigned delta = height * 2;
	unsigned i = 1;
	unsigned y = 0;

	WCHAR sz[200];

	float movementSpeed = camera->getMovementSpeed();
	StringCchPrintf(sz, 200, L"Camera Movement: %.1f", movementSpeed);
	dialog.AddStatic(CameraMovementStatic, sz, 0, y, width, height);
	dialog.AddSlider(CameraMovementSlider, 0, y + height, width, height, 1, 500, (int)movementSpeed);
	y += delta;

	float bumpiness = terrain->getBumpiness();
	StringCchPrintf(sz, 200, L"Bumpiness: %.1f", bumpiness);
	dialog.AddStatic(BumpinessStatic, sz, 0, y, width, height);
	dialog.AddSlider(BumpinessSlider, 0, y + height, width, height, 0, 2000, (int)bumpiness);
	y += delta;

	float minPixelPerTriangle = terrain->getMinPixelPerTriangle();
	StringCchPrintf(sz, 200, L"Triangle Size: %.1f", minPixelPerTriangle);
	dialog.AddStatic(MinPixelPerTriangleStatic, sz, 0, y, width, height);
	dialog.AddSlider(MinPixelPerTriangleSlider, 0, y + height, width, height, 0, 20000, (int)(minPixelPerTriangle * 100.0f));
	y += delta;

	float roughnessModificator = terrain->getRoughnessModificator();
	StringCchPrintf(sz, 200, L"Roughness Modificator: %.2f", roughnessModificator);
	dialog.AddStatic(RoughnessModificatorStatic, sz, 0, y, width, height);
	dialog.AddSlider(RoughnessModificatorSlider, 0, y + height, width, height, 0, 1000, (int)(roughnessModificator * 100.0f));
	y += delta;
	
	float textureRepeat = terrain->getColormapRepeat();
	StringCchPrintf(sz, 200, L"Texture Repeat: %.1f", textureRepeat);
	dialog.AddStatic(TextureRepeatStatic, sz, 0, y, width, height);
	dialog.AddSlider(TextureRepeatSlider, 0, y + height, width, height, 1, 1024, (int)textureRepeat);
	y += delta;

	delta = (unsigned)(height * 1.2f);

	dialog.AddCheckBox(WireframeCheckbox, L"Wireframe (TAB)", 0, y + delta * i++, width, height, game->isWireframe(), VK_TAB); 
	dialog.AddCheckBox(UpdateLODCheckbox, L"Update LOD", 0, y + delta * i++, width, height, !camera->isLocked()); 
	dialog.AddCheckBox(CPUFrustumCullingCheckbox, L"CPU Frustum Culling", 0, y + delta * i++, width, height, terrain->getCPUFrustumCullingEnabled()); 
	dialog.AddCheckBox(GPUFrustumCullingCheckbox, L"GPU Frustum Culling", 0, y + delta * i++, width, height, terrain->getGPUFrustumCullingEnabled()); 
	dialog.AddCheckBox(SnapToTerrainCheckbox, L"Snap to Terrain", 0, y + delta * i++, width, height, !game->isFreeCamera()); 
	dialog.AddCheckBox(ColormapCheckbox, L"Colormap", 0, y + delta * i++, width, height, terrain->getColormapEnabled());
	dialog.AddCheckBox(LightingCheckbox, L"Lighting", 0, y + delta * i++, width, height, terrain->getLightingEnabled()); 
	dialog.AddCheckBox(HeightTextureCheckbox, L"Height-based Texturing", 0, y + delta * i++, width, height, terrain->getHeightTextureEnabled());
	dialog.AddCheckBox(SlopeTextureCheckbox, L"Slope-based Texturing", 0, y + delta * i++, width, height, terrain->getSlopeTextureEnabled());
	dialog.AddCheckBox(RoughnessCheckbox, L"Enable Roughness", 0, y + delta * i++, width, height, terrain->getRoughnessEnabled());
	dialog.AddCheckBox(AntiShimmeringCheckbox, L"Anti Shimmering", 0, y + delta * i++, width, height, terrain->getAntiShimmeringEnabled());
	dialog.AddCheckBox(ShowNodesCheckbox, L"Show Nodes", 0, y + delta * i++, width, height, terrain->getShowNodesEnabled());
	dialog.AddCheckBox(UniformPatchSizeCheckbox, L"Uniform Patch Size", 0, y + delta * i++, width, height, terrain->getUniformPatchSizeEnabled());
	dialog.AddCheckBox(BruteForceCheckbox, L"Brute Force", 0, y + delta * i++, width, height, terrain->getBruteForceEnabled());

	dialogResourceManager.OnD3D11CreateDevice(graphicsDevice, deviceContext);
}