Skip to content

Instantly share code, notes, and snippets.

View hamsham's full-sized avatar

Miles Lacey hamsham

View GitHub Profile
@hamsham
hamsham / NormVisualizer.gs
Last active December 20, 2015 18:49
A GLSL 330 shader program to visualize polygon edges, vertex normals, tangents, and bitangents.Vertices are passed in as normal to the vertex shader, colors are set in the geometry shader.
/******************************************************************************
* Edge/Normal/Tangent/Bitangent Visualizer
******************************************************************************/
/**
* Vertex Shader
*/
const char enbtVS[] = R"(
#version 330
uniform mat4 mvpMatrix;
@hamsham
hamsham / endian.cpp
Last active March 1, 2021 00:31
A simple compile-time endianness checking system for programs written in C++11.
/*
* A simple compile-time endian test
* g++ -std=c++11 -Wall -Werror -Wextra -pedantic -pedantic-errors endian.cpp -o endian
*
* This can be used with specialized template functions, classes, and class
* methods in order better tailor code and reduce reliance on runtime
* checking systems.
*/
#include <cstdint>
@hamsham
hamsham / token.cpp
Created April 5, 2014 21:43
Skeleton code for a command-Line argument tokenizer. It will input command-line arguments, convert them into a native data type, and place them into an std::vector as tuples.
/**
* Simple string-to-type tokenizing.
* This program can be used as skeleton code for creating a tokenizer for
* command-line arguments. It will convert values into a tuple-type where values
* can be extracted using their intended data type.
*
* Example:
* token +3.14159
* Results in two returned values:
@hamsham
hamsham / pluginAPI.h
Created November 3, 2014 03:19
An example API for an example plugin system in C++.
/**
* Plugin API header
*/
#ifndef __PLUGIN_API_H__
#define __PLUGIN_API_H__
/*
* Windows-specific settings for a dynamic library
*/
@hamsham
hamsham / sharedLibrary.h
Created November 3, 2014 03:22
Example header for a shared library loader that loads plugin objects from the pluginAPI.h header.
#ifndef __SHARED_LIB_H__
#define __SHARED_LIB_H__
#include <string>
#include "pluginAPI.h"
//-----------------------------------------------------------------------------
// Shared Library loading object (Used for RAII purposes).
@hamsham
hamsham / sharedLibrary.cpp
Last active August 29, 2015 14:08
Example source file for a shared library loader that loads plugin objects from the pluginAPI.h header
#include <iostream>
#include <string>
#include <cctype> // tolower()
#include <SDL2/SDL.h>
#include "sharedLibrary.h"
//-----------------------------------------------------------------------------
@hamsham
hamsham / pluginLoader.cpp
Created November 3, 2014 04:03
Main procedure for loading a plugin library at runtime.
/**
* A test of user-defined plugins
*
* g++ -std=c++11 -Wall -Wextra -Werror -pedantic -pedantic-errors -DSDL_MAIN_HANDLED main.cpp sharedLibrary.cpp -o PluginLoader -lSDL2
*/
#include <iostream> // std::cin, std::cout, std:: cerr
#include <vector>
#include <string>
/**
* Testing the plugin interface
* If you're using GCC/G++, specify the additional linker options:
*
* Indicate that this is a shared library:
* shared -s
*
* Use the provided directive to export compiler symbols to the shared library:
* -DBUILD_PLUGIN
@hamsham
hamsham / work_dispatch.cpp
Created November 18, 2014 09:08
An (incomplete) example in setting up a Worker/Dispatcher system in C++.
/**
* An (incomplete) example in setting up a Worker/Dispatcher system.
*
* g++ -std=c++11 -Wall -Werror -Wextra -pedantic -pedantic-errors work_dispatch.cpp -o work_dispatch
*/
#include <iostream>
#include <vector>
#include <unordered_map>
import QtQuick 2.4
Item {
id: thisCircle
property string color: "black"
property alias border: thisBorder
property real renderWidth: width
property real renderHeight: height