Skip to content

Instantly share code, notes, and snippets.

@moebiussurfing
moebiussurfing / ofApp.cpp
Created January 16, 2024 01:00
ofParameterGroup callback lambda new api
ofParameterGroup parameters;
ofEventListener listenerParameters;
parameters.add(param1.set("p1", 1.f, 0.f, 10.f));
parameters.add(param2.set("p2", 10.f, 1.f, 50.f));
parameters.add(param3.set("p3", 5, 0, 10));
listenerParameters = parameters.parameterChangedE().newListener([this](ofAbstractParameter& e){
string n = e.getName();
ofLogNotice("ofApp") << "Changed " << n << ": " << e;
@moebiussurfing
moebiussurfing / .cpp
Last active November 21, 2023 22:18
ofApp.cpp grouped callbacks pattern
// ofApp.h
ofParameterGroup params{"Params"};
void Changed_Params(ofAbstractParameter &e);
ofParameter<bool> bAnimate;
ofParameter<void> bRefresh;
ofParameter<float> size;
@moebiussurfing
moebiussurfing / toolbar.cpp
Created July 29, 2021 05:47 — forked from rmitton/toolbar.cpp
How to do a toolbar in Dear ImGui.
// How to do a toolbar in Dear ImGui.
const float toolbarSize = 50;
void DockSpaceUI()
{
ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->Pos + ImVec2(0, toolbarSize));
ImGui::SetNextWindowSize(viewport->Size - ImVec2(0, toolbarSize));
ImGui::SetNextWindowViewport(viewport->ID);
@moebiussurfing
moebiussurfing / ImGuiDockspaceExample.cpp
Created July 29, 2021 05:43 — forked from AidanSun05/ImGuiDockspaceExample.cpp
A modified DockSpace example for Dear ImGui. Changes are listed at the top of the file.
// CHANGES MADE:
// Added more clarifying comments inside the function.
// Removed MSVC warning C6011 - null pointer dereference.
// Fixed a slight grammar error - "This demo app only demonstrate" => "This demo app only demonstrates"
// Demonstrate using DockSpace() to create an explicit docking node within an existing window.
// Note: You can use most Docking facilities without calling any API. You DO NOT need to call DockSpace() to use Docking!
// - Drag from window title bar or their tab to dock/undock. Hold SHIFT to disable docking.
// - Drag from window menu button (upper-left button) to undock an entire node (all windows).
// About dockspaces:
@moebiussurfing
moebiussurfing / dock_builder_example.cpp
Created July 29, 2021 03:36 — forked from PossiblyAShrub/dock_builder_example.cpp
Simple example, of how to use the dock builder API. (Adapted from the dock space example in the demo window) You need to use the docking branch and set the ImGuiConfigFlags_DockingEnable config flag. Learn more about Dear ImGui here: https://github.com/ocornut/imgui
static ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_PassthruCentralNode;
// We are using the ImGuiWindowFlags_NoDocking flag to make the parent window not dockable into,
// because it would be confusing to have two docking targets within each others.
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->Pos);
ImGui::SetNextWindowSize(viewport->Size);
ImGui::SetNextWindowViewport(viewport->ID);
@moebiussurfing
moebiussurfing / ffmpeg-hap-readme.md
Created July 20, 2021 01:33 — forked from dlublin/ffmpeg-hap-readme.md
Encoding to Hap from the command line using FFmpeg

Encoding to Hap from the command line using FFmpeg

For users who prefer working with a command line or need to access advanced encoding settings for Hap the popular FFmpeg library can be used to work with Hap movies.

  1. If this is your first time using FFmpeg you may need to install it on your system, or compile it from source. In either case be sure that Snappy is enabled as part of the binary. If you already have FFmpeg on your system with Snappy enabled, you can skip this step.

    You can check that your version of FFmpeg can encode Hap using

    ffmpeg -encoders | grep hap
    
@moebiussurfing
moebiussurfing / ffmpeg.md
Created July 15, 2021 22:07 — forked from liangfu/ffmpeg.md
using ffmpeg to extract audio from video files

ffmpeg

Converting Audio into Different Formats / Sample Rates

Minimal example: transcode from MP3 to WMA:
ffmpeg -i input.mp3 output.wma

You can get the list of supported formats with:
ffmpeg -formats

Convert WAV to MP3, mix down to mono (use 1 audio channel), set bit rate to 64 kbps and sample rate to 22050 Hz:

@moebiussurfing
moebiussurfing / imgui_color_gradient.cpp
Created June 27, 2021 20:42 — forked from galloscript/imgui_color_gradient.cpp
Gradient color generator and editor for ImGui
//
// imgui_color_gradient.cpp
// imgui extension
//
// Created by David Gallardo on 11/06/16.
#include "imgui_color_gradient.h"
#include "imgui_internal.h"
namespace ImGui
{
static bool SelectFile(const std::string &path, std::string &selected, const std::vector<std::string> &ext={}) {
bool ret = false;
if(ofFile(path).isDirectory()) {
if(TreeNode(ofFilePath::getBaseName(path).c_str())) {
ofDirectory dir;
if(!ext.empty()) {
dir.allowExt("");
for(auto &&e : ext) {
@moebiussurfing
moebiussurfing / ofApp.cpp
Last active March 9, 2021 03:10
ImGui layout widgets filling width
if (ofxImGui::BeginWindow("TEST", mainSettings, flags)){
ImGui::BeginGroup();
{
int numRows = 2;
int numWidgets = 3;
float spcx =ImGui::GetStyle().ItemSpacing.x;
float spcy =ImGui::GetStyle().ItemSpacing.y;
float maxWidth = ImGui::GetContentRegionAvail().x - spcx;