| 90 | } |
| 91 | |
| 92 | void Skybox::Initialize(ID3D11Device* device_) |
| 93 | { |
| 94 | device = device_; |
| 95 | |
| 96 | // Load the shaders |
| 97 | const std::wstring shaderPath = SampleFrameworkDir() + L"Shaders\\Skybox.hlsl"; |
| 98 | vertexShader = CompileVSFromFile(device, shaderPath.c_str(), "SkyboxVS", "vs_5_0"); |
| 99 | emPixelShader = CompilePSFromFile(device, shaderPath.c_str(), "SkyboxPS", "ps_5_0"); |
| 100 | simpleSkyPS = CompilePSFromFile(device, shaderPath.c_str(), "SimpleSkyPS", "ps_5_0"); |
| 101 | |
| 102 | // Create the input layout |
| 103 | D3D11_INPUT_ELEMENT_DESC layout[] = |
| 104 | { |
| 105 | { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 }, |
| 106 | }; |
| 107 | |
| 108 | ID3DBlob* byteCode = vertexShader->ByteCode; |
| 109 | DXCall(device->CreateInputLayout(layout, 1, byteCode->GetBufferPointer(), byteCode->GetBufferSize(), &inputLayout)); |
| 110 | |
| 111 | // Create and initialize the vertex and index buffers |
| 112 | Float3 verts[NumVertices] = |
| 113 | { |
| 114 | Float3(-1, 1, 1), |
| 115 | Float3(1, 1, 1), |
| 116 | Float3(1, -1, 1), |
| 117 | Float3(-1, -1, 1), |
| 118 | Float3(1, 1, -1), |
| 119 | Float3(-1, 1, -1), |
| 120 | Float3(-1, -1, -1), |
| 121 | Float3(1, -1,- 1), |
| 122 | }; |
| 123 | |
| 124 | D3D11_BUFFER_DESC desc; |
| 125 | desc.Usage = D3D11_USAGE_IMMUTABLE; |
| 126 | desc.ByteWidth = sizeof(verts); |
| 127 | desc.BindFlags = D3D11_BIND_VERTEX_BUFFER; |
| 128 | desc.CPUAccessFlags = 0; |
| 129 | desc.MiscFlags = 0; |
| 130 | D3D11_SUBRESOURCE_DATA initData; |
| 131 | initData.pSysMem = verts; |
| 132 | initData.SysMemPitch = 0; |
| 133 | initData.SysMemSlicePitch = 0; |
| 134 | DXCall(device->CreateBuffer(&desc, &initData, &vertexBuffer)); |
| 135 | |
| 136 | unsigned short indices[NumIndices] = |
| 137 | { |
| 138 | 0, 1, 2, 2, 3, 0, // Front |
| 139 | 1, 4, 7, 7, 2, 1, // Right |
| 140 | 4, 5, 6, 6, 7, 4, // Back |
| 141 | 5, 0, 3, 3, 6, 5, // Left |
| 142 | 5, 4, 1, 1, 0, 5, // Top |
| 143 | 3, 2, 7, 7, 6, 3 // Bottom |
| 144 | }; |
| 145 | |
| 146 | desc.Usage = D3D11_USAGE_IMMUTABLE; |
| 147 | desc.ByteWidth = sizeof(indices); |
| 148 | desc.BindFlags = D3D11_BIND_INDEX_BUFFER; |
| 149 | desc.CPUAccessFlags = 0; |
no test coverage detected