Skip to content

Instantly share code, notes, and snippets.

View gszauer's full-sized avatar
💻
Living life 16.6 ms at a time

Gabor Szauer gszauer

💻
Living life 16.6 ms at a time
View GitHub Profile
@gszauer
gszauer / SimpleSound.cpp
Created December 1, 2022 21:20
Simple Sound
#include "SimpleSound.h"
#include <windows.h>
#include <atomic>
#include <dsound.h>
#include <iostream>
#undef PlaySound
#define SIMPLE_SOUND_MAX_CHANNELS 6
#define SIMPLE_SOUND_NUM_COMMANDS 512
// Modified from: http://wiki.unity3d.com/index.php/TextureScale#TextureScale.cs
// Only works on ARGB32, RGB24 and Alpha8 textures that are marked readable
using UnityEngine;
public class TextureScale {
private static Color[] texColors;
private static Color[] newColors;
private static int w;
using UnityEngine;
using System.Collections;
public class RaycastOBB : MonoBehaviour {
public Vector3 rayOrigin = new Vector3(5.0f, 10.0f, 7.0f);
public Vector3 rayDirection = new Vector3(-15.0f, 33.0f, 10.0f);
public Vector3 obbRotation = new Vector3(10.0f, 260.0f, 170.0f);
public Vector3 obbPosition = new Vector3(0.0f, 20.0f, 10.0f);
public Vector3 obbHalfSize = new Vector3(1.0f, 1.0f, 1.0f);
Everything you ever wanted to know about alpha blending and more.
When doing alpha channels, few algorithms put in the extra effort for maximum flexibility. This is because there is always a battle between speed, memory and complexity. As we shall see, there are many different ways of doing alpha blending.
By far, the most common form of alpha channel is where you have a semi-transparent image that you want to apply over a static background. The semi-transparent image will contain red, green and blue channels as well as an alpha channel that specifies how transparent each pixel is. Each channel contains a series of values that range from 0 to 255 for 32bit images.
What this means is that an alpha channel of 255 would mean full intensity and an alpha value of 0 would mean that the background would show completely through. Any other value would be some percentage of the image and the inverse percentage of the background. For example, if an alpha channel is at 30%, then you'll see 70% of the background showi
@gszauer
gszauer / UI.js
Last active July 23, 2022 18:08
WebFS First Demo
function UpdateMetaData(WebFS, info) {
let infoDiv = document.getElementById('size');
//let location = window.location.href;
let location = (new URL(window.location.href));
let target = "filesystem:" + location.protocol;
if (target.endsWith(":")) {
target += "//";
}
else {
@gszauer
gszauer / handle.cpp
Created December 20, 2019 08:09
Win32-Wait-For-VSYNCH
typedef LONG NTSTATUS;
typedef UINT D3DKMT_HANDLE;
typedef UINT D3DDDI_VIDEO_PRESENT_SOURCE_ID;
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
#define STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002L)
typedef struct _D3DKMT_WAITFORVERTICALBLANKEVENT {
D3DKMT_HANDLE hAdapter; // in: adapter handle
D3DKMT_HANDLE hDevice; // in: device handle [Optional]
/*
Generates a trail that is always facing upwards using the scriptable mesh interface.
vertex colors and uv's are generated similar to the builtin Trail Renderer.
To use it
1. create an empty game object
2. attach this script and a MeshRenderer
3. Then assign a particle material to the mesh renderer
*/
var height = 2.0;
var time = 2.0;
@gszauer
gszauer / types.h
Created May 26, 2022 04:16
types.h
#pragma once
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef __int8 i8;
typedef __int16 i16;
typedef __int32 i32;
#include "Quaternion.h"
#include <cmath>
// http://content.gpwiki.org/index.php/OpenGL:Tutorials:Using_Quaternions_to_represent_rotation
// http://www.flipcode.com/documents/matrfaq.html
// http://db-in.com/blog/2011/04/cameras-on-opengl-es-2-x/
// http://wiki.beyondunreal.com/Legacy:Quaternion
// http://clb.demon.fi/MathGeoLib/docs/float3x3.cpp_code.html#612
// http://clb.demon.fi/MathGeoLib/docs/Quat_summary.php
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm
@gszauer
gszauer / ASTNode.cs
Created February 25, 2022 03:17
RecursiveDescentParser
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ExpressionParser {
class ASTNode {
}