1
votes

In an attempt to get a texture on a simple rectangle, I get an odd issue. Only the last column of pixels in the texture are seemingly used. http://i.imgur.com/40EoI.png <- The result being the black and white rectangle at the top there.

I've trudged the depths of already asked questions and journeyed the perilous underbelly of Google to no avail. I've compared my code to the tutorial I'd based it off (which, coincidentally, works with my chosen texture) yet still am puzzled. I was thinking it could be the input layout, perhaps the offsets?

D3D11_INPUT_ELEMENT_DESC ied[] =
{
    {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
    {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},        
    {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0},
};

dev->CreateInputLayout(ied, 3, VS->GetBufferPointer(), VS->GetBufferSize(), &pLayout);
devcon->IASetInputLayout(pLayout);

If not this, then theres a chance it could be the CreateShaderResourceFromViewFile:

 D3DX11CreateShaderResourceViewFromFile(dev,        // the Direct3D device
                                   L"Ptitle.png",    // load Wood.png in the local folder
                                   NULL,           // no additional information
                                   NULL,           // no multithreading
                                   &Ttitle,      // address of the shader-resource-view
                                   NULL);          // no multithreading

Also, just for good measure - although I'm certain it's fine, here are the vertices and their respective texture coordinates

        // Title
    {-200.0f, 100.0f, 0.0f, D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), 0.0f, 1.0f},//13 BOTTOM LEFT
    {-200.0f, 200.0f, 0.0f, D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), 0.0f, 0.0f},//14 TOP LEFT
    {200.0f, 100.0f, 0.0f, D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), 1.0f, 1.0f},//15 BOTTOM RIGHT
    {200.0f, 200.0f, 0.0f, D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f), 1.0f, 0.0f},//16 TOP RIGHT

I have a feeling I'll be kicking myself. Many thanks for any help I may receive, as well as apologies in case I'm still being too vague.

1

1 Answers

0
votes

Seems you input layout is wrong:

D3D11_INPUT_ELEMENT_DESC ied[] =
{
    {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
    {"COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},        
    {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0},
};

For TEXCOORD replace 24 by 28, since color is 16 in size.