Skip to content

Instantly share code, notes, and snippets.

@ocornut
ocornut / rrbits.h
Last active January 6, 2019 22:04 — forked from anonymous/rrbits.h
// Copyright 2008-2015 RAD Game Tools
#ifndef RADRR_BITSH
#define RADRR_BITSH
#include "radtypes.h"
RADDEFSTART
//===================================================================================
@ocornut
ocornut / dualshock4_via_directinput.cpp
Last active October 13, 2020 12:05
// Mapping for PlayStation 4 DualShock 4 (PS4, DS4) controller exposed via DirectInput
// 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[] =

Common game localizations https://docs.google.com/spreadsheets/d/135HgMYcRDt6vnJN0d-xFMEZUeWjVbc61ETf8uVwHERE/edit#gid=339250473

Polyglot Gamedev Project : Master Sheet 0.9.0 https://docs.google.com/spreadsheets/d/17f0dQawb-s_Fd7DHgmVvJoEGDMH_yoSd8EYigrb0zmM/edit#gid=310116733

Game UI common translation https://docs.google.com/spreadsheets/d/197GYEhPpk0DQTEO0r80v_k_bkGVtUgBB08PP--hqCIA/edit#gid=0

Raw text files containing characters used in different languages such as English, French, German, Chinese, Japanese, Korean.

"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
// 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;
// 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;
@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

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.

// 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
@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.