Skip to content

Commit

Permalink
Hopefully fixes the high performance usage
Browse files Browse the repository at this point in the history
  • Loading branch information
kuroni committed Dec 25, 2020
1 parent a9ae502 commit c2cddb6
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#include "header.hpp"

#if defined(__unix__) || defined(__unix)
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#else
#if !defined(__unix__) && !defined(__unix)
#include <windows.h>
#endif

Expand All @@ -16,28 +13,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
#endif

window.create(sf::VideoMode(612, 352), "Bongo Cat for osu!", sf::Style::Titlebar | sf::Style::Close);

// get refresh rate and set the frame limit
#if defined(__unix__) || defined(__unix)
Display *dpy = XOpenDisplay(NULL);
Window root = RootWindow(dpy, 0);

XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root);
short refresh_rate = XRRConfigCurrentRate(conf);

XCloseDisplay(dpy);
window.setFramerateLimit(refresh_rate);
#else
DISPLAY_DEVICE device;
ZeroMemory(&device, sizeof(device));
device.cb = sizeof(device);
EnumDisplayDevices(NULL, (DWORD)0, &device, 0);
DEVMODE devmode;
ZeroMemory(&devmode, sizeof(DEVMODE));
devmode.dmSize = sizeof(DEVMODE);
EnumDisplaySettings((LPSTR)device.DeviceName, ENUM_REGISTRY_SETTINGS, &devmode);
window.setFramerateLimit(devmode.dmDisplayFrequency);
#endif
window.setFramerateLimit(60);

// loading configs
while (!data::init()) {
Expand Down

0 comments on commit c2cddb6

Please sign in to comment.