More updates to the mingw environment
This commit is contained in:
parent
edce7b8ae6
commit
fcb2997e69
4
.clangd
4
.clangd
@ -1,9 +1,9 @@
|
||||
If:
|
||||
PathMatch: [.*\.h, .*\.c]
|
||||
CompileFlags:
|
||||
Add: [-xc, -I/home/edgar/Codes/JacksEscape/easyx/include, -target, x86_64-pc-windows-gnu]
|
||||
Add: [-xc, -DWIN32_LEAN_AND_MEAN, -I/home/edgar/Codes/JacksEscape/easyx/include, -target, x86_64-pc-windows-gnu]
|
||||
---
|
||||
If:
|
||||
PathMatch: [.*\.hpp, .*\.cpp]
|
||||
CompileFlags:
|
||||
Add: [-xc++, -I/home/edgar/Codes/JacksEscape/easyx/include, -target, x86_64-pc-windows-gnu]
|
||||
Add: [-xc++, -DWIN32_LEAN_AND_MEAN, -I/home/edgar/Codes/JacksEscape/easyx/include, -target, x86_64-pc-windows-gnu]
|
||||
|
7
Main.cpp
7
Main.cpp
@ -1,10 +1,17 @@
|
||||
#include <graphics.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Types.h"
|
||||
|
||||
|
||||
int main() {
|
||||
TimePoint startup = time_Now();
|
||||
|
||||
initgraph(640, 480);
|
||||
circle(200, 200, 100);
|
||||
Sleep(5000);
|
||||
closegraph();
|
||||
|
||||
printf("%.6lf seconds has elapsed\n", duration_Seconds(time_Since(startup)));
|
||||
return 0;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ endif
|
||||
|
||||
export INCLUDEFLAGS := $(Platform_INCLUDEFLAGS)
|
||||
|
||||
export CPPFLAGS =
|
||||
export CPPFLAGS = -DWIN32_LEAN_AND_MEAN
|
||||
export CFLAGS = $(INCLUDEFLAGS) $(BUILD_OPTIONS) -O2 -Wno-attributes -flto
|
||||
export CXXFLAGS = $(INCLUDEFLAGS) -DHELOS $(BUILD_OPTIONS) $(Platform_CXXFLAGS) -O2 -Wno-unused-result -flto -std=c++17
|
||||
export LDFLAGS = $(Platform_LDFLAGS) -s -O2 -flto
|
||||
|
26
Types.c
26
Types.c
@ -1,5 +1,6 @@
|
||||
|
||||
#include "Types.h"
|
||||
#include <windows.h>
|
||||
|
||||
static inline double dmin(double x, double y) {
|
||||
return x < y ? x : y;
|
||||
@ -70,9 +71,28 @@ Box2 box2_OffsetY(Box2 box, double offsetY) {
|
||||
}
|
||||
|
||||
|
||||
Duration duration_Now() {
|
||||
// TODO Use Windows.h
|
||||
static double freqInverse = 0.0;
|
||||
|
||||
TimePoint time_Now() {
|
||||
// Reference: https://github.com/SFML/SFML/blob/2.6.x/src/SFML/System/Win32/ClockImpl.cpp
|
||||
Duration d = {.microseconds = 0};
|
||||
|
||||
if (freqInverse == 0.0) {
|
||||
LARGE_INTEGER freq;
|
||||
QueryPerformanceFrequency(&freq);
|
||||
freqInverse = 1000000.0 / ((double)freq.QuadPart);
|
||||
}
|
||||
|
||||
LARGE_INTEGER time;
|
||||
QueryPerformanceCounter(&time);
|
||||
|
||||
TimePoint t = {.microseconds = (int64_t)(((double)time.QuadPart) * freqInverse)};
|
||||
return t;
|
||||
}
|
||||
|
||||
Duration time_Since(TimePoint prev) {
|
||||
return time_Difference(time_Now(), prev);
|
||||
}
|
||||
Duration time_Difference(TimePoint now, TimePoint prev) {
|
||||
Duration d = {.microseconds = now.microseconds - prev.microseconds};
|
||||
return d;
|
||||
}
|
||||
|
15
Types.h
15
Types.h
@ -40,17 +40,20 @@ Box2 box2_OffsetY(Box2 box, double offsetY);
|
||||
|
||||
// Time duration.
|
||||
typedef struct {
|
||||
uint64_t microseconds;
|
||||
int64_t microseconds;
|
||||
} Duration;
|
||||
|
||||
static inline double duration_Seconds(const Duration t) { return ((double)t.microseconds) / 1000.0 / 1000.0; }
|
||||
static inline double duration_Milliseconds(const Duration t) { return ((double)t.microseconds) / 1000.0; }
|
||||
|
||||
// Returns a relative duration since
|
||||
// a static time point in the past.
|
||||
//
|
||||
// Its absolute value has no meaning.
|
||||
Duration duration_Now();
|
||||
// A Time point since the start of the program.
|
||||
typedef struct {
|
||||
int64_t microseconds;
|
||||
} TimePoint;
|
||||
|
||||
TimePoint time_Now();
|
||||
Duration time_Since(TimePoint prev);
|
||||
Duration time_Difference(TimePoint now, TimePoint prev);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
Reference in New Issue
Block a user