Skip to content

Instantly share code, notes, and snippets.

View deccer's full-sized avatar
👾

deccer

👾
  • Sol
View GitHub Profile
@deccer
deccer / troubleshoot.gl.md
Last active June 2, 2024 12:29
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

  • nothing works:

    • get rid of GLCALL/GLCHECK macros, most of them use glGetError incorrectly anyway
    • setup glDebugMessageCallback see here
    • your shaders could contain errors, make sure you check compile and linking state and fix according to what the error was highlighting
  • renderdoc crashes when i try to capture something from my project:

    • most likely some of your code is fucked, its rarely renderdoc being fucked in that case
  • make sure to hookup glDebugMessageCallback as stated above

@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'
@deccer
deccer / arch-install-btrfs.sh
Created March 14, 2022 12:56
Arch Linux - Base Install Script - UEFI BTRFS
#!/bin/bash
set -e
set -o pipefail
set -o errtrace
set -o nounset
set -o errexit
KEYMAP='us'
LANG='en_US'
@deccer
deccer / arch-install-lvm-ext4.sh
Last active March 14, 2022 12:55
Arch Linux - Base Install Script - UEFI LVM EXT4
#!/bin/bash
set -e
set -o pipefail
set -o errtrace
set -o nounset
set -o errexit
KEYMAP='us'
LANG='en_US'