Skip to content

Instantly share code, notes, and snippets.

View alexsr's full-sized avatar

Alexander Scheid-Rehder alexsr

View GitHub Profile
@alexsr
alexsr / CameraController.ts
Created August 17, 2020 15:35
Three JS Camera Controller for typical CG camera
import * as THREE from 'three'
export class CameraController {
camera: THREE.Camera;
invertControls: boolean;
domElement: HTMLElement;
controls: PointerLockControls;
moveForward: boolean;
moveBackward: boolean;
moveLeft: boolean;
#include <functional>
#include <iostream>
#include <type_traits>
#include <optional>
#include <variant>
#include <chrono>
#include <memory>
//! Returns the time since epoch in ms
template <typename... Ts>
void attach_shaders(GLuint program, Ts... shaders) {
(glAttachShader(program, shaders), ...);
}
template <typename... Ts>
void detach_shaders(GLuint program, Ts... shaders) {
(glDetachShader(program, shaders), ...);
}
bool ImGui::BeginBarMenu(const char* label, const bool enabled) {
auto window = GetCurrentWindow();
if (window->SkipItems) {
return false;
}
auto& g = *GImGui;
const auto& style = g.Style;
const auto id = window->GetID(label);
const char* str = "##barmenubar";
const char* str_end = nullptr;
@alexsr
alexsr / gl_texture_format_util.hpp
Created July 4, 2018 20:24
OpenGL internal texture format conversion
enum class format : GLenum {
r = GL_RED,
g = GL_GREEN,
b = GL_BLUE,
rg = GL_RG,
rgb = GL_RGB,
bgr = GL_BGR,
rgba = GL_RGBA,
bgra = GL_BGRA,
r_int = GL_RED_INTEGER,
@alexsr
alexsr / svd_glsl.glsl
Last active April 3, 2023 18:47
SVD and other matrix decompositions on 3x3 matrices written in GLSL
// This is a GLSL implementation of
// "Computing the Singular Value Decomposition of 3 x 3 matrices with
// minimal branching and elementary floating point operations"
// by Aleka McAdams et.al.
// http://pages.cs.wisc.edu/~sifakis/papers/SVD_TR1690.pdf
// This should also work on the CPU using glm
// Then you probably should use glm::quat instead of vec4
// and mat3_cast to convert to mat3.