Skip to content

Instantly share code, notes, and snippets.

@ocornut
ocornut / imgui_node_graph_test.cpp
Last active April 23, 2024 19:02
Node graph editor basic demo for ImGui
// Creating a node graph editor for Dear ImGui
// Quick sample, not production code!
// This is quick demo I crafted in a few hours in 2015 showcasing how to use Dear ImGui to create custom stuff,
// which ended up feeding a thread full of better experiments.
// See https://github.com/ocornut/imgui/issues/306 for details
// Fast forward to 2023, see e.g. https://github.com/ocornut/imgui/wiki/Useful-Extensions#node-editors
// Changelog
// - v0.05 (2023-03): fixed for renamed api: AddBezierCurve()->AddBezierCubic().
Wonder Boy: The Dragon's Trap
-----------------------------
Quick Guide for programmers
Last updated October 2018
Contact: Omar Cornut <XXXXXX
===============================================
INDEX
===============================================
@ocornut
ocornut / (Archived) imgui_memory_editor.h
Last active January 1, 2024 04:27
Mini memory editor for dear imgui (to embed in your game/tools)
// Mini memory editor for Dear ImGui (to embed in your game/tools)
// Animated GIF: https://twitter.com/ocornut/status/894242704317530112
// THE MEMORY EDITOR CODE HAS MOVED TO GIT:
// https://github.com/ocornut/imgui_club/tree/master/imgui_memory_editor
// Click "Revisions" on the Gist to see old version.
// My game is using a Japanese font that doesn't seem to declare codepoint for Kanjis for those which only comprised of a simple radical.
// e.g. https://en.wikipedia.org/wiki/Radical_180
// Radical 180 (U+2FB3) ~~ 音 (U+97F3)
// I am remapping the codepoints in software but couldn't find an easy to parse list, ended up scraping from Unicode webpages
{ 0x4E00, 0x2F00 }, // Kangxi Radical One
{ 0x4E28, 0x2F01 }, // Kangxi Radical Line
{ 0x4E36, 0x2F02 }, // Kangxi Radical Dot
{ 0x4E3F, 0x2F03 }, // Kangxi Radical Slash
{ 0x4E59, 0x2F04 }, // Kangxi Radical Second

Last updated 2020/03/04

Some links from twitter on the topic of parsing PSD files (haven't looked into them in details). PSD include a flattened rasterized image so this is easy to load if that's the only thing you need. Most software / librairies have support for extracting this flattened data (e.g. stb_image.h does).

However if you want access to individual layers, render non-rasterized layers, emulate every photoshop features, extract or apply effects with more granularity, more code is needed. May range from easy to lots-of-work depending on what exactly you need.

As far as I know there isn't a trivial stb-like ready-to-use C++ library to do that sort of things. Posting all links here. Some are probably bloated or hard to use into your project, some lacking features.

TODO: Actually look into the pros/cons of all those.

@ocornut
ocornut / printf_tips.cpp
Last active March 24, 2023 11:23
C/C++ tips for using printf-style functions
// C/C++ tips for using printf-style functions
// Lots of manipulation can be expressed simply and fast with printf-style formatting
// Also helps reducing the number of temporaries, memory allocations or copies
// ( If you are looking for a simple C++ string class that is printf-friendly and not heap-abusive,
// I've been using this one: https://github.com/ocornut/Str )
// If you are interested in a FASTER implementation of sprintf functions, see stb_sprintf.h
// https://github.com/nothings/stb/blob/master/stb_sprintf.h
// How to concatenate non-zero terminated strings
// pie menu test
// v0.00
#include <imgui_internal.h>
// Return >= 0 on mouse release
// Optional int* p_selected display and update a currently selected item
int PiePopupSelectMenu(const ImVec2& center, const char* popup_id, const char** items, int items_count, int* p_selected)
{
int ret = -1;
// Test helper for imgui_freetype
#include "misc/freetype/imgui_freetype.h"
struct FreeTypeTest
{
enum FontBuildMode { FontBuildMode_FreeType, FontBuildMode_Stb };
FontBuildMode BuildMode = FontBuildMode_FreeType;
bool WantRebuild = true;
"Modern" C++ Lamentations
Aras Pranckevičius
http://aras-p.info/blog/2018/12/28/Modern-C-Lamentations/
Is C++ fast?
Arseny Kapoulkine
https://zeuxcg.org/2019/01/17/is-c-fast/
Thoughts on Modern C++ and Game Dev