我应该使用 DeviceContext 函数在管道中循环输入还是通过创建输入?
Should I use the DeviceContext functions to input in the Pipeline in loop or by creation?
嘿伙计们,我应该使用像 IASetVertexBuffers、IASetPrimitiveTopology、VSSetShader 这样的 DeviceContext 函数来创建
void init() {
//create window and stuff
devicecontext->IASetVertexBuffers(...);
}
void draw() {
//draw
}
或像
这样循环
void init() {
//create window and stuff
}
void draw() {
devicecontext->IASetVertexBuffers(...);
//draw
}
这是我实际使用的代码
void ARenderer::Draw(AMesh * mesh, AShader* shader)
{
ARenderer::SetViewport(currentviewport);
ARenderer::ApplyShader(shader);
///Drawing
uint32_t stride = sizeof(AVertex);
uint32_t offset = 0;
dxmanager->DeviceContext->IASetVertexBuffers(0, 1, mesh->GetBuffer().GetAddressOf(), &stride, &offset);
dxmanager->DeviceContext->IASetPrimitiveTopology(static_cast<D3D11_PRIMITIVE_TOPOLOGY>(mesh->GetPrimitive()));
dxmanager->DeviceContext->Draw(mesh->GetVertexCount(), 0);
}
您可能希望在应用程序中绘制多个对象或事物,这意味着您必须在每帧中多次调用它们,因此初始化时间不是一个选项。
您始终在平局之前设置所有必要的状态,直到它在您的应用程序中出现性能问题,这样比较安全。这通常不会发生在小型应用程序中。一旦你完成了功能和正确性,你可以尝试更聪明地发送东西,而不是之前。
嘿伙计们,我应该使用像 IASetVertexBuffers、IASetPrimitiveTopology、VSSetShader 这样的 DeviceContext 函数来创建
void init() {
//create window and stuff
devicecontext->IASetVertexBuffers(...);
}
void draw() {
//draw
}
或像
这样循环void init() {
//create window and stuff
}
void draw() {
devicecontext->IASetVertexBuffers(...);
//draw
}
这是我实际使用的代码
void ARenderer::Draw(AMesh * mesh, AShader* shader)
{
ARenderer::SetViewport(currentviewport);
ARenderer::ApplyShader(shader);
///Drawing
uint32_t stride = sizeof(AVertex);
uint32_t offset = 0;
dxmanager->DeviceContext->IASetVertexBuffers(0, 1, mesh->GetBuffer().GetAddressOf(), &stride, &offset);
dxmanager->DeviceContext->IASetPrimitiveTopology(static_cast<D3D11_PRIMITIVE_TOPOLOGY>(mesh->GetPrimitive()));
dxmanager->DeviceContext->Draw(mesh->GetVertexCount(), 0);
}
您可能希望在应用程序中绘制多个对象或事物,这意味着您必须在每帧中多次调用它们,因此初始化时间不是一个选项。
您始终在平局之前设置所有必要的状态,直到它在您的应用程序中出现性能问题,这样比较安全。这通常不会发生在小型应用程序中。一旦你完成了功能和正确性,你可以尝试更聪明地发送东西,而不是之前。