Jump to content

  • Log In with Google      Sign In   
  • Create Account


Can't get a simple cube to display


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 3DModelerMan   Members   -  Reputation: 921

Like
0Likes
Like

Posted 05 April 2012 - 03:24 PM

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;


Sponsor:

#2 Asesh   Members   -  Reputation: 268

Like
0Likes
Like

Posted 06 April 2012 - 09:20 AM

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

#3 3DModelerMan   Members   -  Reputation: 921

Like
0Likes
Like

Posted 06 April 2012 - 07:23 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS