Skip to content

Instantly share code, notes, and snippets.

@Flix01
Flix01 / totp.c
Last active May 22, 2024 19:38 — forked from syzdek/totp.c
totp.c
// Original code: https://gist.github.com/syzdek/eba233ca33e1b5a45a99
// Original code license:
/*
* TOTP: Time-Based One-Time Password Algorithm
* Copyright (c) 2015, David M. Syzdek <david@syzdek.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
@Flix01
Flix01 / imgui_virtual_keyboard.cpp
Last active May 28, 2024 19:49
Complete keyboard prototype for Dear ImGui version 1.87.
/* This code is an extension of the 'keyboard section' present in 'imgui_demo.cpp'.
License is the same (MIT License AFAIK)
*/
#include <imgui_virtual_keyboard.h>
namespace ImGui {
// VirtualKeyboard Implementation
const char** GetKeyboardLogicalLayoutNames() {
@Flix01
Flix01 / mini_mp3_radio_decoder.c
Last active July 9, 2023 06:55
Very basic single-file, plain C, openAL mp3 radio decoder
// gist made after this issue: https://github.com/mackron/dr_libs/issues/142
/*
The license refers to this single file.
Every included or linked library comes with its own license
===============================================================================
Public Domain (www.unlicense.org)
===============================================================================
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
@Flix01
Flix01 / imgui_input_text_multiline_for_std_vector.h.cpp
Created December 12, 2017 13:23
Experimental attempt to create an ImGui::InputTextMultiline(...) for std::strings
// EXPERIMENTAL (ALMOST UNTESTED) InputTextMultiline(...) for std::strings.
// USE IT AT YOUR OWN RISK!
// Example usage:
/*
static std::string text = "Dear ImGui lacks InputTextMultiline(...) for std::string.";
static bool isTextBoxActive = false; // A better implementation should remove this
ImGui::InputTextMultiline("###ADummyLabelForMe",text,isTextBoxActive);
*/
// On Ubuntu, I can compile it with the following command line (provided that imgui.h is two folders up, and that I want to use glfw):
// gcc -o basicExample mainBasic.cpp -I"../../" ../../imgui.cpp ../../imgui_draw.cpp -D"IMGUI_INCLUDE_IMGUI_USER_H" -D"IMGUI_INCLUDE_IMGUI_USER_INL" -I"/usr/include/GLFW" -D"IMGUI_USE_GLFW_BINDING" -L"/usr/lib/x86_64-linux-gnu" -lglfw -lX11 -lm -lGL -lstdc++ -s
// This file is intended to test/answer to https://github.com/Flix01/imgui/issues/15
// RESULT:
// Dynamic enum works!
// And if you can use dynamic_cast<>() making new Node types that use it is easier (non-intrusive)
// Otherwise you must modify the code of CustomEnumEditorNode::render(...) for every new user class you add.
//
// Added also some code to serialize/deserialize the enum names ("TestEnumNames") together
@Flix01
Flix01 / edtaa3func.h
Last active May 26, 2024 19:21
A Signed Distance Font Builder for Dear ImGui
/*
* edtaa3()
*
* Sweep-and-update Euclidean distance transform of an
* image. Positive pixels are treated as object pixels,
* zero or negative pixels are treated as background.
* An attempt is made to treat antialiased edges correctly.
* The input image must have pixels in the range [0,1],
* and the antialiased image should be a box-filter
* sampling of the ideal, crisp edge.
@Flix01
Flix01 / imguiverticaltext.h
Created June 23, 2016 17:23
ImDrawList methods to display vertical text in ImGui
#pragma once
#include <imgui.h>
#include <imgui_internal.h>
// ImDrawList methods to display vertical text
/*
// TEST: inside a window:
ImGuiWindow* window = ImGui::GetCurrentWindow();
ImDrawList* dl = window->DrawList;
@Flix01
Flix01 / imguitabwindow.cpp
Last active August 19, 2023 08:35
ImGui::TabWindow: a self-partitioning ImGui::Window with TabLabels that can be dragged around.
#include "imguitabwindow.h"
#include <imgui_internal.h>
#include <imgui.h> // intellisense
// TODO: Clean this code, it's a mess!
namespace ImGui {
@Flix01
Flix01 / imguitablabel.h
Last active October 12, 2021 22:36
A ImGui::TabLabels(...) that supports line wrapping, tab reordering through drag'n'drop and tab closing through MMB press.
#pragma once
#include <imgui.h>
// USAGE EXAMPLE
/*
ImGui::Text("Tabs (based on the code by krys-spectralpixel):");
static const char* tabNames[] = {"Render","Layers","Scene","World","Object","Constraints","Modifiers","Data","Material","Texture","Particle","Physics"};
static const int numTabs = sizeof(tabNames)/sizeof(tabNames[0]);
static const char* tabTooltips[numTabs] = {"Render Tab Tooltip","","","","Object Type Tooltip","","","","","Tired to add tooltips...",""};
static int tabItemOrdering[numTabs] = {0,1,2,3,4,5,6,7,8,9,10,11};
@Flix01
Flix01 / imguilistview.h
Last active October 13, 2023 23:19
Minimal ListView implementation for ImGui version v1.31
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it
// freely, subject to the following restrictions:
// 1. The origin of this software must not be misrepresented; you must not
// claim that you wrote the original software. If you use this software
// in a product, an acknowledgment in the product documentation would be
// appreciated but is not required.