Sign in to follow this  
Caeous

Vertex Declaration failure

Recommended Posts

Hey everyone,

 

I'm trying to split my position and my color as two different arrays by using a declaration instead of FVF, however when I'm creating it, I'm getting a fail.

 

D3DVERTEXELEMENT9 posColour_vec[] =
{
    { 0, 0, D3DDECLTYPE_FLOAT4,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0 },
    { 1, 0, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR,     0 },
    D3DDECL_END()
};

Is it because I'm using POSITIONT? Do I need to change it to POSITION to be able to use another stream for my color?

 
Thanks!
Edited by Caeous

Share this post


Link to post
Share on other sites

I'm by no means confident in my answer, but am going to hazard a guess, since the usage of PositionT  disables vertex processing, that it is not designed to work with multiple streams. Have you verified that the multiple streams are available? Are the usages you requested available on your card? Have you been able to multiple streams with  untransformed positions successfully?

Share this post


Link to post
Share on other sites

That's what I thought too. I'm in the process of going to XYZ and using D3DXMatrixOrthoOffCenterRH to get a 2D view instead of using RHW. 

 

I've gotten it to work by putting both the color and the xyzrhw on the same stream. The moment that I split them up it fails.

 

Looking at the documentation tells me that when using POSITIONT:

 

  • Only stream zero can be used in such declarations.

Share this post


Link to post
Share on other sites

Hey guys, I'm not sure if I'm allowed to divert the subject a little bit as I'm trying to move from POSITIONT to POSITION. Obviously I'm trying to setup a 2D view... but now when I use D3DXMatrixOrthoOffCenterRH, my screen is completely black. Any thoughts? I'm coming from OpenGL and I think that's RH.

      ZeroMemory(&d3dpp, sizeof(d3dpp));    // clear out the struct for use      d3dpp.Windowed = TRUE;    // program windowed, not fullscreen
      d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;    // discard old frames
      d3dpp.hDeviceWindow = hWnd;    // set the window to be used by Direct3D

      // create a device class using this information and information from the d3dpp stuct
      d3d->CreateDevice(D3DADAPTER_DEFAULT,
         D3DDEVTYPE_HAL,
         hWnd,
         D3DCREATE_SOFTWARE_VERTEXPROCESSING,
         &d3dpp,
         &this->d3d_device);

      HRESULT hr;

      D3DXMATRIX ortho2D;
      D3DXMATRIX identity;

      D3DXMatrixOrthoOffCenterRH(&ortho2D, 0.0f, UI::WindowSize::Instance().GetWindowWidth(), UI::WindowSize::Instance().GetWindowHeight(), 0.0f, -1.0f, 4.0f);
      D3DXMatrixIdentity(&identity);

      this->d3d_device->SetTransform(D3DTS_PROJECTION, &ortho2D);
      this->d3d_device->SetTransform(D3DTS_WORLD, &identity);
      this->d3d_device->SetTransform(D3DTS_VIEW, &identity);

This is my declaration:

      D3DVERTEXELEMENT9 posColour_vec[] =
      {
         { 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
         { 1, 0, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
         D3DDECL_END()
      };

I'm setting my z to be 1.0f.

 

This is my Clear

this->d3d_device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);
Edited by Caeous

Share this post


Link to post
Share on other sites

Have you adjusted the data in your vertex buffers? Pretransformed data is in the +/-1 range, but you are now using a projection that would imply you want vertex data in +width or +height ranges. So it's possible your entire scene is compressed into less than a pixel in the bottom left or something.

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