sebban

Untitled

Apr 18th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     //Fill the vertex input layout description
  3.     polygonLayout[0].SemanticName = "POSITION";
  4.     polygonLayout[0].SemanticIndex = 0;
  5.     polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
  6.     polygonLayout[0].InputSlot = 0;
  7.     polygonLayout[0].AlignedByteOffset = 0;
  8.     polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
  9.     polygonLayout[0].InstanceDataStepRate = 0;
  10.  
  11.     polygonLayout[1].SemanticName = "TEXCOORD";
  12.     polygonLayout[1].SemanticIndex = 0;
  13.     polygonLayout[1].Format = DXGI_FORMAT_R32G32_FLOAT;
  14.     polygonLayout[1].InputSlot = 0;
  15.     polygonLayout[1].AlignedByteOffset = 12;
  16.     polygonLayout[1].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
  17.     polygonLayout[1].InstanceDataStepRate = 0;
  18.  
  19.     //Get the number of elements in the layout
  20.     numElements = sizeof(polygonLayout) / sizeof(polygonLayout[0]);
  21.  
  22.     //Create the vertex input layout.
  23.     hresult = device->CreateInputLayout(polygonLayout, numElements, vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), &this->layout);
  24.     if (FAILED(hresult)) {
  25.         MessageBox(*hwnd, L"device->CreateInputLayout", L"Error", MB_OK);
  26.         return false;
  27.     }
  28.  
  29. //screen quad for deferred rendering
  30. //Calculate the screen coordinates of the left side of the window
  31.     left = (float)((screenWidth / 2) * -1);
  32.  
  33.     //Calculate the screen coordinates of the right side of the window
  34.     right = left + (float)screenWidth;
  35.  
  36.     //Calculate the screen coordinates of the top of the window
  37.     top = (float)(screenHeight / 2);
  38.  
  39.     //Calculate the screen coordinates of the bottom of the window
  40.     bottom = top - (float)screenHeight;
  41.  
  42.     //Load the vertex array with data
  43.     //First triangle
  44.     vertices[0].position = DirectX::XMFLOAT3(left, top, 0.0f);  //Top left
  45.     vertices[0].texture = DirectX::XMFLOAT2(0.0f, 0.0f);
  46.  
  47.     vertices[1].position = DirectX::XMFLOAT3(right, bottom, 0.0f);  //Bottom right
  48.     vertices[1].texture = DirectX::XMFLOAT2(1.0f, 1.0f);
  49.  
  50.     vertices[2].position = DirectX::XMFLOAT3(left, bottom, 0.0f);  //Bottom left
  51.     vertices[2].texture = DirectX::XMFLOAT2(0.0f, 1.0f);
  52.  
  53.     //Second triangle
  54.     vertices[3].position = DirectX::XMFLOAT3(left, top, 0.0f);  //Top left
  55.     vertices[3].texture = DirectX::XMFLOAT2(0.0f, 0.0f);
  56.  
  57.     vertices[4].position = DirectX::XMFLOAT3(right, top, 0.0f);  //Top right
  58.     vertices[4].texture = DirectX::XMFLOAT2(1.0f, 0.0f);
  59.  
  60.     vertices[5].position = DirectX::XMFLOAT3(right, bottom, 0.0f);  //Bottom right
  61.     vertices[5].texture = DirectX::XMFLOAT2(1.0f, 1.0f);
Advertisement
Add Comment
Please, Sign In to add comment