Skip to content

Instantly share code, notes, and snippets.

View zao's full-sized avatar

Lars Viklund zao

View GitHub Profile
namespace rendering
{
namespace detail
{
template <typename T>
struct format_of;
template <>
struct format_of<D3DXVECTOR2>
{
@zao
zao / animated_mesh.cc
Created August 9, 2011 06:39
Instanced drawing
void animated_mesh::draw(animated_mesh& model, std::vector<instance_data> const& instances, D3DXMATRIX view, D3DXMATRIX projection)
{
auto hr = noisy_hresult();
unsigned stride[] = { sizeof(vertex_type_a), sizeof(vertex_type_b), sizeof(instance_data) };
unsigned offset[] = { 0, 0, 0 };
CComPtr<ID3D11DeviceContext> ctx = model.ctx;
CComPtr<ID3D11Device> device;
ctx->GetDevice(&device);
@zao
zao / common.h
Created August 9, 2011 06:45
Asserting HRESULT-like
struct noisy_hresult
{
HRESULT hr;
noisy_hresult& operator = (HRESULT hr)
{
this->hr = hr;
if (FAILED(hr))
__debugbreak();
return *this;
}
@zao
zao / A.cpp
Created August 26, 2011 23:20
circular includes
#include "A.hpp"
#include "B.hpp"
void A::f(B* b)
{
b->g(this);
}
struct delayed_call
{
boost::optional<std::function<void ()>> f;
~delayed_call()
{
if (f)
(*f)();
}
};
@zao
zao / seekbar.fx
Created October 18, 2011 00:08
Default seekbar effect, it seems
texture tex : WAVEFORMDATA;
sampler sTex = sampler_state
{
Texture = (tex);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Clamp;
@zao
zao / premake4.lua
Created October 22, 2011 07:12
Horror, oh the horror! premake4.
solution "brigade"
configurations { "Debug", "Release" }
location "build"
defines {
"WIN32",
"_WIN32_WINNT=0x0600",
"_CRT_SECURE_NO_WARNINGS=1",
"_SCL_SECURE_NO_WARNINGS=1",
"_WINDOWS",
@zao
zao / gist:1305956
Created October 22, 2011 12:39
tundra build log
gcc -Ltundra-output/linux-gcc-release-standalone -lm -lpthread -o tundra-output/linux-gcc-release-standalone/tundra_luac tundra-output/linux-gcc-release-standalone/__luac/lua/src/luac.o tundra-output/linux-gcc-release-standalone/__luac/lua/src/print.o tundra-output/linux-gcc-release-standalone/libbase_lua_host.a
tundra-output/linux-gcc-release-standalone/libbase_lua_host.a(lvm.o): In function `luaV_execute':
lua/src/lvm.c:(.text+0x21ae): undefined reference to `pow'
lua/src/lvm.c:(.text+0x2265): undefined reference to `pow'
tundra-output/linux-gcc-release-standalone/libbase_lua_host.a(lcode.o): In function `codearith':
lua/src/lcode.c:(.text+0x1c72): undefined reference to `pow'
collect2: ld returned 1 exit status
@zao
zao / Kitteh.pm
Created October 27, 2011 19:45
Kitteh.pm
package Kitteh;
use strict;
use warnings;
use DBI;
use File::Basename;
use File::HomeDir;
use MIME::Base64;
use UUID::Tiny ':std';
@zao
zao / seekbar-line.fx
Created November 1, 2011 01:37
Line-drawing seekbar effect
texture tex : WAVEFORMDATA;
sampler sTex = sampler_state
{
Texture = (tex);
MipFilter = LINEAR;
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Clamp;