Can't get a simple cube to display

Started by
1 comment, last by 3DModelerMan 12 years ago
I'm trying to get a cube displaying. I generate my constant buffer with all the matrices here:


//Setup the constant buffer.
m_matrices.m_world.identity();
core::Vector3 Eye(5.0f, 1.0f, -15.0f);
core::Vector3 At(0.0f, 0.0f, 0.0f);
core::Vector3 Up(0.0f, 1.0f, 0.0f);
m_matrices.m_view.buildViewMatrixLH(Eye, At, Up);
m_matrices.m_projection.buildProjectionMatrixLH(XM_PIDIV2, window->getScreenSize().width/window->getScreenSize().height, 0.1f, 100.0f);
D3D11_BUFFER_DESC bd;
ZeroMemory( &bd, sizeof(bd) );
bd.Usage = D3D11_USAGE_DEFAULT;
bd.ByteWidth = sizeof(SMatrixBuffer);
bd.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
bd.CPUAccessFlags = 0;
if( FAILED(m_d3dDevice->CreateBuffer( &bd, NULL, &m_constantBuffer ) ) )
core::DebugUtils::out << "Error: Failed to create constant buffer.\n";
setTransform(m_matrices.m_world, m_matrices.m_view, m_matrices.m_projection);


setTransform just looks like this:


world.getTransposed(m_matrices.m_world);
view.getTransposed(m_matrices.m_view);
projection.getTransposed(m_matrices.m_projection);
m_deviceContext->UpdateSubresource(m_constantBuffer, 0, NULL, &m_matrices, 0, 0);
m_deviceContext->VSSetConstantBuffers(0, 1, &m_constantBuffer);


And then I draw everything like normal. The problem is, I get only a blank blue screen. I know that the matrices must be correct though. I can see the vertices correctly transformed and position in PIX in the "post VS" section. They just don't show up in the viewport at all. Here's my vertex shader:


PSInput output;
output.Pos = mul( input.Pos, World );
output.Pos = mul( output.Pos, View );
output.Pos = mul( output.Pos, Projection );

//output.Pos = input.Pos;

output.Texcoord = input.Texcoord;

return output;
Advertisement
Looking at your posted code, seems like there's nothing wrong not unless there's something wrong in your wrapper. Where's your pixel shader code? May be there's something wrong in pixel shader
Finally figured it out. It was because I was using the same structure that I uploaded the matrices to the GPU with to store them on the C++ side. I don't know why that did it, but that's what worked.

This topic is closed to new replies.

Advertisement