locked
How to draw texture on screen once texture is made ?

    Question

  • I have made a texture and now I want to fill the screen with it.

    How do I go about it ?

    void Renderer::Render()
    {
    	m_d3dContext->ClearRenderTargetView(
    		m_renderTargetView.Get(),
    		Colors::MidnightBlue
    		);
    	
    	
    	m_d3dContext->ClearDepthStencilView(
    		m_depthStencilView.Get(),
    		D3D11_CLEAR_DEPTH,
    		1.0f,
    		0
    		);
    
    	m_d3dContext->OMSetRenderTargets(
    		1,
    		m_renderTargetView.GetAddressOf(),
    		m_depthStencilView.Get()
    		);
    	
    
    	/////////////////////////////////////////////
    	
    	UINT fred;
    	m_d3dDevice->CheckMultisampleQualityLevels(DXGI_FORMAT_R8G8B8A8_UNORM, 16, &fred);
    
    	D3D11_TEXTURE2D_DESC desc;
    	ZeroMemory(&desc, sizeof(D3D11_TEXTURE2D_DESC));
    	desc.ArraySize = 1;
    	desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
    	desc.CPUAccessFlags = 0;
    	desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
    	desc.MipLevels = 1;
    	desc.MiscFlags = 0;
    	desc.SampleDesc.Count = 1; // 4;
    	desc.SampleDesc.Quality = fred;
    	desc.Usage = D3D11_USAGE_DEFAULT;
    	desc.Width = 1000;
    	desc.Height = 1000;
    	
    
    	ID3D11Texture2D *pTexture = NULL;
    
    
    
    	D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDescription;
    	ZeroMemory(&renderTargetViewDescription, sizeof(renderTargetViewDescription));
    	renderTargetViewDescription.Format = desc.Format;
    	renderTargetViewDescription.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D; // MS;
    	
    	D3D11_SUBRESOURCE_DATA tbsd;
    
    	byte *buf = new byte[1000*1000 * 4];
    
    
    	int cx;
    	
    	for (cx = 0; cx <= (1000000*4)-1; cx++)
    		buf[cx] = 0xff;
    	
    	tbsd.pSysMem = (void *) buf;
    	tbsd.SysMemPitch = 1000 * 4;
    	tbsd.SysMemSlicePitch = 1000*1000 * 4; // Not needed since this is a 2d texture
    
    	HRESULT hr;
    	if (FAILED(m_d3dDevice->CreateTexture2D(&desc, &tbsd, &pTexture)))
    		return;
    
    
    	
    	DX::ThrowIfFailed(
    	m_d3dDevice->CreateRenderTargetView(
    	pTexture,
    		&renderTargetViewDescription,
    		&m_renderTargetView
    		)
    		);
    
    
    		delete [] buf;
    	}
    


    n.Wright

    Monday, September 16, 2013 2:24 AM

Answers

All replies