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

Recommended Posts

I cant seem to get my Box mesh to show up , here is the code


void

initBox()
{

const char* strAsmVertexShader = "vs_1_1\n" //version instruction

"dcl_position v0\n" //define position data in register v0

"dcl_color v1\n" //define color

"m4x4 oPos, v0, c0\n" //view/projection

"mov oD0, v1\n" //apply diffuse to vertices

"";

HRESULT hr;
NULL,
NULL,
NULL);

if(FAILED(hr))
{

}

if(FAILED(hr))
{
}
?
?

//Mesh code
D3DVERTEXELEMENT9 decl[] =
{
{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},

//POSITION
{ 0, 12, D3DDECLTYPE_D3DCOLOR, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0},

//COLOR
D3DDECL_END()
};

HRESULT hr = d3ddev->CreateVertexDeclaration(decl,&m_pVertexDeclarationBox);
D3DXCreateBox(d3ddev,1.0f,1.0f,1.0f,&D3DCube,NULL);
?

//Clone the mesh so it gets position and color data for the vertex shader
D3DCube->CloneMesh(D3DXMESH_32BIT | D3DXMESH_MANAGED,
decl,
d3ddev,
&D3DClonedCube);

}



?

Rendering



if(m_pAsm_VS)
{
D3DXMATRIX compMat;
D3DXMatrixMultiply(&compMat,&matRotateY,&matView);
D3DXMatrixMultiply(&compMat,&compMat,&matProjection);

D3DXMatrixTranspose(&compMat,&compMat);

//rearranges to column major order so its 4 dot products

float*)&compMat,4);
d3ddev->SetVertexDeclaration(m_pVertexDeclarationBox);

//d3ddev->SetStreamSource(0,m_pVB,0,sizeof(CUSTOMVERTEX_ASM));//CreateVertexBuffer code, now were working with LPD3DXMESH...
//d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST,0,1);

D3DClonedCube->DrawSubset(0);
}



?

Edited by Anddos

Share on other sites

A lot of things not shown in the code can be wrong, starting with your transform matrices.

Enable the Direct3D Debug Runtimes and check for any errors and warnings in the output log. Use PIX to debug the application and see better what's going on.

Btw, what color do you use to clear your backbuffer? If it's black or white then definitely change it to something else. Especially black is perfect in "hiding" rendered geometry if you have some error in lighting.

Also I would pay attention to the fact that you create the box with D3DXCreateBox and then add color to its vertex declaration via CloneMesh, but you never really set some colors to the verticles. I don't know how exactly this behaves, but I would suppose the color is zero? Either completely zero, which means also completely transparent, or maybe 0xFF000000 which means black. Or it simply is a "random" number? No idea. You definitely should lock the vertex buffer and set your own colors.

And last remark - is it possible to have your own vertex shader and let the fixed-function pipeline do the rest? You don't set any pixel shader. I've never done this, but maybe it is possible.

And just now I noticed that you don't set even the vertex shader. You have this line d3ddev->SetVertexShader(NULL) before the DrawSubset. So you have no vertex shader!

Edited by Tom KQT

• 17
• 10
• 19
• 14
• 19