1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
float ClearColor[4] = { 0.176f, 0.196f, 0.667f, 0.0f };
ID3D11RenderTargetView* pRTV = DXUTGetD3D11RenderTargetView();
ID3D11DepthStencilView* pDSV = DXUTGetD3D11DepthStencilView();
pd3dImmediateContext->ClearRenderTargetView( pRTV, ClearColor );
pd3dImmediateContext->ClearDepthStencilView( pDSV, D3D11_CLEAR_DEPTH, 1.0, 0 );
D3DXMATRIX mWorld = *g_Camera.GetWorldMatrix();
D3DXMATRIX mView = *g_Camera.GetViewMatrix();
D3DXMATRIX mProj = *g_Camera.GetProjMatrix();
D3DXMATRIX mWorldViewProjection = mWorld * mView * mProj;
D3D11_MAPPED_SUBRESOURCE MappedResource;
V(pd3dImmediateContext->Map(g_pcbVSPerObject11, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource));
CB_VS_PER_OBJECT* pVSPerObject = (CB_VS_PER_OBJECT*)MappedResource.pData;
//Matrizen
D3DXMatrixTranspose(&pVSPerObject->m_mWorldViewProjection, &mWorldViewProjection);
D3DXMatrixTranspose(&pVSPerObject->m_mWorld, &mWorld);
//Material
pVSPerObject->m_MaterialAmbientColor = D3DXVECTOR4(0.3f, 0.3f, 0.3f, 1.0f);
pVSPerObject->m_MaterialDiffuseColor = D3DXVECTOR4(0.7f, 0.7f, 0.7f, 1.0f);
pd3dImmediateContext->Unmap(g_pcbVSPerObject11, 0);
//Beleuchtung
pd3dImmediateContext->Map(g_pcbVSPerFrame11, 0, D3D11_MAP_WRITE_DISCARD, 0, &MappedResource);
CB_VS_PER_FRAME* pVSPerFrame = (CB_VS_PER_FRAME*)MappedResource.pData;
pVSPerFrame->m_vLightDir = D3DXVECTOR3(0, 0.707f, -0.707f);
pVSPerFrame->m_LightDiffuse = D3DXVECTOR4(1.f, 1.f, 1.f, 1.f);
pd3dImmediateContext->Unmap(g_pcbVSPerFrame11, 0);
pd3dImmediateContext->VSSetConstantBuffers(0, 1, &g_pcbVSPerObject11);
pd3dImmediateContext->VSSetConstantBuffers(1, 1, &g_pcbVSPerFrame11);
pd3dImmediateContext->VSSetShader(g_pVertexShader11, NULL, 0);
pd3dImmediateContext->PSSetShader(g_pPixelShader11, NULL, 0);
pd3dImmediateContext->PSSetSamplers(0, 1, &g_pSamLinear);
ID3D11ShaderResourceView* aRViews[1] = {g_pRV};
pd3dImmediateContext->PSSetShaderResources(0, 1, aRViews);
pd3dImmediateContext->RSSetState(g_pRasterState);
// Inputlayout setzen
pd3dImmediateContext->IASetInputLayout( g_pLayout11 );
//Primitve topology setzen
pd3dImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_LINELIST );
// Rendern
pd3dImmediateContext->DrawIndexed(numIndices, 0, 0);
|