@@ -176,6 +176,10 @@ int main() {
176176 #define RGFW_USERPTR NULL
177177#endif
178178
179+ #ifndef RGFW_ROUND
180+ #define RGFW_ROUND (x ) (int)((x) >= 0 ? (x) + 0.5f : (x) - 0.5f)
181+ #endif
182+
179183#ifndef RGFW_ALLOC
180184 #include <stdlib.h>
181185
@@ -1263,7 +1267,6 @@ typedef RGFW_ENUM(u8, RGFW_mouseIcons) {
12631267
12641268#include <string.h>
12651269
1266- #include <math.h>
12671270#include <assert.h>
12681271
12691272/*
@@ -1815,7 +1818,7 @@ u32 RGFW_window_checkFPS(RGFW_window* win, u32 fpsCap) {
18151818 u64 deltaTime = RGFW_getTimeNS () - win -> event .frameTime ;
18161819
18171820 u32 output_fps = 0 ;
1818- u64 fps = round (1e+9 / deltaTime );
1821+ u64 fps = RGFW_ROUND (1e+9 / deltaTime );
18191822 output_fps = fps ;
18201823
18211824 if (fpsCap && fps > fpsCap ) {
@@ -1834,7 +1837,7 @@ u32 RGFW_window_checkFPS(RGFW_window* win, u32 fpsCap) {
18341837 return (u32 ) output_fps ;
18351838
18361839 deltaTime = RGFW_getTimeNS () - win -> event .frameTime2 ;
1837- output_fps = round (1e+9 / deltaTime );
1840+ output_fps = RGFW_ROUND (1e+9 / deltaTime );
18381841 win -> event .frameTime2 = RGFW_getTimeNS ();
18391842
18401843 return output_fps ;
@@ -3860,7 +3863,7 @@ static float XGetSystemContentDPI(Display* display, i32 screen) {
38603863 XrmDestroyDatabase (db );
38613864 }
38623865 #else
3863- dpi = roundf (DisplayWidth (display , screen ) / (DisplayWidthMM (display , screen ) / 25.4 ));
3866+ dpi = RGFW_ROUND (DisplayWidth (display , screen ) / (DisplayWidthMM (display , screen ) / 25.4 ));
38643867 #endif
38653868
38663869 return dpi ;
@@ -3891,8 +3894,8 @@ RGFW_monitor RGFW_XCreateMonitor(i32 screen) {
38913894 ci = XRRGetCrtcInfo (display , sr , sr -> crtcs [crtc ]);
38923895 }
38933896
3894- float ppi_width = round ((float )monitor .rect .w /(float )monitor .physW );
3895- float ppi_height = round ((float )monitor .rect .h /(float )monitor .physH );
3897+ float ppi_width = RGFW_ROUND ((float )monitor .rect .w /(float )monitor .physW );
3898+ float ppi_height = RGFW_ROUND ((float )monitor .rect .h /(float )monitor .physH );
38963899
38973900 monitor .scaleX = (float ) (ppi_width ) / dpi ;
38983901 monitor .scaleY = (float ) (ppi_height ) / dpi ;
@@ -3934,8 +3937,8 @@ RGFW_monitor RGFW_XCreateMonitor(i32 screen) {
39343937 monitor .scaleX = 0 ;
39353938 monitor .scaleY = 0 ;
39363939 } else {
3937- float ppi_width = round ((float )monitor .rect .w /(float )monitor .physW );
3938- float ppi_height = round ((float )monitor .rect .h /(float )monitor .physH );
3940+ float ppi_width = RGFW_ROUND ((float )monitor .rect .w /(float )monitor .physW );
3941+ float ppi_height = RGFW_ROUND ((float )monitor .rect .h /(float )monitor .physH );
39393942
39403943 monitor .scaleX = (float ) (ppi_width ) / (float ) dpi ;
39413944 monitor .scaleY = (float ) (ppi_height ) / (float ) dpi ;
0 commit comments