Fix Windows build (#1910)
* Fix function in conflict with Windows Unicode API * Minor corrections from PR
This commit is contained in:
parent
f0585716a8
commit
47cfba6c54
|
@ -17,22 +17,16 @@ void ACarlaHUD::DrawHUD()
|
|||
return;
|
||||
}
|
||||
|
||||
// get viewport size for culling
|
||||
int ScreenWidth = 0;
|
||||
int ScreenHeight = 0;
|
||||
Player->GetViewportSize(ScreenWidth, ScreenHeight);
|
||||
|
||||
double Now = FPlatformTime::Seconds();
|
||||
int i = 0;
|
||||
while (i < StringList.Num())
|
||||
{
|
||||
// project position from camera
|
||||
FVector2D Screen;
|
||||
Player->ProjectWorldLocationToScreen(StringList[i].Location, Screen, true);
|
||||
if (Screen.X >= 0 && Screen.Y >= 0 && Screen.X < ScreenWidth && Screen.Y < ScreenHeight)
|
||||
if (Player->ProjectWorldLocationToScreen(StringList[i].Location, Screen, true))
|
||||
{
|
||||
// draw text
|
||||
DrawText(StringList[i].Str, StringList[i].Color, Screen.X, Screen.Y, nullptr, 1.0f, false);
|
||||
DrawText(StringList[i].Str, StringList[i].Color, Screen.X, Screen.Y);
|
||||
}
|
||||
|
||||
// check to remove the string
|
||||
|
|
|
@ -6,6 +6,21 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
// Workaround to fix Windows conflict: Windows changes the name of some functions (DrawText, LoadLibrary...)
|
||||
// with Unicode / ANSI versions for his own API (DrawTextW, DrawTextA, LoadLibraryW, LoadLibraryA...).
|
||||
// But the changes are global for the compiler. Deep in headers, Windows has something like:
|
||||
// #ifdef UNICODE
|
||||
// #define DrawText DrawTextW
|
||||
// #define LoadLibrary LoadLibraryW
|
||||
// #else
|
||||
// #define DrawText DrawTextA
|
||||
// #define LoadLibrary LoadLibraryA
|
||||
// #endif
|
||||
// Then the linker tries to find the function DrawTextW on an external DLL and an unresolved external error happens because
|
||||
// Unreal has no function DrawTextW, it has just DrawText.
|
||||
// We can fix that by just undefining the function that conflicts with the name of the Windows API in Unicode.
|
||||
#undef DrawText
|
||||
|
||||
#include "Containers/Array.h"
|
||||
#include "GameFramework/HUD.h"
|
||||
|
||||
|
|
Loading…
Reference in New Issue