I'm working on a DX11 project, and I get an odd behavior with a static function. I'm a little uneducated about static functions, so I'm probably making a mistake somewhere.
My function is simple:
namespace Rendering
{
static bool PlaceObjectInMatrix(EntityBase* obj, D3DXMATRIX world)
{
D3DXMatrixTranslation(&world, obj->GetPosition()->x, obj->GetPosition()->y, obj->GetPosition()->z);
return true;
}
}
and it is called in a loop to render all the objects:
for(unsigned int i = 0; i < listSize; i++)
{
if(entities[i].taken == false)
continue;
entities[i].entry->Render(deviceContext, shader);
PlaceObjectInMatrix(entities[i].entry, worldMatrix);
if(entities[i].entry->GetIndexCount() != 0)
{
shader->Render(deviceContext, entities[i].entry->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, entities[i].entry->GetTexture(), m_debugLight->GetDirection(), m_debugLight->GetDiffuseColor());
objectsRendered++;
}
d3d->GetWorldMatrix(worldMatrix); //reset world matrix
}
However, it does not work. When I replace the line with the function call with what is in the function itself, however, it does work. It's like something is getting lost in the function call.
The EntityBase class is abstract, and the class I'm actually rendering with is called EntityModelStatic, which is derived from EntityModel.
worldparameter a referenceD3DXMATRIX& world.