Fix compiling on both MSVC & mingw32
Turns out easyX is different on MSVC and mingw32
This commit is contained in:
parent
0d44ce87ff
commit
8bf4d95384
@ -104,6 +104,7 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@ -118,6 +119,7 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@ -127,9 +129,17 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Physics_Component.h" />
|
||||
<ClInclude Include="Entity.h" />
|
||||
<ClInclude Include="Types.h" />
|
||||
<ClInclude Include="app.h" />
|
||||
<ClInclude Include="camera.h" />
|
||||
<ClInclude Include="entity.h" />
|
||||
<ClInclude Include="input.h" />
|
||||
<ClInclude Include="particle.h" />
|
||||
<ClInclude Include="physics.h" />
|
||||
<ClInclude Include="player.h" />
|
||||
<ClInclude Include="render_pattern.h" />
|
||||
<ClInclude Include="render_util.h" />
|
||||
<ClInclude Include="types.h" />
|
||||
<ClInclude Include="util\assert.h" />
|
||||
<ClInclude Include="util\minmax.h" />
|
||||
<ClInclude Include="util\queue.h" />
|
||||
<ClInclude Include="util\tree.h" />
|
||||
@ -137,9 +147,21 @@
|
||||
<ClInclude Include="util\vector.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Types.c" />
|
||||
<ClCompile Include="Physics_Component.c" />
|
||||
<ClCompile Include="Physics_Move.c" />
|
||||
<ClCompile Include="app.c" />
|
||||
<ClCompile Include="app_debug.c" />
|
||||
<ClCompile Include="app_render.cpp" />
|
||||
<ClCompile Include="camera.c" />
|
||||
<ClCompile Include="entity.c" />
|
||||
<ClCompile Include="input.c" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="particle.c" />
|
||||
<ClCompile Include="particle_render.cpp" />
|
||||
<ClCompile Include="physics.c" />
|
||||
<ClCompile Include="physics_move.c" />
|
||||
<ClCompile Include="player.c" />
|
||||
<ClCompile Include="render_pattern.c" />
|
||||
<ClCompile Include="render_util.cpp" />
|
||||
<ClCompile Include="types.c" />
|
||||
<ClCompile Include="util\queue.c" />
|
||||
<ClCompile Include="util\tree.c" />
|
||||
<ClCompile Include="util\vector.c" />
|
||||
|
@ -33,13 +33,37 @@
|
||||
<ClInclude Include="util\vector.h">
|
||||
<Filter>Util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Entity.h">
|
||||
<ClInclude Include="util\assert.h">
|
||||
<Filter>Util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="app.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Physics_Component.h">
|
||||
<ClInclude Include="camera.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Types.h">
|
||||
<ClInclude Include="entity.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="input.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="particle.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="physics.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="player.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="render_pattern.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="render_util.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="types.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
@ -53,13 +77,49 @@
|
||||
<ClCompile Include="util\vector.c">
|
||||
<Filter>Util</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Types.c">
|
||||
<ClCompile Include="app.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Physics_Component.c">
|
||||
<ClCompile Include="app_debug.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Physics_Move.c">
|
||||
<ClCompile Include="camera.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="entity.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="input.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="particle.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="physics.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="physics_move.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="player.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="render_pattern.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="types.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="app_render.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="main.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="particle_render.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="render_util.cpp">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
6
main.cpp
6
main.cpp
@ -15,11 +15,17 @@ int main() {
|
||||
lastFrame = lastUpdate = frameCounter = time_Now();
|
||||
int frameCount = 0;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
SetProcessDPIAware();
|
||||
#endif
|
||||
HWND win = initgraph(SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
SetWindowTextA(win, "JacksEscape");
|
||||
|
||||
#ifdef __MINGW32__
|
||||
settextstyle(TEXTHEIGHT, 0, "Courier New");
|
||||
#else // MSVC
|
||||
settextstyle(TEXTHEIGHT, 0, L"Courier New");
|
||||
#endif
|
||||
vector_Vector *debugText = vector_Create(1);
|
||||
|
||||
App *app = app_NewApp();
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// for BYTE
|
||||
#include <minwindef.h>
|
||||
#include <windows.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -17,12 +17,18 @@ extern "C" {
|
||||
|
||||
static vector_Vector *tbuf;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
#define NCHAR char
|
||||
#else
|
||||
#define NCHAR wchar_t
|
||||
#endif
|
||||
|
||||
void render_DrawText(int x, int y, const char *str) {
|
||||
if (!tbuf)
|
||||
tbuf = vector_Create(1);
|
||||
tbuf = vector_Create(sizeof(NCHAR));
|
||||
|
||||
int cx = x, cy = y;
|
||||
const char zero = 0;
|
||||
int cx = x, cy = y;
|
||||
const NCHAR zero = 0;
|
||||
|
||||
vector_Clear(tbuf);
|
||||
int len = strlen(str);
|
||||
@ -34,8 +40,10 @@ void render_DrawText(int x, int y, const char *str) {
|
||||
|
||||
cy += TEXTHEIGHT;
|
||||
vector_Clear(tbuf);
|
||||
} else
|
||||
vector_Push(tbuf, &str[i]);
|
||||
} else {
|
||||
NCHAR wc = str[i];
|
||||
vector_Push(tbuf, &wc);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -77,7 +85,7 @@ void render_SetModes(FillMode mode, TimePoint since) {
|
||||
|
||||
if (mode.rotate.microseconds != 0) {
|
||||
// Rotate mode
|
||||
int steps = round(duration_Seconds(time_Since(since)) / duration_Seconds(mode.rotate));
|
||||
int steps = (int)round(duration_Seconds(time_Since(since)) / duration_Seconds(mode.rotate));
|
||||
|
||||
static const long hatches[] = {HS_HORIZONTAL, HS_FDIAGONAL, HS_VERTICAL, HS_BDIAGONAL};
|
||||
setfillstyle(BS_HATCHED, hatches[steps % 4], NULL);
|
||||
|
4
types.c
4
types.c
@ -115,8 +115,8 @@ static ZwSetTimerResolution_Type ZwSetTimerResolution;
|
||||
|
||||
void duration_Sleep(const Duration t) {
|
||||
if (!NtDelayExecution) {
|
||||
NtDelayExecution = (NtDelayExecution_Type)GetProcAddress(GetModuleHandle("ntdll.dll"), "NtDelayExecution");
|
||||
ZwSetTimerResolution = (ZwSetTimerResolution_Type)GetProcAddress(GetModuleHandle("ntdll.dll"), "ZwSetTimerResolution");
|
||||
NtDelayExecution = (NtDelayExecution_Type)GetProcAddress(GetModuleHandleA("ntdll.dll"), "NtDelayExecution");
|
||||
ZwSetTimerResolution = (ZwSetTimerResolution_Type)GetProcAddress(GetModuleHandleA("ntdll.dll"), "ZwSetTimerResolution");
|
||||
|
||||
// Only run this once
|
||||
ULONG actualResolution;
|
||||
|
Loading…
Reference in New Issue
Block a user