Sign in to follow this  
3DModelerMan

Can't get a simple cube to display

Recommended Posts

I'm trying to get a cube displaying. I generate my constant buffer with all the matrices here:

[CODE]
//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);
[/CODE]

setTransform just looks like this:

[CODE]
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);
[/CODE]

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:

[CODE]
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;
[/CODE]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

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