Mercurial > games > semicongine
changeset 860:3586266ba74e
fix: logging output on windows
author | sam <sam@basx.dev> |
---|---|
date | Wed, 27 Dec 2023 16:01:05 +0700 |
parents | a55410a08c63 |
children | 3ba17a9b0c01 |
files | semicongine/platform/windows/audio.nim semicongine/platform/windows/window.nim |
diffstat | 2 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/semicongine/platform/windows/audio.nim Wed Dec 27 14:29:15 2023 +0700 +++ b/semicongine/platform/windows/audio.nim Wed Dec 27 16:01:05 2023 +0700 @@ -1,3 +1,5 @@ +import std/os + import winim import winim/extra @@ -37,7 +39,7 @@ proc writeSoundData*(soundDevice: var NativeSoundDevice, buffer: int) = while (soundDevice.buffers[buffer].dwFlags and WHDR_DONE) == 0: - echo "" # ugly solution to prevent code elimination, need to find a nicer solution + sleep(1) checkWinMMResult waveOutWrite(soundDevice.handle, addr soundDevice.buffers[buffer], UINT(sizeof(WAVEHDR))) proc closeSoundDevice*(soundDevice: var NativeSoundDevice) =
--- a/semicongine/platform/windows/window.nim Wed Dec 27 14:29:15 2023 +0700 +++ b/semicongine/platform/windows/window.nim Wed Dec 27 16:01:05 2023 +0700 @@ -2,6 +2,7 @@ import winim import ../../core/vector +import ../../core/buildconfig import ./virtualkey_map import ../../events @@ -63,6 +64,12 @@ proc createWindow*(title: string): NativeWindow = + when DEBUG: + AllocConsole() + discard stdin.reopen("conIN$", fmRead) + discard stdout.reopen("conOUT$", fmWrite) + discard stderr.reopen("conOUT$", fmWrite) + result.hInstance = HINSTANCE(GetModuleHandle(nil)) var windowClassName = T"EngineWindowClass" @@ -91,7 +98,7 @@ ) result.g_wpPrev.length = UINT(sizeof(WINDOWPLACEMENT)) - discard ShowWindow(result.hwnd, SW_SHOW) + discard result.hwnd.ShowWindow(SW_SHOW) # inspired by the one and only, Raymond Chen # https://devblogs.microsoft.com/oldnewthing/20100412-00/?p=14353