Skip to content

Commit

Permalink
Merge pull request #144 from RandomPrototypes/compat_cpp17_cmake3.16
Browse files Browse the repository at this point in the history
cpp 17 and cmake 3.16 compatibility
  • Loading branch information
smasherprog authored Dec 5, 2022
2 parents 7586bd5 + 8eb6a13 commit 9303bbc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 1 addition & 0 deletions Example_OpenGL/Screen_Capture_Example_OpenGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "ScreenCapture.h"
#include <GLFW/glfw3.h>
#include <iostream>
#include <atomic>
using namespace std::chrono_literals;

void CheckStatus(GLuint obj, bool isShader)
Expand Down
16 changes: 9 additions & 7 deletions src_cpp/ScreenCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,25 @@
#include <cstring>
#include <iostream>
#include <memory>
#include <span>
#include <thread>
#include <type_traits>

namespace SL::Screen_Capture {

template <class MonitorT> 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!!

Expand All @@ -44,7 +46,7 @@ template <class MonitorT> bool IsMonitorInsideBounds(MonitorT monitors, const Mo
return true;
}

bool isMonitorInsideBounds(const std::vector<Monitor> &monitors, const Monitor &monitor) { return IsMonitorInsideBounds(monitors, monitor); }
bool isMonitorInsideBounds(const std::vector<Monitor> &monitors, const Monitor &monitor) { return IsMonitorInsideBounds(monitors.data(), (int)monitors.size(), monitor); }

namespace C_API {

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9303bbc

Please sign in to comment.