0

This is what happens in DirectX:

What it should do is display 5 of those birds. It only does one (the last one) and also not correctly.

And this is how it really should look like (same buffers etc., but done in openGL):

So any idea what could cause the problem?

My calls are:

Initialize:

this->device->QueryInterface(__uuidof(IDXGIDevice), (LPVOID*)&dxgiDevice);

dxgiDevice->GetAdapter(&adapter);

adapter->GetParent(IID_PPV_ARGS(&factory));

ZeroMemory(&swapChainDescription, sizeof(swapChainDescription));
swapChainDescription.BufferDesc.Width = this->description.ResolutionWidth;
swapChainDescription.BufferDesc.Height = this->description.ResolutionHeight;
swapChainDescription.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
swapChainDescription.BufferDesc.RefreshRate.Numerator = 60;
swapChainDescription.BufferDesc.RefreshRate.Denominator = 1;
swapChainDescription.BufferDesc.Scaling = DXGI_MODE_SCALING_STRETCHED;
swapChainDescription.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_PROGRESSIVE;
swapChainDescription.SampleDesc.Count = 1;
swapChainDescription.SampleDesc.Quality = 0;
swapChainDescription.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
swapChainDescription.BufferCount = 1;
swapChainDescription.OutputWindow = this->hwnd;
swapChainDescription.Windowed = !this->window->GetDescription().Fullscreen;
swapChainDescription.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
swapChainDescription.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
factory->CreateSwapChain(this->device, &swapChainDescription, &this->swapChain);

this->swapChain->GetBuffer(0, __uuidof(ID3D10Texture2D), (LPVOID*)&backBuffer);

this->device->CreateRenderTargetView(backBuffer, NULL, &this->backBufferView);

backBuffer->Release();

ZeroMemory(&depthStencilDescription, sizeof(depthStencilDescription));
depthStencilDescription.Width = this->description.ResolutionWidth;
depthStencilDescription.Height = this->description.ResolutionHeight;
depthStencilDescription.MipLevels = 1;
depthStencilDescription.ArraySize = 1;
depthStencilDescription.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthStencilDescription.SampleDesc.Count = 1;
depthStencilDescription.SampleDesc.Quality = 0;
depthStencilDescription.Usage = D3D10_USAGE_DEFAULT;
depthStencilDescription.BindFlags = D3D10_BIND_DEPTH_STENCIL;
depthStencilDescription.CPUAccessFlags = 0;
depthStencilDescription.MiscFlags = 0;

this->device->CreateTexture2D(&depthStencilDescription, 0, &depthStencilBuffer);

this->device->CreateDepthStencilView(depthStencilBuffer, 0, &this->depthStencilBufferView);

depthStencilBuffer->Release();

viewPort.Width = this->description.ResolutionWidth;
viewPort.Height = this->description.ResolutionHeight;
viewPort.MinDepth = 0.0f;
viewPort.MaxDepth = 1.0f;
viewPort.TopLeftX = 0;
viewPort.TopLeftY = 0;

this->device->RSSetViewports(1, &viewPort);

D3D10_BLEND_DESC BlendState;
ZeroMemory(&BlendState, sizeof(D3D10_BLEND_DESC));
BlendState.AlphaToCoverageEnable = FALSE;
BlendState.BlendEnable[0] = TRUE;
BlendState.SrcBlend = D3D10_BLEND_SRC_ALPHA;
BlendState.DestBlend = D3D10_BLEND_INV_SRC_ALPHA;
BlendState.BlendOp = D3D10_BLEND_OP_ADD;
BlendState.SrcBlendAlpha = D3D10_BLEND_ZERO;
BlendState.DestBlendAlpha = D3D10_BLEND_ZERO;
BlendState.BlendOpAlpha = D3D10_BLEND_OP_ADD;
BlendState.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;

this->device->CreateBlendState(&BlendState, &this->blendState);

Each Frame (broken down to):

 this->device->OMSetBlendState(this->blendState, 0, 0xffffffff);
    this->device->OMSetRenderTargets(1, &this->backBufferView, this->depthStencilBufferView);
    this->device->ClearRenderTargetView(this->backBufferView, &Color.colors[0]);
    this->device->ClearDepthStencilView(this->depthStencilBufferView, D3D10_CLEAR_DEPTH | 
D3D10_CLEAR_STENCIL, 1.0f, 0);

in for loop (5 times):

   ID3D10Buffer* buff = (ID3D10Buffer*)buffer->GetData();

            UINT stride = buffer->GetStride();
            UINT offset = 0;

            this->device->IASetVertexBuffers(0, 1, &buff, &stride, &offset);

            ID3D10Buffer* buff = (ID3D10Buffer*)buffer->GetData();

            this->device->IASetIndexBuffer(buff, DXGI_FORMAT_R32_UINT, 0);

            this->device->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

            this->device->DrawIndexed(Indexes, 0, 0);

At the End

 this->swapChain->Present(0, 0);
PuRe
  • 179
  • 2
  • 13
  • Looks like triangle winding order. What happens if you disable backface culling? – Roger Rowland Dec 07 '14 at 10:13
  • And where are you drawing multiple birds? I only see a single draw call. I assume, you use a very basic shader? – Nico Schertler Dec 07 '14 at 10:15
  • I draw those in a for loop, just edited my post. If I disable backface culling nothing happens (I disable it using rasterDesc.CullMode = D3D10_CULL_NONE right?) – PuRe Dec 07 '14 at 10:58
  • Cutting Texture was because of my far and nearplane. Adjusted them and now it works fine. Only problem remaining is that DirectX only uses the last draw call. – PuRe Dec 07 '14 at 15:21
  • While I never used DirectX, shouldn't `swapChain->Present()` be called at the end of the frame? Which means, that it should be outside the loop, instead of being called after rendering each bird? – Reto Koradi Dec 07 '14 at 15:54
  • Oh just did not edit the post correctly. swapChain is only called at the end once each frame. – PuRe Dec 07 '14 at 15:58

1 Answers1

0

I got it fixed, here for others:

Vertices getting cut:

my near/far plane were to near to eachother. (they were 0.1f and 100.0f) Changed both values and now they work.

DirectX only drawing last call:

Had to apply material again for each model.

So doing

// Set coresponding input layout
this->device->IASetInputLayout(this->inputLayout);

// Apply specified pass of current technique
this->technique->GetPassByIndex(0)->Apply(0);
PuRe
  • 179
  • 2
  • 13