Skip to content

Instantly share code, notes, and snippets.

View NotAPenguin0's full-sized avatar
🐧
Not on vacation.

NotAPenguin NotAPenguin0

🐧
Not on vacation.
View GitHub Profile
@NotAPenguin0
NotAPenguin0 / gist_godbolt.hpp
Created September 8, 2019 17:52
godbolt test
#include <string_view>
#include <iostream>
void message(std::string_view sv) {
std::cout << sv;
}
@NotAPenguin0
NotAPenguin0 / Additional Dep Cmakelists.txt
Created September 20, 2019 18:03
Cmake libclang madness
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
set(AUDEO_DEPENDENCIES_FOLDER_NAME "dependencies")
set(DEBUG_OUTPUT_DIRECTORY "bin/debug")
set(RELEASE_OUTPUT_DIRECTORY "bin/release")
project(audeo)
enable_language(CXX)
set(CMAKE_CXX_EXTENSIONS OFF)
#version 430 core
#define MAX_LIGHTS_PER_TYPE 15
in vec2 TexCoords;
in vec3 Normal;
in vec3 FragPos;
in vec4 FragPosLightSpace;
struct PointLight {
template<typename AssetT>
void display_preview(AssetT& asset, ImVec2 size) {
// Default preview: an image saying no preview is available
Resource<Texture> no_preview_tex = AssetManager<Texture>::get_resource(
"config/resources/textures/no_preview.tex", true);
ImGui::Image(reinterpret_cast<ImTextureID>(no_preview_tex->handle()), size);
}
template<>
void display_preview(AssetManager<Texture>::Asset& asset, ImVec2 size) {
@NotAPenguin0
NotAPenguin0 / xerrordb
Created November 23, 2019 14:08
xerrordb
!
! Copyright 1993, 1995, 1998 The Open Group
! Permission to use, copy, modify, distribute, and sell this software and its
! documentation for any purpose is hereby granted without fee, provided that
! the above copyright notice appear in all copies and that both that
! copyright notice and this permission notice appear in supporting
! documentation.
!
! The above copyright notice and this permission notice shall be
@NotAPenguin0
NotAPenguin0 / perlin.cpp
Created December 31, 2019 13:13
perlin noise
struct vec2 {
float x, y;
float magnitude() const {
return std::sqrt(x * x + y * y);
}
vec2 normalized() const {
float mag = magnitude();
return {x / mag, y / mag};
@NotAPenguin0
NotAPenguin0 / heightmap.cpp
Last active January 18, 2020 15:45
chunk_stuff
static void generate_chunk_lod(HeightmapTerrain& terrain, HeightmapTerrain::Chunk& chunk, HeightmapTerrainInfo const& info,
size_t const lod_index, size_t const lod) {
GridMeshOptions options;
options.tex_w = terrain.width;
options.tex_h = terrain.length;
options.xoffset = chunk.xoffset;
options.yoffset = chunk.yoffset;
chunk.meshes[lod_index] = create_grid_mesh(chunk.width, chunk.length, lod, options);
calculate_normals(terrain, chunk.meshes[lod_index]);
@NotAPenguin0
NotAPenguin0 / swap_buffer.cpp
Created January 20, 2020 18:38
Swap buffer weird thingy
#include "renderer/swap_buffer.hpp"
#include <glad/glad.h>
#include <iostream>
namespace titan::renderer {
SwapBuffer::SwapBuffer(unsigned int buffer_target, size_t max_byte_size)
: target(buffer_target), size(max_byte_size) {
#include "generators/heightmap_terrain.hpp"
#include "generators/noise.hpp"
#include "math.hpp"
#include <thread>
#include <iostream>
namespace titan {
static void calculate_normals(HeightmapTerrain& terrain, GridMesh& mesh, size_t const offset) {
// Loop over each face
auto const& indices = mesh.indices;
auto& vertices = mesh.vertices;
size_t const vertex_size = mesh.vertex_size;
for (size_t quad = 0; quad < indices.size(); quad += 6) {
// Grab the verts of this quad
size_t const v1_index = vertex_size * indices[quad];
size_t const v2_index = vertex_size * indices[quad + 1];
size_t const v3_index = vertex_size * indices[quad + 2];