diff --git a/CMakeLists.txt b/CMakeLists.txt index c6055e2..e297a5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,11 +19,6 @@ include(cmake/FindSDL2_mixer.cmake) include(cmake/FindCCache.cmake) include(cmake/Findcppcheck.cmake) -if (NOT WIN32) - include(FindX11) - include(cmake/FindCheck.cmake) -endif (NOT WIN32) - configure_file( "${PROJECT_SOURCE_DIR}/src/config.h.in" "${PROJECT_BINARY_DIR}/config.h" @@ -73,11 +68,6 @@ include_directories( ${SDL2_MIXER_INCLUDE_DIR} ) -if (NOT WIN32) - include_directories( - ${X11_INCLUDE_DIR} - ) -endif (NOT WIN32) if (CHECK_FOUND) include_directories( ${CHECK_INCLUDE_DIR} @@ -163,12 +153,6 @@ else (NOT PHYSFS_FOUND) ) endif (NOT PHYSFS_FOUND) -if (NOT WIN32) - target_link_libraries(breakhack - ${X11_LIBRARIES} - ) -endif (NOT WIN32) - if (MSVC) set_target_properties(breakhack PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE") set_target_properties(breakhack PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE") diff --git a/src/main.c b/src/main.c index 5a856ba..c69f129 100644 --- a/src/main.c +++ b/src/main.c @@ -92,6 +92,13 @@ static bool initSDL(void) { int imgFlags = IMG_INIT_PNG; + + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) + { + error("Could not initiate SDL2: %s", SDL_GetError()); + return false; + } + Dimension dim = getScreenDimensions(); if (dim.height > 1080) { @@ -104,12 +111,6 @@ bool initSDL(void) info("Scaling by %f", renderScale); } - if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) - { - error("Could not initiate SDL2: %s", SDL_GetError()); - return false; - } - if ( (IMG_Init(imgFlags) & imgFlags) == 0 ) { error("Unable to initiate img loading: %s", IMG_GetError()); diff --git a/src/screenresolution.c b/src/screenresolution.c index ae60cb7..c26d22b 100644 --- a/src/screenresolution.c +++ b/src/screenresolution.c @@ -17,28 +17,20 @@ */ #include "defines.h" +#include "util.h" -#ifndef _WIN32 -#include -#else // _WIN32 -#include -#endif // _WIN32 -#include +#include #include "screenresolution.h" Dimension getScreenDimensions(void) { -#ifndef _WIN32 - Display *d = XOpenDisplay(NULL); - Screen *s = DefaultScreenOfDisplay(d); - Dimension dim = (Dimension) { s->width, s->height }; - - free(d); - free(s); -#else // _WIN32 - Dimension dim = (Dimension) { GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN) }; -#endif // _WIN32 + SDL_DisplayMode dm; + if (SDL_GetCurrentDisplayMode(0, &dm) != 0) + { + error("SDL_GetDesktopDisplayMode failed: %s", SDL_GetError()); + } + Dimension dim = (Dimension) { dm.w, dm.h }; return dim; }