Jump to content
  • Advertisement
Sign in to follow this  
3DModelerMan

Can't get a simple cube to display

This topic is 2445 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;

Share this post


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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!