Merge branch 'main' of https://git.sixtenhugosson.com/sixtenhugosson/vn into main
# Conflicts: # code/win32_main.cppmain
commit
d70b6db7af
|
@ -113,10 +113,10 @@ static glyph_atlas *CreateGlyphAtlas(vn_render_commands *RenderCommands,
|
||||||
Atlas->RenderCommands = RenderCommands;
|
Atlas->RenderCommands = RenderCommands;
|
||||||
Atlas->Texture = RenderCommands->AllocateTexture(V2S(BitmapSize, BitmapSize), Render_TextureFormat_R8, 0);
|
Atlas->Texture = RenderCommands->AllocateTexture(V2S(BitmapSize, BitmapSize), Render_TextureFormat_R8, 0);
|
||||||
|
|
||||||
Atlas->Fonts[Font_Regular].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("../fonts/Roboto-Regular.ttf"));
|
Atlas->Fonts[Font_Regular].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("fonts/Roboto-Regular.ttf"));
|
||||||
Atlas->Fonts[Font_Bold].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("../fonts/Roboto-Bold.ttf"));
|
Atlas->Fonts[Font_Bold].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("fonts/Roboto-Bold.ttf"));
|
||||||
Atlas->Fonts[Font_Monospace].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("../fonts/Liberation-Mono.ttf"));
|
Atlas->Fonts[Font_Monospace].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("fonts/Liberation-Mono.ttf"));
|
||||||
Atlas->Fonts[Font_Icons].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("../fonts/icons.ttf"));
|
Atlas->Fonts[Font_Icons].Data = Platform_ReadEntireFile(&Atlas->Arena, StrLit("fonts/icons.ttf"));
|
||||||
|
|
||||||
for(s32 FontIndex = 0;
|
for(s32 FontIndex = 0;
|
||||||
FontIndex < Font_Count;
|
FontIndex < Font_Count;
|
||||||
|
|
|
@ -44,6 +44,28 @@ inline string MakeStringFromCString(char *Data)
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline b32 AreEqual(string A, string B)
|
||||||
|
{
|
||||||
|
b32 Result = false;
|
||||||
|
if(A.Count == B.Count)
|
||||||
|
{
|
||||||
|
Result = true;
|
||||||
|
|
||||||
|
for(s64 Index = 0;
|
||||||
|
Index < A.Count;
|
||||||
|
++Index)
|
||||||
|
{
|
||||||
|
if(A.Data[Index] != B.Data[Index])
|
||||||
|
{
|
||||||
|
Result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Result);
|
||||||
|
}
|
||||||
|
|
||||||
inline s64 FirstIndexOf(string String, char Char)
|
inline s64 FirstIndexOf(string String, char Char)
|
||||||
{
|
{
|
||||||
s64 Result = -1;
|
s64 Result = -1;
|
||||||
|
@ -76,25 +98,23 @@ inline s64 LastIndexOf(string String, char Char)
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline b32 AreEqual(string A, string B)
|
inline s64 LastIndexOf(string String, string Substring)
|
||||||
{
|
{
|
||||||
b32 Result = false;
|
s64 Result = -1;
|
||||||
if(A.Count == B.Count)
|
if(String.Count >= Substring.Count)
|
||||||
{
|
{
|
||||||
Result = true;
|
for(s64 Index = String.Count-Substring.Count;
|
||||||
|
Index >= 0;
|
||||||
for(s64 Index = 0;
|
--Index)
|
||||||
Index < A.Count;
|
|
||||||
++Index)
|
|
||||||
{
|
{
|
||||||
if(A.Data[Index] != B.Data[Index])
|
string ToCheck = MakeString((char *)String.Data + Index, Substring.Count);
|
||||||
|
if(AreEqual(ToCheck, Substring))
|
||||||
{
|
{
|
||||||
Result = false;
|
Result = Index;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,9 +84,12 @@ static PLATFORM_OPEN_FILE(Win32_OpenFile)
|
||||||
CreationAttributes = OPEN_EXISTING;
|
CreationAttributes = OPEN_EXISTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
string FullPath = Path;
|
temporary_memory Scratch = GetScratch(0, 0);
|
||||||
|
|
||||||
HANDLE File = CreateFileA((char *)Path.Data, DesiredAccess, 0, 0, CreationAttributes, 0, 0);
|
string FullPath = PushFormat(Scratch.Arena, "%S\\%S", Global_Win32State.ContentsPath, Path);
|
||||||
|
HANDLE File = CreateFileA((char *)FullPath.Data, DesiredAccess, 0, 0, CreationAttributes, 0, 0);
|
||||||
|
|
||||||
|
ReleaseScratch(Scratch);
|
||||||
|
|
||||||
platform_file_handle Result = {};
|
platform_file_handle Result = {};
|
||||||
Result.Platform = (u64)File;
|
Result.Platform = (u64)File;
|
||||||
|
@ -225,6 +228,11 @@ static PLATFORM_TOGGLE_FULLSCREEN(Win32_ToggleFullscreen)
|
||||||
DWORD Style = GetWindowLong(Window, GWL_STYLE);
|
DWORD Style = GetWindowLong(Window, GWL_STYLE);
|
||||||
if(Style & WS_OVERLAPPEDWINDOW)
|
if(Style & WS_OVERLAPPEDWINDOW)
|
||||||
{
|
{
|
||||||
|
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
|
||||||
|
if(GetWindowPlacement(Window, &Global_WindowPosition) &&
|
||||||
|
GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
|
||||||
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
|
MONITORINFO MonitorInfo = {sizeof(MonitorInfo)};
|
||||||
if(GetWindowPlacement(Window, &Global_WindowPosition) &&
|
if(GetWindowPlacement(Window, &Global_WindowPosition) &&
|
||||||
GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
|
GetMonitorInfo(MonitorFromWindow(Window, MONITOR_DEFAULTTOPRIMARY), &MonitorInfo))
|
||||||
|
@ -245,6 +253,20 @@ static PLATFORM_TOGGLE_FULLSCREEN(Win32_ToggleFullscreen)
|
||||||
SetWindowPlacement(Window, &Global_WindowPosition);
|
SetWindowPlacement(Window, &Global_WindowPosition);
|
||||||
SetWindowPos(Window, 0, 0, 0, 0, 0,
|
SetWindowPos(Window, 0, 0, 0, 0, 0,
|
||||||
SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_FRAMECHANGED);
|
SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_FRAMECHANGED);
|
||||||
|
=======
|
||||||
|
SetWindowPos(Window, HWND_TOP,
|
||||||
|
MonitorInfo.rcMonitor.left, MonitorInfo.rcMonitor.top,
|
||||||
|
MonitorInfo.rcMonitor.right - MonitorInfo.rcMonitor.left,
|
||||||
|
MonitorInfo.rcMonitor.bottom - MonitorInfo.rcMonitor.top,
|
||||||
|
SWP_NOOWNERZORDER | SWP_FRAMECHANGED);
|
||||||
|
>>>>>>> 376349b92227dcf5369dee77701a9ad8570ab639
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetWindowPlacement(Window, &Global_WindowPosition);
|
||||||
|
SetWindowPos(Window, 0, 0, 0, 0, 0,
|
||||||
|
SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_FRAMECHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,7 +583,19 @@ inline void Win32_GetRelevantPaths(win32_state *State)
|
||||||
Win32_PlatformError("Path to executable is too long. Try running the game from another directory", true);
|
Win32_PlatformError("Path to executable is too long. Try running the game from another directory", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
s64 OnePastLastSlash = LastIndexOf(MakeStringFromCString(State->EXEPath), '\\') + 1;
|
string EXEPathString = MakeStringFromCString(State->EXEPath);
|
||||||
|
|
||||||
|
s64 OnePastLastSlash = LastIndexOf(EXEPathString, '\\') + 1;
|
||||||
|
s64 BuildIndex = LastIndexOf(EXEPathString, StrLit("build"));
|
||||||
|
|
||||||
|
if(BuildIndex == -1)
|
||||||
|
{
|
||||||
|
State->ContentsPath = MakeString((char *)EXEPathString.Data, OnePastLastSlash);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
State->ContentsPath = MakeString((char *)EXEPathString.Data, BuildIndex);
|
||||||
|
}
|
||||||
|
|
||||||
string DLLName = StrLit("vn.dll");
|
string DLLName = StrLit("vn.dll");
|
||||||
Copy(State->DLLPath, State->EXEPath, OnePastLastSlash);
|
Copy(State->DLLPath, State->EXEPath, OnePastLastSlash);
|
||||||
|
|
|
@ -30,6 +30,7 @@ struct win32_state
|
||||||
char EXEPath[512];
|
char EXEPath[512];
|
||||||
char DLLPath[512];
|
char DLLPath[512];
|
||||||
char TempDLLPath[512];
|
char TempDLLPath[512];
|
||||||
|
string ContentsPath;
|
||||||
|
|
||||||
platform_cursor Cursor;
|
platform_cursor Cursor;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue