@@ -259,6 +259,10 @@ void GameObjectsDisplay::on_frame() {
259
259
260
260
m_d3d12.effect ->SetProjection (proj_directx);
261
261
m_d3d12.effect ->SetView (view_directx);
262
+ m_d3d12.effect ->SetTexture (m_d3d12.text_texture ->get_srv_gpu (), m_d3d12.states ->LinearWrap ());
263
+
264
+ m_d3d12.effect_no_tex ->SetProjection (proj_directx);
265
+ m_d3d12.effect_no_tex ->SetView (view_directx);
262
266
});
263
267
}
264
268
@@ -304,7 +308,7 @@ void GameObjectsDisplay::on_frame() {
304
308
DirectX::SimpleMath::Matrix world =
305
309
DirectX::SimpleMath::Matrix{&world_matrix[0 ][0 ]};
306
310
307
- d3d12_work.emplace_back ([this , world, owner_name ](const BackBufferRenderer::RenderWorkData& data) {
311
+ d3d12_work.emplace_back ([this , owner_name, world ](const BackBufferRenderer::RenderWorkData& data) {
308
312
// Create barrier to transition to render target
309
313
D3D12_RESOURCE_BARRIER barrier{};
310
314
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
@@ -337,8 +341,9 @@ void GameObjectsDisplay::on_frame() {
337
341
data.command_list ->ClearRenderTargetView (m_d3d12.text_texture ->get_rtv (), DirectX::Colors::Transparent, 0 , nullptr );
338
342
339
343
m_d3d12.sprite_batch ->Begin (data.command_list );
340
-
341
- m_d3d12.font ->DrawString (m_d3d12.sprite_batch .get (), owner_name.c_str (), DirectX::SimpleMath::Vector2 (0 , 0 ), DirectX::Colors::White);
344
+
345
+ const auto measurements = m_d3d12.font ->MeasureString (owner_name.c_str ());
346
+ m_d3d12.font ->DrawString (m_d3d12.sprite_batch .get (), owner_name.c_str (), DirectX::SimpleMath::Vector2 (256 .0f - glm::min (DirectX::XMVectorGetX (measurements) / 2 .0f , 256 .0f ), 256 .0f ), DirectX::Colors::White);
342
347
343
348
m_d3d12.sprite_batch ->End ();
344
349
@@ -359,6 +364,12 @@ void GameObjectsDisplay::on_frame() {
359
364
D3D12_CPU_DESCRIPTOR_HANDLE bbrtv_heaps[] = { data.backbuffer_ctx ->get_rtv () };
360
365
data.command_list ->OMSetRenderTargets (1 , bbrtv_heaps, FALSE , nullptr );
361
366
367
+ if (m_effect_alpha > 0 .0f ) {
368
+ m_d3d12.effect_no_tex ->SetWorld (world);
369
+ m_d3d12.effect_no_tex ->Apply (data.command_list );
370
+ m_d3d12.quad ->Draw (data.command_list );
371
+ }
372
+
362
373
m_d3d12.effect ->SetWorld (world);
363
374
m_d3d12.effect ->Apply (data.command_list );
364
375
m_d3d12.quad ->Draw (data.command_list );
0 commit comments