Update dqn with CPP api for memstacks
This commit is contained in:
parent
26e6892d64
commit
54c6abd9d7
@ -935,8 +935,9 @@ extern "C" void DTR_Update(PlatformRenderBuffer *const platformRenderBuffer,
|
|||||||
if (DTR_DEBUG)
|
if (DTR_DEBUG)
|
||||||
{
|
{
|
||||||
DTRDebug_TestMeshFaceAndVertexParser(&state->mesh);
|
DTRDebug_TestMeshFaceAndVertexParser(&state->mesh);
|
||||||
auto memRegion = DqnMemStackTempRegionScoped(&memory->tempStack);
|
bool regionValid;
|
||||||
if (memRegion.isInit)
|
auto memRegion = DqnMemStackTempRegionScoped(&memory->tempStack, ®ionValid);
|
||||||
|
if (regionValid)
|
||||||
{
|
{
|
||||||
DTRBitmap test = {};
|
DTRBitmap test = {};
|
||||||
DTRAsset_LoadBitmap(input->api, assetStack, &memory->tempStack, &test,
|
DTRAsset_LoadBitmap(input->api, assetStack, &memory->tempStack, &test,
|
||||||
@ -947,8 +948,9 @@ extern "C" void DTR_Update(PlatformRenderBuffer *const platformRenderBuffer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto tempMemRegion = DqnMemStackTempRegionScoped(&memory->tempStack);
|
bool regionValid;
|
||||||
if (tempMemRegion.isInit)
|
auto tempMemRegion = DqnMemStackTempRegionScoped(&memory->tempStack, ®ionValid);
|
||||||
|
if (regionValid)
|
||||||
{
|
{
|
||||||
size_t debugSize = DQN_MEGABYTE(1);
|
size_t debugSize = DQN_MEGABYTE(1);
|
||||||
u8 *debugMemory = (u8 *)DqnMemStack_Push(&memory->tempStack, debugSize);
|
u8 *debugMemory = (u8 *)DqnMemStack_Push(&memory->tempStack, debugSize);
|
||||||
|
@ -634,8 +634,9 @@ bool DTRAsset_LoadFontToBitmap(const PlatformAPI api, DqnMemStack *const memStac
|
|||||||
stbtt_pack_context fontPackContext = {};
|
stbtt_pack_context fontPackContext = {};
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
auto tmpMemRegion = DqnMemStackTempRegionScoped(tmpMemStack);
|
bool regionValid;
|
||||||
if (!tmpMemRegion.isInit)
|
auto tmpMemRegion = DqnMemStackTempRegionScoped(tmpMemStack, ®ionValid);
|
||||||
|
if (!regionValid)
|
||||||
{
|
{
|
||||||
// TODO(doyle): Logging
|
// TODO(doyle): Logging
|
||||||
DQN_ASSERT(DQN_INVALID_CODE_PATH);
|
DQN_ASSERT(DQN_INVALID_CODE_PATH);
|
||||||
@ -766,13 +767,7 @@ bool DTRAsset_LoadBitmap(const PlatformAPI api, DqnMemStack *const memStack,
|
|||||||
if (!api.FileOpen(path, &file, PlatformFilePermissionFlag_Read, PlatformFileAction_OpenOnly))
|
if (!api.FileOpen(path, &file, PlatformFilePermissionFlag_Read, PlatformFileAction_OpenOnly))
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
auto tmpMemRegion = DqnMemStackTempRegionScoped(tempStack);
|
DqnMemStackTempRegionScoped tmpMemRegion = tempStack->TempRegionScoped();
|
||||||
if (!tmpMemRegion.isInit)
|
|
||||||
{
|
|
||||||
// TODO(doyle): Logging
|
|
||||||
DQN_ASSERT(DQN_INVALID_CODE_PATH);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 *const rawData = (u8 *)DqnMemStack_Push(tempStack, file.size);
|
u8 *const rawData = (u8 *)DqnMemStack_Push(tempStack, file.size);
|
||||||
size_t bytesRead = api.FileRead(&file, rawData, file.size);
|
size_t bytesRead = api.FileRead(&file, rawData, file.size);
|
||||||
|
@ -77,8 +77,9 @@ void DTRDebug_DumpZBuffer(DTRRenderBuffer *const renderBuffer, DqnMemStack *cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto memRegion = DqnMemStackTempRegionScoped(tempStack);
|
bool regionValid;
|
||||||
if (memRegion.isInit)
|
auto memRegion = DqnMemStackTempRegionScoped(tempStack, ®ionValid);
|
||||||
|
if (regionValid)
|
||||||
{
|
{
|
||||||
size_t bufSize = DQN_MEGABYTE(16);
|
size_t bufSize = DQN_MEGABYTE(16);
|
||||||
char *bufString = (char *)DqnMemStack_Push(tempStack, bufSize);
|
char *bufString = (char *)DqnMemStack_Push(tempStack, bufSize);
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#define UNICODE
|
||||||
|
#define _UNICODE
|
||||||
|
|
||||||
#include "DTRenderer.h"
|
#include "DTRenderer.h"
|
||||||
#include "DTRendererPlatform.h"
|
#include "DTRendererPlatform.h"
|
||||||
|
|
||||||
@ -5,9 +8,6 @@
|
|||||||
#define DQN_IMPLEMENTATION
|
#define DQN_IMPLEMENTATION
|
||||||
#include "dqn.h"
|
#include "dqn.h"
|
||||||
|
|
||||||
#define UNICODE
|
|
||||||
#define _UNICODE
|
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <Windowsx.h> // For GET_X|Y_LPARAM(), mouse input
|
#include <Windowsx.h> // For GET_X|Y_LPARAM(), mouse input
|
||||||
#include <Psapi.h> // For win32 GetProcessMemoryInfo()
|
#include <Psapi.h> // For win32 GetProcessMemoryInfo()
|
||||||
@ -176,7 +176,7 @@ FILE_SCOPE inline DqnFile PlatformFileToDqnFileInternal(const PlatformFile file)
|
|||||||
void Platform_Print(const char *const string)
|
void Platform_Print(const char *const string)
|
||||||
{
|
{
|
||||||
if (!string) return;
|
if (!string) return;
|
||||||
OutputDebugString(string);
|
OutputDebugStringA(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Platform_FileOpen(const char *const path, PlatformFile *const file, const u32 permissionFlags,
|
bool Platform_FileOpen(const char *const path, PlatformFile *const file, const u32 permissionFlags,
|
||||||
@ -287,7 +287,7 @@ FILETIME Win32GetLastWriteTime(const char *const srcName)
|
|||||||
{
|
{
|
||||||
FILETIME lastWriteTime = {};
|
FILETIME lastWriteTime = {};
|
||||||
WIN32_FILE_ATTRIBUTE_DATA attribData = {};
|
WIN32_FILE_ATTRIBUTE_DATA attribData = {};
|
||||||
if (GetFileAttributesEx(srcName, GetFileExInfoStandard, &attribData) != 0)
|
if (GetFileAttributesExA(srcName, GetFileExInfoStandard, &attribData) != 0)
|
||||||
{
|
{
|
||||||
lastWriteTime = attribData.ftLastWriteTime;
|
lastWriteTime = attribData.ftLastWriteTime;
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ FILE_SCOPE Win32ExternalCode Win32LoadExternalDLL(const char *const srcPath,
|
|||||||
{
|
{
|
||||||
Win32ExternalCode result = {};
|
Win32ExternalCode result = {};
|
||||||
result.lastWriteTime = lastWriteTime;
|
result.lastWriteTime = lastWriteTime;
|
||||||
CopyFile(srcPath, tmpPath, false);
|
CopyFileA(srcPath, tmpPath, false);
|
||||||
|
|
||||||
DTR_UpdateFunction *updateFunction = NULL;
|
DTR_UpdateFunction *updateFunction = NULL;
|
||||||
result.dll = LoadLibraryA(tmpPath);
|
result.dll = LoadLibraryA(tmpPath);
|
||||||
@ -332,10 +332,10 @@ FILE_SCOPE void Win32CreateMenu(HWND window)
|
|||||||
HMENU menuBar = CreateMenu();
|
HMENU menuBar = CreateMenu();
|
||||||
{ // File Menu
|
{ // File Menu
|
||||||
HMENU menu = CreatePopupMenu();
|
HMENU menu = CreatePopupMenu();
|
||||||
AppendMenu(menuBar, MF_STRING | MF_POPUP, (UINT_PTR)menu, "File");
|
AppendMenuA(menuBar, MF_STRING | MF_POPUP, (UINT_PTR)menu, "File");
|
||||||
AppendMenu(menu, MF_STRING, Win32Menu_FileOpen, "Open");
|
AppendMenuA(menu, MF_STRING, Win32Menu_FileOpen, "Open");
|
||||||
AppendMenu(menu, MF_STRING, Win32Menu_FileFlushMemory, "Flush Memory");
|
AppendMenuA(menu, MF_STRING, Win32Menu_FileFlushMemory, "Flush Memory");
|
||||||
AppendMenu(menu, MF_STRING, Win32Menu_FileExit, "Exit");
|
AppendMenuA(menu, MF_STRING, Win32Menu_FileExit, "Exit");
|
||||||
}
|
}
|
||||||
SetMenu(window, menuBar);
|
SetMenu(window, menuBar);
|
||||||
}
|
}
|
||||||
@ -774,7 +774,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
|||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
// Update State
|
// Update State
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
f64 startFrameTimeInS = DqnTime_NowInS();
|
f64 startFrameTimeInS = DqnTimer_NowInS();
|
||||||
|
|
||||||
FILETIME lastWriteTime = Win32GetLastWriteTime(dllPath);
|
FILETIME lastWriteTime = Win32GetLastWriteTime(dllPath);
|
||||||
if (CompareFileTime(&lastWriteTime, &dllCode.lastWriteTime) != 0)
|
if (CompareFileTime(&lastWriteTime, &dllCode.lastWriteTime) != 0)
|
||||||
@ -785,7 +785,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
platformInput.timeNowInS = DqnTime_NowInS();
|
platformInput.timeNowInS = DqnTimer_NowInS();
|
||||||
platformInput.deltaForFrame = (f32)frameTimeInS;
|
platformInput.deltaForFrame = (f32)frameTimeInS;
|
||||||
Win32ProcessMessages(mainWindow, &platformInput);
|
Win32ProcessMessages(mainWindow, &platformInput);
|
||||||
|
|
||||||
@ -823,7 +823,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
|||||||
// Frame Limiting
|
// Frame Limiting
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
{
|
{
|
||||||
f64 workTimeInS = DqnTime_NowInS() - startFrameTimeInS;
|
f64 workTimeInS = DqnTimer_NowInS() - startFrameTimeInS;
|
||||||
if (workTimeInS < targetSecondsPerFrame)
|
if (workTimeInS < targetSecondsPerFrame)
|
||||||
{
|
{
|
||||||
DWORD remainingTimeInMs =
|
DWORD remainingTimeInMs =
|
||||||
@ -832,7 +832,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frameTimeInS = DqnTime_NowInS() - startFrameTimeInS;
|
frameTimeInS = DqnTimer_NowInS() - startFrameTimeInS;
|
||||||
f32 msPerFrame = 1000.0f * (f32)frameTimeInS;
|
f32 msPerFrame = 1000.0f * (f32)frameTimeInS;
|
||||||
f32 framesPerSecond = 1.0f / (f32)frameTimeInS;
|
f32 framesPerSecond = 1.0f / (f32)frameTimeInS;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user