Skip to content

Instantly share code, notes, and snippets.

@mtsamis
mtsamis / SIMD_AABB.md
Created November 21, 2023 16:37
An optimized representation for 2D AABBs and SIMD intrinsics

(Note: This writeup assumes some knowledge of SIMD programming, assembly and AABBs).

Introduction

There are a couple of ways to represent an axis aligned bounding box in 2D, but I think the most common is to store the minimum and maximum coordinates. With this approach, most basic operations (overlap tests, union/intersection, etc.) have simple implementations and offer decent performance.

Some time ago, I came up with a modification to this AABB representation that has the potential for better performance. I haven't seen this technique mentioned or used anywhere, but if you have seen it somehow I would appreciate it if you could let me know.

@futureengine2
futureengine2 / gi.c
Last active June 23, 2024 08:10
Radiance Cascades 2d GI implementation
static void gi_on_gpu(u8* in_bitmap, int w, int h) {
#define num_cascades 7
static bool initialized;
static gpu_bindgroup_t texture_bindgroup[2];
static gpu_bindgroup_t cascade_uniform_bindgroup[num_cascades];
static gpu_bindgroup_t render_uniform_bindgroup;
static gpu_buffer_t vertex_buffer;
static gpu_buffer_t uniform_buffer;
static gpu_pipeline_t pipeline;
@mlabbe
mlabbe / ftg_bitbuffer.h
Last active January 12, 2023 22:22
bitbuffer
/* ftg_bitbuffer - public domain library
no warranty implied; use at your own risk
Tightly pack values by bits into a stream of bytes.
For example, a 1-bit bool and a 32-bit integer are packed into 33
bits.
Bitbuffers are intended for small amounts of data, like a few
hundred network packets where size is important enough to remove
@mlabbe
mlabbe / log.h
Created December 28, 2021 19:49
Barebones code for a structured logger in C
#pragma once
// config
#define LOG_USE_STDIO 1
#define LOG_USE_FILE 0
#define LOG_USE_STRUCTURED 1
#define LOG_LEVEL_TRACE 0
#define LOG_LEVEL_WARN 1
#define LOG_LEVEL_ERROR 2
@dwilliamson
dwilliamson / Text.md
Created December 22, 2021 21:35
Prince of Persia style Character Controller with no Level Markup

Documenting a tiny fraction of the Character Physics/Locomotion/Animation of Advent Shadow for PSP (2004).

The first thing I will say before I start this is; if you can get hold of a guy that can both code and animate stick them in the guts of the implementation and you'll get something that surpasses anything a paired programmer/animator can achieve. Have them responsible for implementing rough first-pass animations and writing the code that drives the animation engine. They might be responsible for final animations here and there, it really depends on your setup. However as far as the code goes, keep them purely on the gameplay side and away from the core technology - you don't want to over-burden them. If you have to use a separate programmer/animator, these guys have to be good. This is not easy stuff and both guys need to be artistic - if you have a programmer who looks at a bunch of moves to implement as a tasklist to be ticked off whenever something is in the game, that's not good enough. The sam

@mmozeiko
mmozeiko / win32_d3d11.c
Last active May 17, 2024 08:42
setting up and using D3D11 in C
// example how to set up D3D11 rendering on Windows in C
#define COBJMACROS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <d3d11.h>
#include <dxgi1_3.h>
#include <d3dcompiler.h>
#include <dxgidebug.h>
@boocs
boocs / readme.md
Last active July 2, 2024 06:51
Removing red squiggles (Intellisense errors) for Unreal Engine

Removing red squiggles (Intellisense errors) for Unreal Engine

This guide should remove all Intellisense errors from your project. I've recently finished a Udemy series and had no problems fixing any Intellisense errors with this guide.

I've tested this in both Visual Studio 2019 and VSCode (Latest Microsoft C++ plugin). They both work. (Windows 10)

Some other compilers, with their version of Intellisense, may still be helped by some of this info.

Note: VSCode was used with Build Tools for Visual Studio 2019
@raysan5
raysan5 / custom_game_engines_small_study.md
Last active July 26, 2024 01:53
A small state-of-the-art study on custom engines

CUSTOM GAME ENGINES: A Small Study

a_plague_tale

A couple of weeks ago I played (and finished) A Plague Tale, a game by Asobo Studio. I was really captivated by the game, not only by the beautiful graphics but also by the story and the locations in the game. I decided to investigate a bit about the game tech and I was surprised to see it was developed with a custom engine by a relatively small studio. I know there are some companies using custom engines but it's very difficult to find a detailed market study with that kind of information curated and updated. So this article.

Nowadays lots of companies choose engines like Unreal or Unity for their games (or that's what lot of people think) because d

@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active July 28, 2024 18:43
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@jspohr
jspohr / microsecs.c
Last active June 2, 2024 18:10
Avoid overflow when converting time to microseconds
// Taken from the Rust code base: https://github.com/rust-lang/rust/blob/3809bbf47c8557bd149b3e52ceb47434ca8378d5/src/libstd/sys_common/mod.rs#L124
// Computes (value*numer)/denom without overflow, as long as both
// (numer*denom) and the overall result fit into i64 (which is the case
// for our time conversions).
int64_t int64MulDiv(int64_t value, int64_t numer, int64_t denom) {
int64_t q = value / denom;
int64_t r = value % denom;
// Decompose value as (value/denom*denom + value%denom),
// substitute into (value*numer)/denom and simplify.
// r < denom, so (denom*numer) is the upper bound of (r*numer)