Skip to content

Instantly share code, notes, and snippets.

View native-m's full-sized avatar

Muhammad Gusti Nurfathin (Native-M) native-m

View GitHub Profile
@native-m
native-m / maze.cpp
Created November 26, 2021 18:19
SDL Maze Generator
#include <iostream>
#include <stack>
#include <array>
#include <algorithm>
#include <random>
#include <memory>
#include <SDL.h>
#undef main
@native-m
native-m / Property.h
Created July 7, 2021 13:42
Simple Property Getter & Setter in C++
#include <functional>
template<typename T>
class Property
{
public:
using GetterFn = T&();
using SetterFn = void(const T&);
template<typename Getter, typename Setter>
@native-m
native-m / ThreadPool.h
Created July 6, 2020 17:07
Thread Pool
#include <thread>
#include <vector>
#include <functional>
#include <condition_variable>
#include <queue>
#include <utility>
class ThreadPool
{
public:
@native-m
native-m / hxecs.cpp
Last active February 20, 2020 08:15
Hexagon engine ECS concept
#include <iostream>
using Hx::ECS::ECSContext;
using Hx::ECS::EntityManager;
using Hx::ECS::Entity;
using Hx::ECS::World;
using Hx::ECS::System;
using Hx::Components::Position2D;
using Hx::Components::Direction2D;
using Hx::Components::Sprite2D;
@native-m
native-m / basic.cpp
Created January 20, 2020 02:21
example
#include <Hx.hpp>
#include <iostream>
using Hx::App::Application;
using Hx::App::Game;
using Hx::Entity::Entity;
using Hx::Entity::EntityManager;
using Hx::Entity::PlayerSystem;
using Hx::Math::Vec2;
@native-m
native-m / csm.cpp
Created January 8, 2020 19:01
GTA: SA Stuff
void
UpdateShadowMatrix()
{
DirectX::XMMATRIX camInv;
DirectX::XMMATRIX shadowView;
RwCamera* rwcam = Scene.camera;
float minDist = RwCameraGetNearClipPlane(rwcam);
float maxDist = RwCameraGetFarClipPlane(rwcam);
CVector sunPos;
CVector camPos;
float rand(vec2 p)
{
float t = floor(iTime * 20.) / 10.; // limit glitch FPS
//t = exp(t);
return fract(sin(dot(p, vec2(t * 12.9898, t * 78.233))) * 43758.5453);
}
float noise(vec2 uv, float blockiness)
{
vec2 lv = fract(uv);
@native-m
native-m / jpegemu.py
Last active November 16, 2019 19:44
JPEG Emulator
# JPEG Emulator
# licensed under GPLv2 license
#
# What this thing does?
# It emulates jpeg DCT algorithm
#
# Python 3 is required to run this code
#
# HOW TO USE:
# 1. install numpy, scipy, and Pillow package
@native-m
native-m / f32add.cpp
Last active July 14, 2019 17:26
Floating-point addition & multiplication behind the scene. Rounding not included!
union IEEEFloat
{
struct
{
int m : 23;
int e : 8;
int s : 1;
};
int i;
@native-m
native-m / async_diffgpu.cpp
Created July 9, 2019 19:24
Performing async task in different GPU using DirectX 11
#include <Windows.h>
#include <d3d11.h>
#include <iostream>
#include <vector>
#include <thread>
#include <mutex>
#include <d3dcompiler.h>
#pragma comment(lib, "dxgi.lib")
#pragma comment(lib, "d3d11.lib")