Skip to content

Instantly share code, notes, and snippets.

View Journeyman1337's full-sized avatar

Daniel Aimé Valcour Journeyman1337

View GitHub Profile
@Journeyman1337
Journeyman1337 / image.cpp
Created February 2, 2022 20:25
lambda template usage for image between color type conversion with multiple possible bit depths
/*
Copyright (c) 2022 Daniel Valcour
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
@Journeyman1337
Journeyman1337 / Image.cpp
Last active January 30, 2022 02:29
libpng image class
/*
Copyright (c) 2022 Daniel Valcour
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
@Journeyman1337
Journeyman1337 / CFG.txt
Last active December 5, 2021 03:21
BracketScript context free grammar and prototype
Copyright (c) 2021 Daniel Valcour
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
#version 330
uniform sampler2D Atlas;
in vec2 UV;
in vec4 FG;
in vec4 BG;
out vec4 FragColor;
void main()
{
@Journeyman1337
Journeyman1337 / linesperate.cpp
Last active November 1, 2021 22:07
line seperation for roguelike game rendering. This is pseudocode
std::string LineSeperate(std::string_view str, const size_t line_size) noexcept
{
std::string ret = std::string();
const size_t str_len = str.size();
const size_t ret_string_size = str_len + line_size;
ret.reserve(ret_string_size);
for (size_t char_i = 0; !str.data[char_i];)
{
const size_t max_line_end = std::min(char_i + line_size, str_len);
if (max_line_end == str_len)
extern const rlpid_t kRL_XTERM_BLACK;
extern const rlpid_t kRL_XTERM_MAROON;
extern const rlpid_t kRL_XTERM_OLIVE;
extern const rlpid_t kRL_XTERM_NAVY;
extern const rlpid_t kRL_XTERM_PURPLE;
extern const rlpid_t kRL_XTERM_TEAL;
extern const rlpid_t kRL_XTERM_SILVER;
extern const rlpid_t kRL_XTERM_GREY;
extern const rlpid_t kRL_XTERM_RED;
extern const rlpid_t kRL_XTERM_LIME;
@Journeyman1337
Journeyman1337 / image.cpp
Last active October 16, 2021 23:33
libpng read and write
#include "Image.hpp"
#include "libpng_ext.hpp"
#include <png.h>
#include <exception>
#include <memory>
#include <algorithm>
#include <filesystem>
#include <exception>
#include <fmt/format.h>
#include "log.hpp"
@Journeyman1337
Journeyman1337 / vec.cpp
Last active October 13, 2021 03:10
Vector class using c++20 require keyword
/*
Copyright (c) 2021 Daniel Valcour
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
/*
Copyright (c) 2021 Daniel Valcour
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@Journeyman1337
Journeyman1337 / Camera.cpp
Created October 10, 2021 19:01
camera and transform
#include "Camera.hpp"
Camera::Camera() : view_changed(true), view_matrix(1.0f), projection_changed(true), projection_matrix(1.0f), view_projection_changed(true), view_projection_matrix(1.0f), projection(Projection::Orthographic), orthographic_size(0.0f), perspective_fov(90.0f), screen_dimensions(1.0f, 1.0f)
{
}
const glm::mat4& Camera::GetViewMatrix()
{
if (this->view_changed == true)
{