Added VSync
This commit is contained in:
parent
8f130ada92
commit
22e68de4cd
5 changed files with 34 additions and 3 deletions
|
|
@ -150,7 +150,7 @@ class ICUConan(ConanFile):
|
|||
"--disable-samples",
|
||||
])
|
||||
if cross_building(self):
|
||||
base_path = unix_path(self, self.dependencies.build["icu"].package_folder)
|
||||
base_path = unix_path(self, self.dependencies.build["icu-infinipaint"].package_folder)
|
||||
tc.configure_args.append(f"--with-cross-build={base_path}")
|
||||
if self.settings.os in ["iOS", "tvOS", "watchOS"]:
|
||||
# ICU build scripts interpret all Apple platforms as 'darwin'.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "VersionConstants.hpp"
|
||||
#include "cereal/archives/portable_binary.hpp"
|
||||
#include "cereal/details/helpers.hpp"
|
||||
#include <SDL3/SDL_render.h>
|
||||
#include <SDL3/SDL_video.h>
|
||||
#include <chrono>
|
||||
#include <include/core/SkAlphaType.h>
|
||||
#include <include/core/SkColor.h>
|
||||
|
|
@ -251,6 +253,14 @@ void MainProgram::load_config() {
|
|||
NetLibrary::copy_default_p2p_config_to_path(configPath / "p2p.json");
|
||||
}
|
||||
|
||||
void MainProgram::set_vsync_value(int vsyncValue) {
|
||||
if(!SDL_GL_SetSwapInterval(vsyncValue)) {
|
||||
Logger::get().log("INFO", "Vsync value " + std::to_string(vsyncValue) + " not available. Setting to 1");
|
||||
SDL_GL_SetSwapInterval(1);
|
||||
}
|
||||
window.vsyncValue = vsyncValue;
|
||||
}
|
||||
|
||||
void MainProgram::draw(SkCanvas* canvas) {
|
||||
canvas->clear(transparentBackground ? SkColor4f{0.0f, 0.0f, 0.0f, 0.0f} : world->canvasTheme.backColor);
|
||||
world->draw(canvas);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include "DrawData.hpp"
|
||||
#include <SDL3/SDL_render.h>
|
||||
#include <chrono>
|
||||
#include <include/core/SkCanvas.h>
|
||||
#include "InputManager.hpp"
|
||||
|
|
@ -40,6 +41,7 @@ class MainProgram {
|
|||
bool fullscreen = false;
|
||||
SkColorType defaultColorType;
|
||||
SkAlphaType defaultAlphaType;
|
||||
int vsyncValue = 1;
|
||||
|
||||
float scale = 1.0f;
|
||||
|
||||
|
|
@ -91,6 +93,7 @@ class MainProgram {
|
|||
void load_config();
|
||||
|
||||
void init_net_library();
|
||||
void set_vsync_value(int vsyncValue);
|
||||
|
||||
std::filesystem::path homePath;
|
||||
std::filesystem::path configPath;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include "VersionConstants.hpp"
|
||||
#include "World.hpp"
|
||||
#include <SDL3/SDL_dialog.h>
|
||||
#include <SDL3/SDL_render.h>
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
|
@ -225,6 +226,7 @@ nlohmann::json Toolbar::get_config_json() {
|
|||
toRet["jumpTransitionTime"] = jumpTransitionTime;
|
||||
toRet["dragZoomSpeed"] = dragZoomSpeed;
|
||||
toRet["scrollZoomSpeed"] = scrollZoomSpeed;
|
||||
toRet["vsync"] = main.window.vsyncValue;
|
||||
toRet["showPerformance"] = showPerformance;
|
||||
toRet["displayName"] = main.displayName;
|
||||
toRet["useNativeFilePicker"] = useNativeFilePicker;
|
||||
|
|
@ -277,6 +279,13 @@ void Toolbar::set_config_json(const nlohmann::json& j, VersionNumber version) {
|
|||
try{j.at("jumpTransitionTime").get_to(jumpTransitionTime);} catch(...) {}
|
||||
try{j.at("dragZoomSpeed").get_to(dragZoomSpeed);} catch(...) {}
|
||||
try{j.at("scrollZoomSpeed").get_to(scrollZoomSpeed);} catch(...) {}
|
||||
try {
|
||||
j.at("vsync").get_to(main.window.vsyncValue);
|
||||
main.set_vsync_value(main.window.vsyncValue);
|
||||
}
|
||||
catch(...) {
|
||||
main.set_vsync_value(1);
|
||||
}
|
||||
try{j.at("guiScale").get_to(guiScale);} catch(...) {}
|
||||
try{j.at("showPerformance").get_to(showPerformance);} catch(...) {}
|
||||
try{j.at("useNativeFilePicker").get_to(useNativeFilePicker);} catch(...) {}
|
||||
|
|
@ -1416,6 +1425,15 @@ void Toolbar::options_menu() {
|
|||
gui.input_scalar_field("jump transition time", "Jump transition time", &jumpTransitionTime, 0.01f, 1000.0f, 2);
|
||||
gui.checkbox_field("changebrushwidthwithspeed", "Change brush size with mouse speed", &velocityAffectsBrushWidth);
|
||||
gui.input_scalar_field("Max GUI Scale", "Max GUI Scale", &guiScale, 0.5f, 3.0f, 1);
|
||||
|
||||
gui.text_label("VSync:");
|
||||
if(gui.radio_button_field("Vsync On", "On", main.window.vsyncValue == 1))
|
||||
main.set_vsync_value(1);
|
||||
if(gui.radio_button_field("Vsync Off", "Off", main.window.vsyncValue == 0))
|
||||
main.set_vsync_value(0);
|
||||
if(gui.radio_button_field("Vsync Adaptive", "Adaptive", main.window.vsyncValue == -1))
|
||||
main.set_vsync_value(-1);
|
||||
|
||||
gui.pop_id();
|
||||
break;
|
||||
}
|
||||
|
|
@ -1426,7 +1444,7 @@ void Toolbar::options_menu() {
|
|||
gui.input_scalar_field<uint8_t>("middle click", "Middle click pen button", &tabletOptions.middleClickButton, 1, 255);
|
||||
gui.input_scalar_field<uint8_t>("right click", "Right click pen button", &tabletOptions.rightClickButton, 1, 255);
|
||||
#ifdef _WIN32
|
||||
gui.checkbox_field("mouse ignore when pen proximity", "Ignore mouse movement when pen in proximity (may fix some issues on Windows, dont check if not required)", &tabletOptions.ignoreMouseMovementWhenPenInProximity);
|
||||
gui.checkbox_field("mouse ignore when pen proximity", "Ignore mouse movement when pen in proximity", &tabletOptions.ignoreMouseMovementWhenPenInProximity);
|
||||
#endif
|
||||
gui.pop_id();
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ void resize_window(MainStruct& mS) {
|
|||
|
||||
SkSurfaceProps props2;
|
||||
mS.target = GrBackendRenderTargets::MakeGL(mS.m->window.size.x(), mS.m->window.size.y(), 0, mS.kStencilBits, info);
|
||||
mS.surface = SkSurfaces::WrapBackendRenderTarget(mS.ctx.get(), mS.target, kBottomLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, nullptr, &props2);
|
||||
mS.surface = SkSurfaces::WrapBackendRenderTarget(mS.ctx.get(), mS.target, kBottomLeft_GrSurfaceOrigin, kRGBA_8888_SkColorType, SkColorSpace::MakeSRGB(), &props2);
|
||||
|
||||
if(!mS.surface)
|
||||
throw std::runtime_error("[resize_window] Could not make surface");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue