In an IMGUI we need a way to identify which control is active
or hot
. For example,
when we press a key, which text box does the text go to.
Possible options:
- Sequential number (Unity)
Each control drawn gets a sequentially increasing number.
/* | |
Cached Factory | |
Sometimes you want to make objects with a lifetime managed | |
by their target owner but you also want to hold reference | |
to them in a custom cache. The target owner, naturally, will | |
be given a shared_ptr to the output object. However, we don't | |
want the lifetime of the output object to be tied to the | |
internal cache. I.e. if the owner dies then the object should | |
die even if referenced in the cache. |
#include <SDL2/SDL.h> | |
#include <SDL2/SDL_syswm.h> | |
#include <bgfx/bgfx.h> | |
#include <bgfx/platform.h> | |
#include <bx/bx.h> | |
#include <bx/mutex.h> | |
#include <bx/thread.h> | |
void threadInit() | |
{ |
#ifndef RECURSIVE_recursive_generator | |
#define RECURSIVE_recursive_generator | |
#include <experimental/coroutine> | |
// This class implements delegating (potentially recursive) recursive_generator. | |
// It supports two kind of yield expressions: | |
// | |
// co_yield V; | |
// co_yield G_of_T; |
#include "SDL.h" | |
#include <windows.h> | |
int main(int argc, char *argv[]) { | |
const SDL_MessageBoxButtonData buttons[] = { | |
{ /* .flags, .buttonid, .text */ 0, 0, "no" }, | |
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 1, "yes" }, | |
{ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, 2, "cancel" }, | |
}; | |
const SDL_MessageBoxColorScheme colorScheme = { |
What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.
In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.
Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th
// | |
// Basic instrumentation profiler by Cherno | |
// Usage: include this header file somewhere in your code (eg. precompiled header), and then use like: | |
// | |
// Instrumentor::Get().BeginSession("Session Name"); // Begin session | |
// { | |
// InstrumentationTimer timer("Profiled Scope Name"); // Place code like this in scopes you'd like to include in profiling | |
// // Code | |
// } |
/* | |
* Test the new ASAN feature of MSVC (ripped from clang presumably). | |
* | |
* Ref: | |
* https://devblogs.microsoft.com/cppblog/addresssanitizer-asan-for-windows-with-msvc/ | |
*/ | |
#include <stdlib.h> | |
/* | |
* Ref 'https://github.com/google/sanitizers/wiki/AddressSanitizerFlags' |
#pragma once | |
#include "core.hh" | |
// | |
// Entities | |
// | |
using Entity = entt::entity; | |
inline constexpr auto nullEntity = entt::null; |