Skip to content

Instantly share code, notes, and snippets.

public unsafe class UnmanagedMemoryPoolManager
{
#if UNMANAGED_MEMORY_DEBUG
/// <summary>
/// Value added to the end of an <see cref="UnmanagedMemoryPool"/> block. Used to detect
/// out-of-bound memory writes.
/// </summary>
private const ulong SentinelValue = 0x8899AABBCCDDEEFF;
#endif
@prime31
prime31 / ldtk.zig
Created November 4, 2023 23:57
LDtk export from json schema
pub const Ld = struct {
description: []const u8,
title: []const u8,
// renamed from: "$schema
schema: []const u8,
// renamed from: "$ref
ref: []const u8,
version: []const u8,
// renamed from: "LdtkJsonRoot
ldtk_json_root: LdtkJsonRoot,
@prime31
prime31 / glowy.wgsl
Created March 28, 2023 14:34
Bevy Material Example
#import bevy_pbr::mesh_view_bindings
#import bevy_pbr::mesh_bindings
#import bevy_pbr::pbr_types
#import bevy_pbr::utils
#import bevy_pbr::clustered_forward
#import bevy_pbr::lighting
#import bevy_pbr::shadows
#import bevy_pbr::pbr_functions
@prime31
prime31 / Blobs.cs
Created March 17, 2021 23:07
Unmanaged Resources
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Nez.Unmanaged
{
unsafe public struct BlobAllocator : IDisposable
{
byte* m_RootPtr;
@prime31
prime31 / Program.cs
Last active May 16, 2024 11:27
C# Basic ECS implementation example. Not production ready, optimized or even fully functional. It is here to illustrate the patterns for creating an ECS from scratch.
using System;
namespace SimpleECS
{
struct Position
{
public float X, Y;
}
struct Velocity
@prime31
prime31 / FilePicker.cs
Last active January 13, 2026 09:18
Simple file and folder picker for ImGui.Net
using ImGuiNET;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using Num = System.Numerics;
namespace Nez.ImGuiTools
{
public class FilePicker
const int C2_GJK_ITERS = 20;
public const int C2_MAX_POLYGON_VERTS = 8;
// position of impact p = ray.p + ray.d * raycast.t
public static c2v c2Impact(c2Ray ray, float t) => c2Add(ray.p, c2Mulvs(ray.d, t));
#region Wrapper Methods
public static unsafe bool c2Collided(void* A, c2x* ax, C2_TYPE typeA, void* B, c2x* bx, C2_TYPE typeB)
@prime31
prime31 / Game2.cs
Last active December 16, 2016 04:50
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Nez;
namespace TheWall
{
public class Game2 : Game
{
using Microsoft.Xna.Framework;
using Nez;
using Nez.Sprites;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Vapor.Code.Utility;
@prime31
prime31 / 2DDeferredLighting.fx
Last active April 15, 2016 05:33
2D deferred lighting implementation (first pass, not optimized)
// ##### ##### ##### ##### ##### ##### #####
// ##### ##### Common Uniforms ##### #####
// ##### ##### ##### ##### ##### ##### #####
float4x4 _objectToWorld;
float4x4 _worldToView;
float4x4 _projection; // viewToCamera?
float4x4 _screenToWorld; // this is used to compute the world-position
// color of the light