Skip to content

Instantly share code, notes, and snippets.

@lhog
lhog / GLSL
Last active January 11, 2024 22:18
UV coordinates of a quad from its 2D coordinate
float cross2d(vec2 v1, vec2 v2) {
return v1.x * v2.y - v1.y * v2.x;
}
// https://www.uio.no/studier/emner/matnat/ifi/nedlagte-emner/INF4360/h10/undervisningsmateriale/bc_lecture.pdf
bool GetQuadUV(vec2 p00, vec2 p10, vec2 p01, vec2 p11, vec2 p, out vec2 uv) {
vec2 a = p00 - p;
vec2 b = p10 - p00;
vec2 c = p01 - p00;
vec2 d = p00 - p10 - p01 + p11;
@lhog
lhog / COZ profiler by pako
Created January 30, 2022 23:59
COZ profiler by pako
1st add: find_package(coz-profiler), add library dl, include coz.h and COZ_PROGRESS; in gameFrame()
2nd: compile with clang RelwithDebug or maybe gcc with some correct -gdwarf-4 settings
3rd: run: "coz run --- ./spring ./demos/2022xxx.sdfz"
4th: use /skip 10000 to profile synced code and maybe pause to profile drawing
From a6cfcbd9141146a5c84c38182a4cd6086608947e Mon Sep 17 00:00:00 2001
From: You Name <your@example.com>
docker run -it verybadsoldier/springrts-build:latest dev -b BAR105-winres2 -p linux-64
./engine/105.1.1-739-ga241485\ bar/spring --isolation --write-dir /home/ak/Documents/Beyond\ All\ Reason --menu="rapid://byar-chobby:test"
@lhog
lhog / resolution_test.lua
Created January 9, 2022 21:53
resolution_test.lua
function widget:GetInfo()
return {
name = "Resolution Testing",
desc = "Debug changing fulscreen/borderless/resolution",
layer = 0,
enabled = true,
}
end
local windowType = {
@lhog
lhog / FixedPipelineState.cpp
Created December 9, 2021 23:26
FixedPipelineState backup
#include "FixedPipelineState.h"
#include <array>
#include <stdexcept>
#include "System/type2.h"
#include "System/float4.h"
#include "System/StringHash.h"
#include "Rendering/GlobalRendering.h"
function widget:GetInfo()
return {
name = "CUS GL4",
author = "ivand",
layer = 0,
enabled = true,
}
end
--inputs
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <vector>
#include <algorithm>
#include <iostream>
void framebuffer_size_callback(GLFWwindow* window, int width, int height);
void processInput(GLFWwindow *window);
function widget:GetInfo()
return {
name = "Unitshapes Rendering",
version = "v0.2",
desc = "Unitshapes Rendering",
author = "ivand",
date = "2020",
license = "GPL",
layer = 0,
enabled = false,
function widget:GetInfo()
return {
name = "Test Unitshapes Rendering",
version = "v0.2",
desc = "Test Unitshapes Rendering",
author = "ivand",
date = "2020",
license = "GPL",
layer = 0,
enabled = true,
@lhog
lhog / map_grass
Last active April 15, 2021 23:13
function widget:GetInfo()
return {
name = "Map Grass GL4",
version = "v0.001",
desc = "Instanced rendering of garbagegrass",
author = "Beherith",
date = "2021.04.12",
license = "CC-BY-NC-ND 4.0",
layer = -1000000000000,