From 8eb6a13630986ea06e8ae0d65a12b63fb5071e0f Mon Sep 17 00:00:00 2001 From: RandomPrototypes Date: Sun, 4 Dec 2022 16:10:04 +0900 Subject: [PATCH] make it compatible with cpp 17 and cmake 3.16 --- CMakeLists.txt | 4 ++-- Example_OpenGL/Screen_Capture_Example_OpenGL.cpp | 1 + src_cpp/ScreenCapture.cpp | 16 +++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d646b23f..5abf45fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 3.20) +cmake_minimum_required(VERSION 3.16) project(screen_capture_lite_build) -set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) option(BUILD_EXAMPLE "Build example" ON) diff --git a/Example_OpenGL/Screen_Capture_Example_OpenGL.cpp b/Example_OpenGL/Screen_Capture_Example_OpenGL.cpp index 6811920a..0a29ed08 100644 --- a/Example_OpenGL/Screen_Capture_Example_OpenGL.cpp +++ b/Example_OpenGL/Screen_Capture_Example_OpenGL.cpp @@ -3,6 +3,7 @@ #include "ScreenCapture.h" #include #include +#include using namespace std::chrono_literals; void CheckStatus(GLuint obj, bool isShader) diff --git a/src_cpp/ScreenCapture.cpp b/src_cpp/ScreenCapture.cpp index b20f7cb4..65963459 100644 --- a/src_cpp/ScreenCapture.cpp +++ b/src_cpp/ScreenCapture.cpp @@ -7,23 +7,25 @@ #include #include #include -#include #include #include namespace SL::Screen_Capture { -template bool IsMonitorInsideBounds(MonitorT monitors, const Monitor &monitor) +bool IsMonitorInsideBounds(const Monitor *monitors, const int monitorsize, const Monitor &monitor) { auto totalwidth = 0; - for (auto &m : monitors) { - totalwidth += Width(m); + for (int i = 0; i < monitorsize; i++) { + totalwidth += Width(monitors[i]); } // if the monitor doesnt exist any more! - if (std::find_if(begin(monitors), end(monitors), [&](auto &m) { return m.Id == monitor.Id; }) == end(monitors)) { + int index = 0; + while(index < monitorsize && monitors[index].Id != monitor.Id) + index++; + if (index == monitorsize) { return false; } // if the area to capture is outside the dimensions of the desktop!! @@ -44,7 +46,7 @@ template bool IsMonitorInsideBounds(MonitorT monitors, const Mo return true; } -bool isMonitorInsideBounds(const std::vector &monitors, const Monitor &monitor) { return IsMonitorInsideBounds(monitors, monitor); } +bool isMonitorInsideBounds(const std::vector &monitors, const Monitor &monitor) { return IsMonitorInsideBounds(monitors.data(), (int)monitors.size(), monitor); } namespace C_API { @@ -272,7 +274,7 @@ int SCL_GetWindows(SCL_WindowRef windows, int monitors_size) int SCL_IsMonitorInsideBounds(SCL_MonitorRefConst monitors, const int monitorsize, SCL_MonitorRefConst monitor) { - return int(IsMonitorInsideBounds(std::span(monitors, monitorsize), *monitor)); + return int(IsMonitorInsideBounds(monitors, monitorsize, *monitor)); } void SCL_MonitorOnNewFrame(SCL_ICaptureConfigurationScreenCaptureCallbackWrapperRef ptr, SCL_ScreenCaptureCallback cb)