Skip to content

Instantly share code, notes, and snippets.

View deccer's full-sized avatar
👾

deccer

👾
  • Sol
View GitHub Profile
@deccer
deccer / mikktspace.md
Created January 31, 2025 23:31
how to use mikktspace.md
FetchContent_Declare(
    mikktspace
    GIT_REPOSITORY  https://github.com/mmikk/MikkTSpace/
    GIT_TAG         master
    GIT_SHALLOW     TRUE
    GIT_PROGRESS    TRUE
)
FetchContent_GetProperties(mikktspace)
if(NOT mikktspace_POPULATED)
@deccer
deccer / Main.cpp
Created July 7, 2024 12:01
SAssetImage -> Texture
#include <cstddef>
#include <fstream>
#include <filesystem>
#include <iostream>
#include <memory>
#include <unordered_map>
#include <string>
#include <utility>
#include <glad/gl.h>
@deccer
deccer / troubleshoot.gl.md
Last active March 26, 2025 01:55
Troubleshoot - OpenGL

i was wondering if we should/could list common errors in the gl get started thing too, after debugcallback/renderdoc chapters or probably in some appendix, if you have more of those, let me know then we can compile those together into some comprehensive unfuck gl list

  • you use glad and its giving you a hard time, symbols not found, multiple definitions etc

    • you most likely did just generate the headers on dav1d's site and manually downloaded the zip and all that bs some time ago
    • if you cant be bothered to use cmake and let cmake handle all that for you, check the timestamp when you generated it last time, and if its (most likely) old, regenerate it again, will most likely fix it
    • use cmake to fetch glad and it will handle gl header generation
  • nothing works:

    • get rid of GLCALL/GLCHECK macros, most of them use glGetError incorrectly anyway
  • setup glDebugMessageCallback see here

@deccer
deccer / tonemap.hlsl
Created February 11, 2023 10:08
Tonemapping
float3 HableToneMap(float3 color)
{
float A = 0.22;//Shoulder Strength
float B = 0.30;//Linear Strength
float C = 0.10;//Linear Angle
float D = 0.20;//Toe Strength
float E = 0.01;//Toe Numerator
float F = 0.30;//Toe Denominator
color = max(0, color - 0.004f);
@deccer
deccer / world.frag
Created February 11, 2023 09:51
bilerp
#version 330 core
out vec4 color;
uniform sampler2D tileMap;
uniform sampler2DArray atlas; //because atlas is now a Texture array we need the proper sampler type for that
uniform sampler2D lightMap;
uniform sampler1D ambient; //1D gradient texture that is used for day-night changes
#include <cstddef>
#include <spdlog/spdlog.h>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <glm/vec3.hpp>
#include <fstream>
#include <string>
#include <string_view>
#include <vector>
public sealed class JoltPhysicsWorld : IPhysicsWorld
{
private const uint MaxBodies = 1024;
private const uint NumBodyMutexes = 0;
private const uint MaxBodyPairs = 1024;
private const uint MaxContactConstraints = 1024;
private const int MaxPhysicsJobs = 2048;
private const int MaxPhysicsBarriers = 8;
public interface IShaderParser
{
string ParseShader(string? shaderSource);
}
internal sealed class ShaderParser : IShaderParser
{
private static readonly Regex _includeRegex =
new Regex("^[ ]*#[ ]*include[ ]+[\\\"<](?'include'.*)[\\\">].*", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private readonly IShaderIncludeHandler _includeHandler;
using System;
using System.IO;
using System.Numerics;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using Vortice.Direct3D;
using Vortice.Direct3D11;
using Vortice.DXGI;
using Vortice.Mathematics;
using Vortice.WIC;
@deccer
deccer / arch-install-luks-lvm-ext4.sh
Created March 14, 2022 12:57
Arch Linux - Base Install Script - UEFI LUKS LVM EXT4
#!/bin/bash
set -e
set -o pipefail
set -o errtrace
set -o nounset
set -o errexit
KEYMAP='us'
LANG='en_US'