Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

What's wrong about my code?

4: Adsense

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 blackfe2010   Members   

150
Like
0Likes
Like

Posted 15 December 2012 - 09:54 AM

Hi

I want display a model. but there is something wrong.

I use PIX to see what's wrong, and I find the data is malposition.

This is the data what my program drew
VTX IDX POSITION[0] POSITION[1] POSITION[2] POSITION[3] TEXCOORD[0] TEXCOORD[1]
0 1 0.453 0.78 0.14 1 61.198 -14.418
1 2 61.198 -14.418 0.453 1 0.653 -7.689
2 0 0.024 55.081 -2.898 1 0.453 0.78

but the correct one is:

VTX IDX POSITION[0] POSITION[1] POSITION[2] POSITION[3] TEXCOORD[0] TEXCOORD[1]
0 1 0.14 61.198 -14.418 1 0.453 0.653
1 2 -7.689 61.197 -11.877 1 0.39 0.653
2 0 0.024 55.081 -2.898 1 0.453 0.78

the issue start at index 1 POSITION[0] and POSITION[1],
They re-use index 0 TEXCOORD[0] and TEXCOORD[1],

And I see the input layout, it is correct.
SemanticName SemanticIndex Format InputSlot AlignedByteOffset InputSlotClass InstanceDataStepRate
POSITION 0 DXGI_FORMAT_R32G32B32_FLOAT 0 0 D3D11_INPUT_PER_VERTEX_DATA 0
TEXCOORD 0 DXGI_FORMAT_R32G32_FLOAT 0 12 D3D11_INPUT_PER_VERTEX_DATA 0

In the .fx file

struct VSInputTexture
{
float4 pos : POSITION;
float2 tex0 : TEXCOORD0;
};

I use a struct in c++

struct VertexTexStr
{
XMFLOAT3 pos;
XMFLOAT2 tex;
};

I used D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST and
create vertex buffer:
[source lang="cpp"]void RenderObject::CreateVertexBuffer(){ try { D3D11_BUFFER_DESC bufferDesc; ZeroMemory( &bufferDesc, sizeof( bufferDesc ) ); D3D11_SUBRESOURCE_DATA initData; ZeroMemory( &initData, sizeof( initData ) ); VertexTexStr* tmpVertexTex=NULL; bufferDesc.Usage=D3D11_USAGE_DEFAULT; bufferDesc.BindFlags=D3D11_BIND_VERTEX_BUFFER; bufferDesc.CPUAccessFlags=0; bufferDesc.MiscFlags=0; bufferDesc.StructureByteStride=0; switch(m_mode) { case RenderWithCameraWithTexture: bufferDesc.ByteWidth=sizeof(VertexTexStr)*m_vertices->size(); tmpVertexTex=new VertexTexStr[m_vertices->size()]; for(size_t i=0;i<m_vertices->size();i++) { tmpVertexTex[i].pos=(*m_vertices)[i]; tmpVertexTex[i].tex=(*m_texs)[i]; } initData.pSysMem=tmpVertexTex; sendMessage(MSG_CREATE_BUFFER,AuxGroupArgus(&bufferDesc,&initData,&m_verticesBuffer)); delete[] tmpVertexTex; break;[/source]

I use debug to see the initData.pSysMem, it is ok at index 1.
What's wrong?

#2 Zaoshi Kaba   Members   

8298
Like
1Likes
Like

Posted 15 December 2012 - 10:02 AM

When you call IASetVertexBuffers are you sure you set correct strides?

#3 blackfe2010   Members   

150
Like
0Likes
Like

Posted 15 December 2012 - 09:01 PM

you are right. thank you




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.