Sign in to follow this  
AlzPatz

Where is my triangle? Issue moving to Directx 11 and Metro

Recommended Posts

AlzPatz    162
Hi. After playing about in directx and metro, I've hit a wall that either I'm being the most useless n00b on the planet or things do not work quite the same as earlier directx. very simply, im trying to render a triangle straight to "normalised / homogenous" or whatever you call it space - using the world's most basic shaders. To make sure that my initialisation code wasn't screwed up, I've transplanted the code into the direct 3D app template and still it does not show. if anyone could help work out why my triangle is not showing, would be appreciated. there must be something easy I've missed. To note this code tries to draw two triangles, filling the screen, one clockwise winding and one anti-clockwise, a test in case my winding was wrong. (Why can't I hit enter on this forum for a new line lol??). Anyway, first I hijack the cuberenders create device resources code
[source lang="cpp"]void CubeRenderer::CreateDeviceResources()
{
 Direct3DBase::CreateDeviceResources();

 VertexPos vertices[] =
 {
  DirectX::XMFLOAT3(0.0f, 0.0f, 0.2f),
  DirectX::XMFLOAT3(1.0f, 0.0f, 0.2f),
  DirectX::XMFLOAT3(0.0f, 1.0f, 0.2f),
  DirectX::XMFLOAT3(0.0f, 1.0f, 0.2f),
  DirectX::XMFLOAT3(1.0f, 1.0f, 0.2f),
  DirectX::XMFLOAT3(1.0f, 0.0f, 0.2f),
 };
 D3D11_BUFFER_DESC TT_vertexDesc;
 ZeroMemory(&TT_vertexDesc, sizeof(TT_vertexDesc));
 TT_vertexDesc.Usage = D3D11_USAGE_DEFAULT;
 TT_vertexDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
 TT_vertexDesc.ByteWidth = sizeof(VertexPos) * 6;
 D3D11_SUBRESOURCE_DATA sResource;
 ZeroMemory(&sResource, sizeof(sResource));
 sResource.pSysMem = vertices;
 DX::ThrowIfFailed(m_d3dDevice->CreateBuffer(&TT_vertexDesc, &sResource, &TT_vertexBuffer));

 //Load the Shaders
 //Load the vertex shader (the build configuration / properties of the shader file deals with compile to .cso)
 auto task_LoadTTVS = DX::ReadDataAsync("VS_TriangleTest.cso");
 auto task_CreateTTVS = task_LoadTTVS.then([this](DX::ByteArray ba)
 {
  //This async load / helper classes are taken straight from the template. Why not.
  auto bc_VS = ba.data;
  DX::ThrowIfFailed(m_d3dDevice->CreateVertexShader(bc_VS->Data, bc_VS->Length, nullptr, &VS_TT));

  //Create Input Layout Description
  D3D11_INPUT_ELEMENT_DESC vertexLayout[] =
  {
   {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}
  };

  //Create the Input Layout
  DX::ThrowIfFailed(m_d3dDevice->CreateInputLayout(vertexLayout, ARRAYSIZE(vertexLayout), bc_VS->Data, bc_VS->Length, &TT_inputLayout));
 });

 //Load the pixel shader (again, the build and configuration properties of the shader file deal with compilation
 auto task_LoadTTPS = DX::ReadDataAsync("PS_TriangleTest.cso");
 auto task_CreateTTPS = task_LoadTTPS.then([this](DX::ByteArray ba)
 {
  auto bc_PS = ba.data;
  DX::ThrowIfFailed(m_d3dDevice->CreatePixelShader(bc_PS->Data, bc_PS->Length, nullptr, &PS_TT));
  m_loadingComplete = true; //dont really work properly as earlier shaders might take longer but meh won't be the issue here
 });

}[/source] THen I hijack the rendering bit. FYI I've confirmed that all the context calls are run[CODE]
const float Red[] = { 1.0f, 0.0f, 0.0f, 1.0f };
m_d3dContext->ClearRenderTargetView(m_renderTargetView.Get(), Red);
//Clear the depth stenicl view
m_d3dContext->ClearDepthStencilView(m_depthStencilView.Get(), D3D11_CLEAR_DEPTH, 1.0f, 0);
if (!m_loadingComplete)
return;
m_d3dContext->IASetInputLayout(TT_inputLayout.Get());
m_d3dContext->OMSetRenderTargets(1, m_renderTargetView.GetAddressOf(), m_depthStencilView.Get());
//Test triangle following some book code to check that everything is working
UINT str = sizeof(VertexPos);
UINT oset = 0;
m_d3dContext->IASetVertexBuffers(0, 1, &TT_vertexBuffer, &str, &oset);
m_d3dContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
m_d3dContext->VSSetShader(VS_TT.Get(), 0, 0);
m_d3dContext->PSSetShader(PS_TT.Get(), 0, 0);
m_d3dContext->Draw(6, 0);
[/CODE] then the world's simplest shaders (even desperately rewritten to copy ones on the net using a structure, obviously this pass through could just be main function only returning float4...[CODE]
struct VOut
{
float4 position : SV_POSITION;
};
VOut main( float4 pos : POSITION )
{
VOut output;
output.position = pos;
return output;
}
[/CODE] and the pixel pencil...[CODE]
float4 main(float4 position : SV_POSITION) : SV_TARGET
{
return float4 (0.0f, 1.0f, 1.0f, 1.0f);
}
[/CODE] and wahay, I always get a red screen. ive tried making the triangles screen sized in case its not -1,-1 to 1,1 but still no joy. any help for a tired n00b? thanks!!

Share this post


Link to post
Share on other sites
papulko    1418
I'm not sure if this will help but it seems to me your input layout defines vertex position as a 3 element vector (DXGI_FORMAT_R32G32B32_FLOAT), while your vertex shader parameter is expecting a 4 element one (float4 pos). I'd suggest you try and change the vertex shader parameter to float3 and see if that helps!

Share this post


Link to post
Share on other sites
AlzPatz    162
Hi, thanks so much for your suggestion. My shaders would not compile with a float3 input, but I changed the code to use XMFLOAT4's instead. unfortunately no luck. Im getting really depressed now. Ive tried this in windows 7 dx11 c++, metro c++/cx DX 11 and with sharp DX in c#, always the same. I even followed the code from book "beginning game programming in directx11 that does this, and it didn't work, except their demo compiled and it worked!). seriously cannot for the life of me work this out. it's infuriating, this was supposed to be small step just to check things are working... :(

Share this post


Link to post
Share on other sites
papulko    1418
Hey again, Don't forget to change your input layout to DXGI_FORMAT_R32G32B32A32_FLOAT (and your vertex struct position element if you haven't already) in order for it to work with XMFLOAT4,

If you wish to stick with XMFLOAT3, I'm guessing your shader won't compile because the 2nd row in the main method of your vertex shader has to be changed from ("output.position = pos") to "output.position = float4(pos, 1.0f)".

Share this post


Link to post
Share on other sites
AlzPatz    162
Sorry I wasn't very clear. I did change the Input Layout format to the 4 component format. and I also changed the vertex shader to output a float4 from a float3 (pos, 1.0f). Ill double check again tonight anyhow.

Share this post


Link to post
Share on other sites
AlzPatz    162
Thanks Papulko - you are right, I do not set one. However, Im pretty certain that DX11 sets up a default rasteriser that CULLS back and FILLS_SOLID. Ill add it later, but I dont hold too much hope this will work. :(

Share this post


Link to post
Share on other sites
L. Spiro    25638
Change it to disable culling or reverse the winding of your triangles.

Use PIX to confirm the positions of your vertices in screen space after the vertex shader is run.
Use PIX to perform general debugging of the scene and verification of the state at the time of rendering.
Use DirectX Debug Mode and watch the console for important messages on errors and warnings.


L. Spiro

Share this post


Link to post
Share on other sites
kauna    2922
[quote name='papulko' timestamp='1349039953' post='4985491']
I'm not sure if this will help but it seems to me your input layout defines vertex position as a 3 element vector (DXGI_FORMAT_R32G32B32_FLOAT), while your vertex shader parameter is expecting a 4 element one (float4 pos). I'd suggest you try and change the vertex shader parameter to float3 and see if that helps!
[/quote]

Using DXGI_FORMAT_R32G32B32_FLOAT is perfectly valid. The vertex shader will receive the value as [x,y,z,1.0f] automatically.

Cheers! Edited by kauna

Share this post


Link to post
Share on other sites
AlzPatz    162
[i]so..turns out PIX has been replaced by Graphics Diagnostics integrated into Visual Studio 2012. Hurray I thought, until it turns out that it's only available on versions higher than 'express', so that's a £500+ purchase to use graphics debugging on Visual Studio 2012. soul destroying. Not sure anyway around this. I cant download any trial versions etc as I am running RC and some version of windows 8, it's all gone to sh1t until the real version of windows 8 is released.[/i]

Share this post


Link to post
Share on other sites
AlzPatz    162
i would also add that I have no problems doing this simple drawing in DirectX 11 and C++ in windows 7 / win 32. Im at a loss, completely.

Share this post


Link to post
Share on other sites
col_anderson    109
The problem you are describing sound like the exact same problem when I try to render a cube.

Inspecting the problem with the Graphics Diagnosis Tool tells me that the Pixel Shader has not participate in the graphics pipeline process, in my case, without any obvious reason.

I have double checked it, but it was loaded properly and set correctly in the device context.
This leaves me clueless.

Perhaps the additional diag info helps in your case as well, AlzPatz. (see attachment)

And this is the corresponding source code

Cube.cpp:
[Code]
#include "Cube.h"
#include "GlobalDefines.h"
#include "Direct3dUtils.h"
struct SChangesEveryFrame{
XMMATRIX mWorld;
};
Cube::Cube(void)
:isInitialized(false),
vertexBuffer(NULL),
indexBuffer(NULL),
cbChangesEveryFrame(NULL),
vertexShaderFile(L"SimpleVertexShader"),
pixelShaderFile(L"SimplePixelShader"),
vertexShader(NULL),
pixelShader(NULL),
inputLayout(NULL)
{
}

Cube::~Cube(void)
{
SAFE_RELEASE(inputLayout);
SAFE_RELEASE(pixelShader);
SAFE_RELEASE(vertexShader);
SAFE_RELEASE(cbChangesEveryFrame);
SAFE_RELEASE(vertexBuffer);
SAFE_RELEASE(indexBuffer);
}
void Cube::Render()
{
if(isInitialized){
SChangesEveryFrame sChangesEveryFrame;
//using XMMATRIX causes runtime error - better use XMFloat4x4
//http://www.gamedev.net/topic/627033-xmmatrixtranspose-crashes/
//http://xboxforums.create.msdn.com/forums/t/84299.aspx
sChangesEveryFrame.mWorld = XMMatrixTranspose(XMLoadFloat4x4(&worldMatrix));

UINT stride =sizeof(SimpleColorVertex) ;
UINT offset = 0;

immediateContext->IASetInputLayout(inputLayout);
immediateContext->IASetVertexBuffers(0,1,&vertexBuffer,&stride,&offset);
immediateContext->IASetIndexBuffer(indexBuffer,DXGI_FORMAT_R16_UINT,0);
immediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

immediateContext->UpdateSubresource(cbChangesEveryFrame,0,NULL,&sChangesEveryFrame,0,0);
immediateContext->VSSetConstantBuffers(2,1,&cbChangesEveryFrame);
//immediateContext->PSSetConstantBuffers(2,1,&cbChangesEveryFrame);
immediateContext->VSSetShader(vertexShader, NULL,0);
immediateContext->PSSetShader(pixelShader, NULL,0);
immediateContext->DrawIndexed( 36, 0, 0 );
}
}
void Cube::Initialize(ID3D11Device* device, ID3D11DeviceContext* immediateContext)
{
this->device = device;
this->immediateContext = immediateContext;

SimpleColorVertex vertices[] =
{
{ XMFLOAT3( -1.0f, 1.0f, -1.0f ), XMFLOAT4( 0.0f, 0.0f, 1.0f, 1.0f ) },
{ XMFLOAT3( 1.0f, 1.0f, -1.0f ), XMFLOAT4( 0.0f, 1.0f, 0.0f, 1.0f ) },
{ XMFLOAT3( 1.0f, 1.0f, 1.0f ), XMFLOAT4( 0.0f, 1.0f, 1.0f, 1.0f ) },
{ XMFLOAT3( -1.0f, 1.0f, 1.0f ), XMFLOAT4( 1.0f, 0.0f, 0.0f, 1.0f ) },
{ XMFLOAT3( -1.0f, -1.0f, -1.0f ), XMFLOAT4( 1.0f, 0.0f, 1.0f, 1.0f ) },
{ XMFLOAT3( 1.0f, -1.0f, -1.0f ), XMFLOAT4( 1.0f, 1.0f, 0.0f, 1.0f ) },
{ XMFLOAT3( 1.0f, -1.0f, 1.0f ), XMFLOAT4( 1.0f, 1.0f, 1.0f, 1.0f ) },
{ XMFLOAT3( -1.0f, -1.0f, 1.0f ), XMFLOAT4( 0.0f, 0.0f, 0.0f, 1.0f ) }
};
WORD indices[] =
{
3,1,0,
2,1,3,

0,5,4,
1,5,0,

3,4,7,
0,4,3,

1,6,5,
2,6,1,

2,7,6,
3,7,2,

6,4,5,
7,4,6,
};
HRESULT hr;
vertexBuffer = Direct3dUtils::CreateBuffer(device,D3D11_BIND_VERTEX_BUFFER,sizeof(SimpleColorVertex) * ARRAYSIZE(vertices),vertices,hr);
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"create vertexbuffer");
return;
}
indexBuffer = Direct3dUtils::CreateBuffer(device,D3D11_BIND_INDEX_BUFFER,sizeof(WORD) * ARRAYSIZE(indices),indices,hr);
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"create indexbuffer");
return;
}
cbChangesEveryFrame = Direct3dUtils::CreateBuffer(device,D3D11_BIND_CONSTANT_BUFFER,sizeof(SChangesEveryFrame),NULL,hr);
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"create cbChangesEveryFrame");
return;
}
D3D11_INPUT_ELEMENT_DESC layoutDesciption[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT,0 ,0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR" , 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 }
};
Direct3dUtils::LoadVertexShader(device, vertexShaderFile, layoutDesciption,ARRAYSIZE(layoutDesciption), &vertexShader, &inputLayout, hr);
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"LoadVertexShader");
return;
}
Direct3dUtils::LoadPixelShader(device, pixelShaderFile,&pixelShader, hr);
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"LoadPixelShader");
return;
}
XMStoreFloat4x4(&worldMatrix,XMMatrixIdentity());
isInitialized = true;
}
[/code]

Direct3d.cpp
[code]
#include "Direct3d.h"
struct SNeverChanges{
XMMATRIX mView;
};
struct SChangesOnResize{
XMMATRIX mProjection;
};
Direct3d::Direct3d(HWND hwnd)
{
// TODO set up configuration class to determine proper system configuration, for now we go with the dev system requirments

IDXGIAdapter* adapter = NULL;
D3D_DRIVER_TYPE driverType = D3D_DRIVER_TYPE_HARDWARE;
// TODO allow multiple display modes, including full-screen resolutions - for now we go with windowed 1024x768x60hz

int resolutionWidth = WINDOWWITDH;
int resolutionHeight = WINDOWHEIGHT;
int refreshrate = 60;
bool windowed = true;
int multisamplingCount = 1;
int mulitsamplingQuality = 0;
UINT createDeviceFlags = 0;
#ifdef _DEBUG
createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif

DXGI_SWAP_CHAIN_DESC sd;
ZeroMemory( &sd, sizeof(sd) );
sd.BufferCount = 1;
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
sd.BufferDesc.RefreshRate.Numerator = refreshrate;
sd.BufferDesc.RefreshRate.Denominator = 1;
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
sd.BufferDesc.Width = resolutionWidth;
sd.BufferDesc.Height = resolutionHeight;
sd.Windowed = windowed;
sd.SampleDesc.Count = multisamplingCount;
sd.SampleDesc.Quality = mulitsamplingQuality;
sd.OutputWindow = hwnd;
D3D_FEATURE_LEVEL featureLevels[] =
{
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0
};
int numberOfFeatureLevels = ARRAYSIZE(featureLevels);
HRESULT hr;
hr = D3D11CreateDeviceAndSwapChain(adapter, driverType, NULL, createDeviceFlags, featureLevels, numberOfFeatureLevels, D3D11_SDK_VERSION, &sd, &swapChain, &device, NULL, &immediateContext );
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult( hr, L"CreateDevice&SwapChain" );
return;
}
hr = swapChain->GetBuffer( 0, __uuidof( ID3D11Texture2D ), (void**) &backBuffer );
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult( hr, L"SwapChain-GetBuffer" );
return;
}

hr = device->CreateRenderTargetView(backBuffer, NULL, &renderTargetView);
backBuffer->Release();
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult( hr, L"CreateRenderTargetView" );
return;
}

D3D11_TEXTURE2D_DESC stencilDescription;
ZeroMemory(&stencilDescription,sizeof(stencilDescription));
stencilDescription.Usage = D3D11_USAGE_DEFAULT;
stencilDescription.Width = resolutionWidth;
stencilDescription.Height = resolutionHeight;
stencilDescription.MipLevels = 1;
stencilDescription.ArraySize = 1;
stencilDescription.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
stencilDescription.SampleDesc.Count = 1;
stencilDescription.SampleDesc.Quality = 0;
stencilDescription.BindFlags = D3D11_BIND_DEPTH_STENCIL;
stencilDescription.CPUAccessFlags = 0;
stencilDescription.MiscFlags = 0;
hr = device->CreateTexture2D(&stencilDescription,NULL, &depthStencilBuffer);
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult( hr, L"CreateDepthStencilBuffer" );
return;
}

D3D11_DEPTH_STENCIL_VIEW_DESC viewDescription;
ZeroMemory(&viewDescription,sizeof(viewDescription));
viewDescription.Format = stencilDescription.Format;
viewDescription.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
hr = device->CreateDepthStencilView(depthStencilBuffer,&viewDescription,&depthStencilView);
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult( hr, L"CreateDepthStencilView" );
return;
}

immediateContext->OMSetRenderTargets( 1, &renderTargetView, depthStencilView);
D3D11_VIEWPORT vp;
vp.Width = float(resolutionWidth);
vp.Height = float(resolutionHeight);
vp.MinDepth = 0.0f;
vp.MaxDepth = 1.0f;
vp.TopLeftX = 0;
vp.TopLeftY = 0;
immediateContext->RSSetViewports( 1, &vp );
XMVECTOR eye = XMVectorSet(0.0f, 3.0f, -2.0f, 0.0f);
XMVECTOR at = XMVectorSet(0.0f,1.0f,1.0f,0.0f);
XMVECTOR up = XMVectorSet(0.0f,1.0f,1.0f,0.0f);
XMStoreFloat4x4(&ViewMatrix,XMMatrixLookAtLH(eye,at,up));
SNeverChanges sNeverChanges;
sNeverChanges.mView = XMLoadFloat4x4(&ViewMatrix);
cbNeverChanges = Direct3dUtils::CreateBuffer(device,D3D11_BIND_CONSTANT_BUFFER,sizeof(SNeverChanges),NULL,hr);
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"create cbNeverChanges");
return;
}
immediateContext->UpdateSubresource( cbNeverChanges, 0, NULL, &sNeverChanges, 0, 0 );
XMStoreFloat4x4(&ProjectionMatrix,XMMatrixPerspectiveFovLH(XM_PIDIV2,resolutionWidth/(float)resolutionHeight,0.01f,1.0f));
SChangesOnResize sChangesOnResize;
sChangesOnResize.mProjection = XMLoadFloat4x4(&ProjectionMatrix);
cbChangesOnResize = Direct3dUtils::CreateBuffer(device,D3D11_BIND_CONSTANT_BUFFER,sizeof(SChangesOnResize),NULL,hr);
if (FAILED(hr)){
Direct3dUtils::ShowMessageBoxOnBadResult(hr,L"create cbNeverChanges");
return;
}
immediateContext->UpdateSubresource( cbChangesOnResize, 0, NULL, &sChangesOnResize, 0, 0 );
}
Direct3d::~Direct3d(void)
{
if (immediateContext) immediateContext->ClearState();
SAFE_RELEASE(cbNeverChanges);
SAFE_RELEASE(cbChangesOnResize);
SAFE_RELEASE(depthStencilView);
SAFE_RELEASE(renderTargetView);
SAFE_RELEASE(backBuffer);
SAFE_RELEASE(immediateContext);
SAFE_RELEASE(swapChain);
SAFE_RELEASE(device);
}
void Direct3d::Render()
{
float color[] = { 0.0f, 0.2f, 0.0f, 1.0f };
immediateContext->ClearRenderTargetView(renderTargetView, color);
immediateContext->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0);
immediateContext->VSSetConstantBuffers(1,1,&cbChangesOnResize);
immediateContext->VSSetConstantBuffers(0,1,&cbNeverChanges);
renderObjects();
swapChain->Present( 0, 0 );
}
void Direct3d::Add(Renderable* object)
{
object->Initialize(device,immediateContext);
objects.insert(objects.end(),object);
}

void Direct3d::renderObjects()
{
for (std::vector<Renderable*>::iterator iter = objects.begin(); iter != objects.end(); iter++)
(*iter)->Render();
}
[/code]

My shaders are pretty basic as well:

definitions.fx:
[code]
cbuffer cbNeverChanges : register(b0) {
matrix View;
};
cbuffer cbChangesOnResize: register(b1) {
matrix Projection;
};
cbuffer cbChangesEveryFrame : register (b2) {
matrix World;
};
struct VS_INPUT{
float4 Pos : POSITION;
float4 Color : COLOR0;
};
struct PS_INPUT{
float4 Pos : SV_POSITION;
float4 Color : COLOR0;
};
[/code]

SimplePixelShader.hlsl:
[code]
#include "definitions.fx"
float4 main(PS_INPUT input) : SV_Target
{
return input.Color;
}
[/code]
SimpleVertexShader.hlsl:
[code]
#include "definitions.fx"

PS_INPUT main( VS_INPUT input )
{
PS_INPUT output = (PS_INPUT)0;
output.Pos = mul(input.Pos,World);
output.Pos = mul(output.Pos, View);
output.Pos = mul(output.Pos, Projection);
output.Color = input.Color;
return output;
}
[/code] Edited by col_anderson

Share this post


Link to post
Share on other sites
AlzPatz    162
Hi col_andersen.
Same as me, I do not see anything obvious in the code. You are using the Jun2010 SDK? So no targeting metro?
I could be getting the same effect. Any chance I could send you a simple solution zip file for you to run through the diagnostics to check if the same?

Share this post


Link to post
Share on other sites
col_anderson    109
I solved the issue for me, but you seem to use untransformed screen coordinates.

The root cause with my code were the Projection and View matrices.

While I stored the world matrix correctly:
[Code]sChangesEveryFrame.mWorld = XMMatrixTranspose(XMLoadFloat4x4(&worldMatrix));[/Code]

I did not do it with the other two:
[CODE]sNeverChanges.mView = XMLoadFloat4x4(&ViewMatrix);[/CODE]
and
[CODE]sChangesOnResize.mProjection = XMLoadFloat4x4(&ProjectionMatrix);[/CODE]

The shader has to use a transposed version of the matrices.

AlzPatz - I will get in touch with you via PM. Edited by col_anderson

Share this post


Link to post
Share on other sites
AlzPatz    162
Hi - no i do not. I didn't think I needed to if my vertices were already in "Screen Space", or Homogenous clip space, or whatever (-1,-1, z to 1, 1,z). maybe i got wrong end of the stick.

Share this post


Link to post
Share on other sites
col_anderson    109
Hi AlzPatz.
I received your code, however I currently have no win8 dev environment therefore no chance to compile your code.
The code and the shaders seem fine, but the devil is in the details as usual.

To diagnose my problem I switched the cull mode to D3D11_CULL_NONE so the rasterizer would render everything that should be on screen.
in native c++ it would look somethin like this:
[source]
D3D11_RASTERIZER_DESC rd;
ZeroMemory(&rd, sizeof(rd));
rd.CullMode = D3D11_CULL_NONE;
rd.FrontCounterClockwise = false;
rd.FillMode = D3D11_FILL_SOLID;

device->CreateRasterizerState(&rd, &rasterizerState);
immediateContext->RSSetState(rasterizerState);
[/source]

Also try to disable the depthstencilbuffer as you don't need it anyway when you draw screen coordinates directly, by not setting in the OMSetRenderTargets call:

[source]
//Set the Render Context
d3dContext->OMSetRenderTargets(1, renderTargetView.GetAddressOf(), nullptr)
[/source]

You should also have a look at the DX11 MSDN tutorial (especially No 2), if you have not already.
[url="http://code.msdn.microsoft.com/Direct3D-Tutorial-Win32-829979ef?SRC=VSIDE"]http://code.msdn.mic...979ef?SRC=VSIDE[/url]

I hoped I could be more helpful.

Let me know if that brought you forward.

C. Edited by col_anderson

Share this post


Link to post
Share on other sites
AlzPatz    162
Thanks, I had look at the disabling the depth stencil before and did play with a different rasterizer (the code i sent did not set one, just use default)(. but will retry. thanks for looking anyway! ill report back

Share this post


Link to post
Share on other sites
AlzPatz    162
Is anyone willing to receive a C++ Metro App to run, either with diagnostics or just to have a browse and see what simple mistake i am making?

Share this post


Link to post
Share on other sites
AlzPatz    162
OK - I have this weekend spare for programming and don't want to spend it stuck on this issue. I have solution ready to send. It is a Metro App. Edited by AlzPatz

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this