will compile on mac but not sure whats wrong
This commit is contained in:
parent
7c5768034f
commit
028dbff64f
6 changed files with 33 additions and 32 deletions
|
@ -360,7 +360,7 @@ namespace K::Graphics {
|
||||||
pack[3] = pack[2] = pack[1] = pack[0] = static_cast<f32>(mode);
|
pack[3] = pack[2] = pack[1] = pack[0] = static_cast<f32>(mode);
|
||||||
|
|
||||||
bgfx::setViewMode(view_id, bgfx::ViewMode::Sequential);
|
bgfx::setViewMode(view_id, bgfx::ViewMode::Sequential);
|
||||||
bgfx::setViewClear(view_id, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH | BGFX_CLEAR_STENCIL);
|
bgfx::setViewClear(view_id, BGFX_CLEAR_COLOR);
|
||||||
bgfx::setViewFrameBuffer(view_id, fb);
|
bgfx::setViewFrameBuffer(view_id, fb);
|
||||||
bgfx::setViewTransform(view_id, composite_view, proj);
|
bgfx::setViewTransform(view_id, composite_view, proj);
|
||||||
bgfx::setViewRect(view_id, 0, 0, w, h);
|
bgfx::setViewRect(view_id, 0, 0, w, h);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <PlugboardNodes.h>
|
#include <PlugboardNodes.h>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace K::PlugboardNodes {
|
namespace K::PlugboardNodes {
|
||||||
std::array<PlugboardGraph::Node*, 20> Nodes = std::to_array<PlugboardGraph::Node*>({
|
std::array<PlugboardGraph::Node*, 20> Nodes = std::to_array<PlugboardGraph::Node*>({
|
||||||
|
|
|
@ -69,9 +69,9 @@ namespace K::UI {
|
||||||
};
|
};
|
||||||
l.track.AddUniform("u_aspect_ratio", ShaderGraph::expand_type(ShaderGraph::T_XY));
|
l.track.AddUniform("u_aspect_ratio", ShaderGraph::expand_type(ShaderGraph::T_XY));
|
||||||
if (s.width > s.height)
|
if (s.width > s.height)
|
||||||
l.track.uniforms[0].val = ShaderGraph::T_Map<ShaderGraph::T_XY>::type(static_cast<f32>(s.width)/static_cast<f32>(s.height), 1.0f);
|
l.track.uniforms[0].val = ShaderGraph::T_Map<ShaderGraph::T_XY>::type{static_cast<f32>(s.width)/static_cast<f32>(s.height), 1.0f};
|
||||||
else
|
else
|
||||||
l.track.uniforms[0].val = ShaderGraph::T_Map<ShaderGraph::T_XY>::type(1.0f, static_cast<f32>(s.height)/static_cast<f32>(s.width));
|
l.track.uniforms[0].val = ShaderGraph::T_Map<ShaderGraph::T_XY>::type{1.0f, static_cast<f32>(s.height)/static_cast<f32>(s.width)};
|
||||||
|
|
||||||
l.track.AddUniform("u_opacity", ShaderGraph::expand_type(ShaderGraph::T_Float));
|
l.track.AddUniform("u_opacity", ShaderGraph::expand_type(ShaderGraph::T_Float));
|
||||||
l.track.uniforms[1].val = ShaderGraph::T_Map<ShaderGraph::T_Float>::type(1.0f);
|
l.track.uniforms[1].val = ShaderGraph::T_Map<ShaderGraph::T_Float>::type(1.0f);
|
||||||
|
@ -80,10 +80,10 @@ namespace K::UI {
|
||||||
l.track.uniforms[2].val = ShaderGraph::T_Map<ShaderGraph::T_Float>::type(.0f);
|
l.track.uniforms[2].val = ShaderGraph::T_Map<ShaderGraph::T_Float>::type(.0f);
|
||||||
|
|
||||||
l.track.AddUniform("u_scale", ShaderGraph::expand_type(ShaderGraph::T_XY));
|
l.track.AddUniform("u_scale", ShaderGraph::expand_type(ShaderGraph::T_XY));
|
||||||
l.track.uniforms[3].val = ShaderGraph::T_Map<ShaderGraph::T_XY>::type(1.0f, 1.0f);
|
l.track.uniforms[3].val = ShaderGraph::T_Map<ShaderGraph::T_XY>::type{1.0f, 1.0f};
|
||||||
|
|
||||||
l.track.AddUniform("u_translate", ShaderGraph::expand_type(ShaderGraph::T_XY));
|
l.track.AddUniform("u_translate", ShaderGraph::expand_type(ShaderGraph::T_XY));
|
||||||
l.track.uniforms[4].val = ShaderGraph::T_Map<ShaderGraph::T_XY>::type(.0f, .0f);
|
l.track.uniforms[4].val = ShaderGraph::T_Map<ShaderGraph::T_XY>::type{.0f, .0f};
|
||||||
|
|
||||||
l.track.shader = "void main() {\n"
|
l.track.shader = "void main() {\n"
|
||||||
"\tfloat angle = -u_rot * M_PI / 180.0f;\n"
|
"\tfloat angle = -u_rot * M_PI / 180.0f;\n"
|
||||||
|
@ -340,7 +340,7 @@ namespace K::UI {
|
||||||
// Perform rendering
|
// Perform rendering
|
||||||
u32 view_count = 0, layers_done = 0;
|
u32 view_count = 0, layers_done = 0;
|
||||||
bgfx::setViewFrameBuffer(Graphics::K_VIEW_COMP_COMPOSITE + view_count, composite_fb[0]); // the other fb will be cleared in composite
|
bgfx::setViewFrameBuffer(Graphics::K_VIEW_COMP_COMPOSITE + view_count, composite_fb[0]); // the other fb will be cleared in composite
|
||||||
bgfx::setViewClear(Graphics::K_VIEW_COMP_COMPOSITE + view_count, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH | BGFX_CLEAR_STENCIL, 0x00000000);
|
bgfx::setViewClear(Graphics::K_VIEW_COMP_COMPOSITE + view_count, BGFX_CLEAR_COLOR, 0x00000000);
|
||||||
bgfx::setViewRect(Graphics::K_VIEW_COMP_COMPOSITE + view_count, 0, 0, s.width, s.height);
|
bgfx::setViewRect(Graphics::K_VIEW_COMP_COMPOSITE + view_count, 0, 0, s.width, s.height);
|
||||||
bgfx::touch(Graphics::K_VIEW_COMP_COMPOSITE + view_count);
|
bgfx::touch(Graphics::K_VIEW_COMP_COMPOSITE + view_count);
|
||||||
view_count++;
|
view_count++;
|
||||||
|
@ -368,7 +368,7 @@ namespace K::UI {
|
||||||
transform);
|
transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImTextureID idx = ImGui::toId(composite[layers_done % 2], 0, 0);
|
ImTextureID idx = ImGui::toId(composite[layers_done % 2], 1, 0);
|
||||||
if (idx != nullptr)
|
if (idx != nullptr)
|
||||||
ImGui::Image(idx, ImVec2{ static_cast<f32>(s.width), static_cast<f32>(s.height) });
|
ImGui::Image(idx, ImVec2{ static_cast<f32>(s.width), static_cast<f32>(s.height) });
|
||||||
|
|
||||||
|
@ -400,7 +400,7 @@ namespace K::UI {
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr u64 TimelineScreenViewToFrame(f32 view_left, f32 view_amt, f32 view_width, f32 view, u64 frame_max) {
|
constexpr u64 TimelineScreenViewToFrame(f32 view_left, f32 view_amt, f32 view_width, f32 view, u64 frame_max) {
|
||||||
return std::clamp(static_cast<u64>(std::round((view / view_width * view_amt + view_left) * static_cast<f32>(frame_max + 1))), 0UL, frame_max);
|
return std::clamp(static_cast<u64>(std::round((view / view_width * view_amt + view_left) * static_cast<f32>(frame_max + 1))), static_cast<u64>(0), frame_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Composition(CompState& s) {
|
void Composition(CompState& s) {
|
||||||
|
@ -1431,6 +1431,7 @@ namespace K::UI {
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||||
ImGui_Implbgfx_Init(K::Graphics::K_VIEW_UI);
|
ImGui_Implbgfx_Init(K::Graphics::K_VIEW_UI);
|
||||||
|
bgfx::setViewClear(Graphics::K_VIEW_UI, BGFX_CLEAR_COLOR);
|
||||||
|
|
||||||
switch (bgfx::getRendererType()) {
|
switch (bgfx::getRendererType()) {
|
||||||
case bgfx::RendererType::Noop:
|
case bgfx::RendererType::Noop:
|
||||||
|
|
|
@ -10,11 +10,11 @@ namespace K {
|
||||||
else if constexpr (std::is_same_v<T, ShaderGraph::T_Map<ShaderGraph::T_Int>::type>)
|
else if constexpr (std::is_same_v<T, ShaderGraph::T_Map<ShaderGraph::T_Int>::type>)
|
||||||
return PlugboardGraph::T_Map<PlugboardGraph::T_Int>::type(arg);
|
return PlugboardGraph::T_Map<PlugboardGraph::T_Int>::type(arg);
|
||||||
else if constexpr (std::is_same_v<T, ShaderGraph::T_Map<ShaderGraph::T_RGBA>::type>)
|
else if constexpr (std::is_same_v<T, ShaderGraph::T_Map<ShaderGraph::T_RGBA>::type>)
|
||||||
return PlugboardGraph::T_Map<PlugboardGraph::T_RGBA>::type(arg.r, arg.g, arg.b, arg.a);
|
return PlugboardGraph::T_Map<PlugboardGraph::T_RGBA>::type{arg.r, arg.g, arg.b, arg.a};
|
||||||
else if constexpr (std::is_same_v<T, ShaderGraph::T_Map<ShaderGraph::T_XY>::type>)
|
else if constexpr (std::is_same_v<T, ShaderGraph::T_Map<ShaderGraph::T_XY>::type>)
|
||||||
return PlugboardGraph::T_Map<PlugboardGraph::T_XY>::type(arg.x, arg.y);
|
return PlugboardGraph::T_Map<PlugboardGraph::T_XY>::type{arg.x, arg.y};
|
||||||
else if constexpr (std::is_same_v<T, ShaderGraph::T_Map<ShaderGraph::T_XYZ>::type>)
|
else if constexpr (std::is_same_v<T, ShaderGraph::T_Map<ShaderGraph::T_XYZ>::type>)
|
||||||
return PlugboardGraph::T_Map<PlugboardGraph::T_XYZ>::type(arg.x, arg.y, arg.z);
|
return PlugboardGraph::T_Map<PlugboardGraph::T_XYZ>::type{arg.x, arg.y, arg.z};
|
||||||
},val);
|
},val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +26,11 @@ namespace K {
|
||||||
else if constexpr (std::is_same_v<T, PlugboardGraph::T_Map<PlugboardGraph::T_Int>::type>)
|
else if constexpr (std::is_same_v<T, PlugboardGraph::T_Map<PlugboardGraph::T_Int>::type>)
|
||||||
return ShaderGraph::T_Map<ShaderGraph::T_Int>::type(arg);
|
return ShaderGraph::T_Map<ShaderGraph::T_Int>::type(arg);
|
||||||
else if constexpr (std::is_same_v<T, PlugboardGraph::T_Map<PlugboardGraph::T_RGBA>::type>)
|
else if constexpr (std::is_same_v<T, PlugboardGraph::T_Map<PlugboardGraph::T_RGBA>::type>)
|
||||||
return ShaderGraph::T_Map<ShaderGraph::T_RGBA>::type(arg.r, arg.g, arg.b, arg.a);
|
return ShaderGraph::T_Map<ShaderGraph::T_RGBA>::type{arg.r, arg.g, arg.b, arg.a};
|
||||||
else if constexpr (std::is_same_v<T, PlugboardGraph::T_Map<PlugboardGraph::T_XY>::type>)
|
else if constexpr (std::is_same_v<T, PlugboardGraph::T_Map<PlugboardGraph::T_XY>::type>)
|
||||||
return ShaderGraph::T_Map<ShaderGraph::T_XY>::type(arg.x, arg.y);
|
return ShaderGraph::T_Map<ShaderGraph::T_XY>::type{arg.x, arg.y};
|
||||||
else if constexpr (std::is_same_v<T, PlugboardGraph::T_Map<PlugboardGraph::T_XYZ>::type>)
|
else if constexpr (std::is_same_v<T, PlugboardGraph::T_Map<PlugboardGraph::T_XYZ>::type>)
|
||||||
return ShaderGraph::T_Map<ShaderGraph::T_XYZ>::type(arg.x, arg.y, arg.z);
|
return ShaderGraph::T_Map<ShaderGraph::T_XYZ>::type{arg.x, arg.y, arg.z};
|
||||||
else if constexpr (std::is_same_v<T, PlugboardGraph::T_Map<PlugboardGraph::T_String>::type>)
|
else if constexpr (std::is_same_v<T, PlugboardGraph::T_Map<PlugboardGraph::T_String>::type>)
|
||||||
return ShaderGraph::T_Map<ShaderGraph::T_Count>::type{};
|
return ShaderGraph::T_Map<ShaderGraph::T_Count>::type{};
|
||||||
},val);
|
},val);
|
||||||
|
@ -39,7 +39,7 @@ namespace K {
|
||||||
void VisualTrack::GetFrame(const CompState& s, u32 view_id, bgfx::FrameBufferHandle fb, u32 w, u32 h, f32 proj[16],
|
void VisualTrack::GetFrame(const CompState& s, u32 view_id, bgfx::FrameBufferHandle fb, u32 w, u32 h, f32 proj[16],
|
||||||
f32 view[16], f32 transform[16]) {
|
f32 view[16], f32 transform[16]) {
|
||||||
bgfx::setViewMode(view_id, bgfx::ViewMode::Sequential);
|
bgfx::setViewMode(view_id, bgfx::ViewMode::Sequential);
|
||||||
bgfx::setViewClear(view_id, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH | BGFX_CLEAR_STENCIL);
|
bgfx::setViewClear(view_id, BGFX_CLEAR_COLOR);
|
||||||
bgfx::setViewFrameBuffer(view_id, fb);
|
bgfx::setViewFrameBuffer(view_id, fb);
|
||||||
|
|
||||||
bgfx::setViewTransform(view_id, view, proj);
|
bgfx::setViewTransform(view_id, view, proj);
|
||||||
|
@ -211,7 +211,7 @@ namespace K {
|
||||||
for (auto& ss : samplers)
|
for (auto& ss : samplers)
|
||||||
if (ss.name == s)
|
if (ss.name == s)
|
||||||
return;
|
return;
|
||||||
uniforms.emplace_back(Uniform(s, bgfx::createUniform(("__" + s).c_str(), bgfx::UniformType::Vec4), val, {nullptr, 0}));
|
uniforms.emplace_back(Uniform{s, bgfx::createUniform(("__" + s).c_str(), bgfx::UniformType::Vec4), val, {nullptr, 0}});
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualTrack::AddSampler(const String& s) {
|
void VisualTrack::AddSampler(const String& s) {
|
||||||
|
@ -221,6 +221,6 @@ namespace K {
|
||||||
for (auto& ss : samplers)
|
for (auto& ss : samplers)
|
||||||
if (ss.name == s)
|
if (ss.name == s)
|
||||||
return;
|
return;
|
||||||
samplers.emplace_back(Sampler(s, bgfx::createUniform(s.c_str(), bgfx::UniformType::Sampler), Resource::fallback_still));
|
samplers.emplace_back(Sampler{s, bgfx::createUniform(s.c_str(), bgfx::UniformType::Sampler), Resource::fallback_still});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include <Resource.h>
|
#include <Resource.h>
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
#include <numbers>
|
||||||
|
|
||||||
#include <bgfx/bgfx.h>
|
#include <bgfx/bgfx.h>
|
||||||
|
|
||||||
|
@ -117,28 +118,25 @@ namespace K::Graphics {
|
||||||
|
|
||||||
void Composite(u32 view_id, bgfx::FrameBufferHandle fb, bgfx::TextureHandle composite, bgfx::TextureHandle from, Blending mode, u16 w, u16 h, f32 proj[16], f32 transform[16]);
|
void Composite(u32 view_id, bgfx::FrameBufferHandle fb, bgfx::TextureHandle composite, bgfx::TextureHandle from, Blending mode, u16 w, u16 h, f32 proj[16], f32 transform[16]);
|
||||||
|
|
||||||
|
constexpr static bool CubicRealAccept(f64 t) {
|
||||||
|
return 0.0 <= t && t <= 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
constexpr static f64 GetCubicUniqueReal(f64 a, f64 b, f64 c, f64 d) {
|
constexpr static f64 GetCubicUniqueReal(f64 a, f64 b, f64 c, f64 d) {
|
||||||
static constexpr auto accept = [](f64 t){ return 0.0 <= t && t <= 1.0; };
|
|
||||||
f64 a1 = b/a, a2 = c/a, a3 = d/a;
|
f64 a1 = b/a, a2 = c/a, a3 = d/a;
|
||||||
f64 Q = (a1 * a1 - 3.0 * a2) / 9.0,
|
f64 Q = (a1 * a1 - 3.0 * a2) / 9.0,
|
||||||
R = (2.0 * a1 * a1 * a1 - 9.0 * a1 * a2 + 27.0 * a3) / 54.0,
|
R = (2.0 * a1 * a1 * a1 - 9.0 * a1 * a2 + 27.0 * a3) / 54.0,
|
||||||
Qcubed = Q * Q * Q,
|
Qcubed = Q * Q * Q,
|
||||||
D = Qcubed - R * R;
|
D = Qcubed - R * R;
|
||||||
|
|
||||||
if (D >= 0) {
|
f64 theta = acos(R / sqrt(Qcubed));
|
||||||
f64 theta = acos(R / sqrt(Qcubed));
|
f64 sqrtQ = sqrt(Q);
|
||||||
f64 sqrtQ = sqrt(Q);
|
f64 r1 = -2.0 * sqrtQ * cos( theta / 3.0) - a1 / 3.0,
|
||||||
f64 r1 = -2.0 * sqrtQ * cos( theta / 3.0) - a1 / 3.0,
|
r2 = -2.0 * sqrtQ * cos((theta + 2.0 * std::numbers::pi) / 3.0) - a1 / 3.0,
|
||||||
r2 = -2.0 * sqrtQ * cos((theta + 2.0 * std::numbers::pi) / 3.0) - a1 / 3.0,
|
r3 = -2.0 * sqrtQ * cos((theta + 4.0 * std::numbers::pi) / 3.0) - a1 / 3.0;
|
||||||
r3 = -2.0 * sqrtQ * cos((theta + 4.0 * std::numbers::pi) / 3.0) - a1 / 3.0;
|
f64 e = std::pow(std::sqrt(-D) + std::abs(R), 1.0 / 3.0);
|
||||||
return accept(r1) ? r1 : (accept(r2) ? r2 : r3);
|
e = (R > 0.0) ? -e : e;
|
||||||
}
|
return D >= 0 ? CubicRealAccept(r1) ? r1 : (CubicRealAccept(r2) ? r2 : r3) : (e + Q / e) - a1 / 3.;
|
||||||
else {
|
|
||||||
f64 e = std::pow(std::sqrt(-D) + std::abs(R), 1.0 / 3.0);
|
|
||||||
if (R > 0.0)
|
|
||||||
e = -e;
|
|
||||||
return (e + Q / e) - a1 / 3.;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr static f64 CubicBezier(f64 a, f64 b, f64 c, f64 d, f64 t) {
|
constexpr static f64 CubicBezier(f64 a, f64 b, f64 c, f64 d, f64 t) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <bgfx/bgfx.h>
|
#include <bgfx/bgfx.h>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <shared_mutex>
|
#include <shared_mutex>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
namespace K::Resource {
|
namespace K::Resource {
|
||||||
extern std::filesystem::path ffmpeg_path;
|
extern std::filesystem::path ffmpeg_path;
|
||||||
|
|
Loading…
Add table
Reference in a new issue