Anyways here they go:
For Vertex and Index buffers I noticed this:
D3D10_BUFFER_DESC vbd;
vbd.Usage = D3D10_USAGE_IMMUTABLE;
vbd.ByteWidth = sizeof(Vertex) * mNumVertices;
vbd.BindFlags = D3D10_BIND_VERTEX_BUFFER;
vbd.CPUAccessFlags = 0;
vbd.MiscFlags = 0;
D3D10_SUBRESOURCE_DATA vinitData;
vinitData.pSysMem = &vertices[0]; <-------
HR(md3dDevice->CreateBuffer(&vbd, &vinitData, &mVB));
What exactly does the piece I have an arrow pointed at do? I think in DX11 it was something completely different (like 3 lines worth) I think we used something like:
D3D11_MAPPED_SUBRESOURCE ms;
devcon->Map(pVBuffer, NULL, D3D11_MAP_WRITE_DISCARD, NULL, &ms); // map the buffer
memcpy(ms.pData, OurVertices, sizeof(OurVertices)); // copy the data
devcon->Unmap(pVBuffer, NULL);
ok secondly is dealing with HLSL in DX11 I would compile the shader and do something like this:
ID3D10Blob *VS, *PS;
D3DX11CompileFromFile(L"shaders.hlsl", 0, 0, "VShader", "vs_5_0", 0, 0, 0, &VS, 0, 0);
D3DX11CompileFromFile(L"shaders.hlsl", 0, 0, "PShader", "ps_5_0", 0, 0, 0, &PS, 0, 0);
// create the shader objects
dev->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), NULL, &pVS);
dev->CreatePixelShader(PS->GetBufferPointer(), PS->GetBufferSize(), NULL, &pPS);
// set the shader objects
devcon->VSSetShader(pVS, 0, 0);
devcon->PSSetShader(pPS, 0, 0);
but in the DX10 code it's like:
D3D10_TECHNIQUE_DESC techDesc;
mTech->GetDesc( &techDesc );
for(UINT p = 0; p < techDesc.Passes; ++p)
{
mWVP = mView*mProj;
mfxWVPVar->SetMatrix((float*)&mWVP);
mTech->GetPassByIndex( p )->Apply(0);
mLand.draw();
}
and this:
mTech = mFX->GetTechniqueByName("ColorTech");
mfxWVPVar = mFX->GetVariableByName("gWVP")->AsMatrix();
I've looked around the book, and it doesnt really explain what these do.
also here's the HLSL for reference for the DX10 book
//=============================================================================
// color.fx by Frank Luna (C) 2008 All Rights Reserved.
//
// Transforms and colors geometry.
//=============================================================================
cbuffer cbPerObject
{
float4x4 gWVP;
};
void VS(float3 iPosL : POSITION,
float4 iColor : COLOR,
out float4 oPosH : SV_POSITION,
out float4 oColor : COLOR)
{
// Transform to homogeneous clip space.
oPosH = mul(float4(iPosL, 1.0f), gWVP);
// Just pass vertex color into the pixel shader.
oColor = iColor;
}
float4 PS(float4 posH : SV_POSITION,
float4 color : COLOR) : SV_Target
{
return color;
}
/*
RasterizerState Wireframe
{
FillMode = Wireframe;
CullMode = Back;
FrontCounterClockwise = false;
};*/
technique10 ColorTech
{
pass P0
{
SetVertexShader( CompileShader( vs_4_0, VS() ) );
SetGeometryShader( NULL );
SetPixelShader( CompileShader( ps_4_0, PS() ) );
//SetRasterizerState(Wireframe);
}
}
I've never seen a "technique" mentioned in DX11....and i'd def. never seen anything like this:
mTech = mFX->GetTechniqueByName("ColorTech");
mfxWVPVar = mFX->GetVariableByName("gWVP")->AsMatrix();
seems like creating an input layout and such is ALOT easier in DX11...
anyone care to explain what these are?