I have a function designed to update various types of data, and I’m encountering an issue where the try-catch block doesn’t seem to catch a nullptr error when I’m attempting to update buffer data for DirectX.
Here’s the function:
void Stelo_Project::UpdateBuffer_game(unint TypeCom, unint TypeEX, GameObject* ob){
const char* dataToCopy;
TransformBuffer tfb;
try{
switch (TypeCom) {
case ComponentType::Transform:{}
case ComponentType::Material: {}
case ComponentType::Light: {}
case ComponentType::Mesh: {
mesh_game = ob->GetComponent<Mesh>();
device_game.d3d_DeviceContext->Map(buffer_game[TypeBuffer::mesh].second->d3d_Buffer, NULL,
D3D11_MAP_WRITE_DISCARD, NULL, &map_game);
memcpy(map_game.pData, mesh_game->Vertices.data(), sizeof(Vertex) * mesh_game->Vertices.size());
device_game.d3d_DeviceContext->Unmap(buffer_game[TypeBuffer::mesh].second->d3d_Buffer, NULL);
device_game.d3d_DeviceContext->IASetVertexBuffers(0, 1, &buffer_game[TypeBuffer::mesh].second->d3d_Buffer,
&PosStride, 0);
device_game.d3d_DeviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
break;
}
}
}
catch (const std::exception& e) {
std::wstring wstr = stringToWstring(e.what());
Debug::Log(wstr);
}
}
and this is what happened
Can anyone tell me what’s going on.