[source lang="cpp"]void CubeRenderer::CreateDeviceResources(){ Direct3DBase::CreateDeviceResources(); VertexPos vertices[] = { DirectX::XMFLOAT3(0.0f, 0.0f, 0.2f), DirectX::XMFLOAT3(1.0f, 0.0f, 0.2f), DirectX::XMFLOAT3(0.0f, 1.0f, 0.2f), DirectX::XMFLOAT3(0.0f, 1.0f, 0.2f), DirectX::XMFLOAT3(1.0f, 1.0f, 0.2f), DirectX::XMFLOAT3(1.0f, 0.0f, 0.2f), }; D3D11_BUFFER_DESC TT_vertexDesc; ZeroMemory(&TT_vertexDesc, sizeof(TT_vertexDesc)); TT_vertexDesc.Usage = D3D11_USAGE_DEFAULT; TT_vertexDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER; TT_vertexDesc.ByteWidth = sizeof(VertexPos) * 6; D3D11_SUBRESOURCE_DATA sResource; ZeroMemory(&sResource, sizeof(sResource)); sResource.pSysMem = vertices; DX::ThrowIfFailed(m_d3dDevice->CreateBuffer(&TT_vertexDesc, &sResource, &TT_vertexBuffer)); //Load the Shaders //Load the vertex shader (the build configuration / properties of the shader file deals with compile to .cso) auto task_LoadTTVS = DX::ReadDataAsync("VS_TriangleTest.cso"); auto task_CreateTTVS = task_LoadTTVS.then([this](DX::ByteArray ba) { //This async load / helper classes are taken straight from the template. Why not. auto bc_VS = ba.data; DX::ThrowIfFailed(m_d3dDevice->CreateVertexShader(bc_VS->Data, bc_VS->Length, nullptr, &VS_TT)); //Create Input Layout Description D3D11_INPUT_ELEMENT_DESC vertexLayout[] = { {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0} }; //Create the Input Layout DX::ThrowIfFailed(m_d3dDevice->CreateInputLayout(vertexLayout, ARRAYSIZE(vertexLayout), bc_VS->Data, bc_VS->Length, &TT_inputLayout)); }); //Load the pixel shader (again, the build and configuration properties of the shader file deal with compilation auto task_LoadTTPS = DX::ReadDataAsync("PS_TriangleTest.cso"); auto task_CreateTTPS = task_LoadTTPS.then([this](DX::ByteArray ba) { auto bc_PS = ba.data; DX::ThrowIfFailed(m_d3dDevice->CreatePixelShader(bc_PS->Data, bc_PS->Length, nullptr, &PS_TT)); m_loadingComplete = true; //dont really work properly as earlier shaders might take longer but meh won't be the issue here });}[/source] THen I hijack the rendering bit. FYI I've confirmed that all the context calls are run
const float Red[] = { 1.0f, 0.0f, 0.0f, 1.0f };
m_d3dContext->ClearRenderTargetView(m_renderTargetView.Get(), Red);
//Clear the depth stenicl view
m_d3dContext->ClearDepthStencilView(m_depthStencilView.Get(), D3D11_CLEAR_DEPTH, 1.0f, 0);
if (!m_loadingComplete)
return;
m_d3dContext->IASetInputLayout(TT_inputLayout.Get());
m_d3dContext->OMSetRenderTargets(1, m_renderTargetView.GetAddressOf(), m_depthStencilView.Get());
//Test triangle following some book code to check that everything is working
UINT str = sizeof(VertexPos);
UINT oset = 0;
m_d3dContext->IASetVertexBuffers(0, 1, &TT_vertexBuffer, &str, &oset);
m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
m_d3dContext->VSSetShader(VS_TT.Get(), 0, 0);
m_d3dContext->PSSetShader(PS_TT.Get(), 0, 0);
m_d3dContext->Draw(6, 0);
then the world's simplest shaders (even desperately rewritten to copy ones on the net using a structure, obviously this pass through could just be main function only returning float4...
struct VOut
{
float4 position : SV_POSITION;
};
VOut main( float4 pos : POSITION )
{
VOut output;
output.position = pos;
return output;
}
and the pixel pencil...
float4 main(float4 position : SV_POSITION) : SV_TARGET
{
return float4 (0.0f, 1.0f, 1.0f, 1.0f);
}
and wahay, I always get a red screen. ive tried making the triangles screen sized in case its not -1,-1 to 1,1 but still no joy. any help for a tired n00b? thanks!!

Find content
Not Telling