Skip to content

Instantly share code, notes, and snippets.

omar ocornut

Block or report user

Report or block ocornut

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Articles & resources on the issues with Modern C++.txt
"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
View imgui_io_queue.cpp
// DRAFT
// [Internal]
enum ImGuiIoEventType
{
ImGuiIoEventType_Unknown = 0,
ImGuiIoEventType_MousePos,
ImGuiIoEventType_MouseButton,
ImGuiIoEventType_MouseWheel,
};
@ocornut
ocornut / dualshock4_via_directinput.cpp
Last active May 28, 2017
// Mapping for PlayStation 4 DualShock 4 (PS4, DS4) controller exposed via DirectInput
View dualshock4_via_directinput.cpp
// FYI the numbers here don't make much sense out of context
// I am using https://github.com/ThemsAllTook/libstem_gamepad which remaps xinput and dinput states to arrays of button + arrays of axises.
// So those are my tables to read back from them and handle DS4 which provide dinput data.
// The PAD_*** enums are mine, the AXIS_*** enums tells which remapping function to use on the float data.
// You may prefer to handle the axises data in a different manner (e.g. some people like the analog trigger to go -1 to +1, I'm using 0 to 1).
// This is merely a loose reference to get you started if you want to support DS4 in your application.
// Mapping for PlayStation 4 DualShock 4 (PS4, DS4) controller exposed via DInput.
// VendorId = 0x0000054C, ProductId = 0x000009CC
static const GamePadMappingEntry g_DInputDS4Mapping[] =
View Kanji to Kangxi Radical remapping tables
// 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
View imgui_pie_menu_test.cpp
// 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;
View PSD parsing resources.md

Last updated 2017/06/01

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.

View rrbits.h
// Copyright 2008-2015 RAD Game Tools
#ifndef RADRR_BITSH
#define RADRR_BITSH
#include "radtypes.h"
RADDEFSTART
//===================================================================================
@ocornut
ocornut / imgui_node_graph_test.cpp
Last active Nov 21, 2019
Node graph editor basic demo for ImGui
View imgui_node_graph_test.cpp
// Creating a node graph editor for ImGui
// Quick demo, not production code! This is more of a demo of how to use ImGui to create custom stuff.
// Better version by @daniel_collin here https://gist.github.com/emoon/b8ff4b4ce4f1b43e79f2
// See https://github.com/ocornut/imgui/issues/306
// v0.03: fixed grid offset issue, inverted sign of 'scrolling'
// Animated gif: https://cloud.githubusercontent.com/assets/8225057/9472357/c0263c04-4b4c-11e5-9fdf-2cd4f33f6582.gif
#include <math.h> // fmodf
// NB: You can use math functions/operators on ImVec2 if you #define IMGUI_DEFINE_MATH_OPERATORS and #include "imgui_internal.h"
You can’t perform that action at this time.