Skip to content

Instantly share code, notes, and snippets.

void screenshot(char filename[160], int x, int y)
{
// get the image data
long imageSize = x * y * 3;
unsigned char *data = new unsigned char[imageSize];
glReadPixels(0,0, x,y, GL_BGR, GL_UNSIGNED_BYTE, data);
// split x and y sizes into bytes
int xa= x % 256;
int xb= (x - xa) / 256;
@kovrov
kovrov / glsl_test.d
Created May 12, 2011 00:27
glsl_test.d
import std.stdio;
import std.conv;
import std.string : toStringz;
import gl;
import glut;
class ShaderException : Exception
DATA
@kovrov
kovrov / unpack.d
Created April 16, 2011 23:33
Delphine's unpacking routines
import std.intrinsic;
pure uint pop(ref const(uint)[] stream)
{
auto res = bswap(stream[$-1]);
stream.length -= 1;
return res;
}
immutable(uint[256]) crc32_lookup_table =
{
uint[] table;
foreach (ref i; 0 .. 256)
{
uint crc = i;
foreach (_; 0 .. 8)
crc = crc & 1 ? (crc >> 1) ^ 0xEDB88320 : crc >> 1;
table ~= crc;
}
#include <qdebug.h>
template <typename T> class Runner;
template <typename T> Runner<T> Closure(T t) { return Runner<T>(t); }
template <typename T> class Runner
{
friend Runner<T> Closure <> (T t);
Runner(T t) : _t (t) {}
T _t;
public:
import std.stdio;
struct Bind(alias F, T1...)
{
static
Bind!(F, T1) opCall(T1...)(T1 t1)
{
Bind!(F, T1) self;
self.t1 = t1;
return self;
@kovrov
kovrov / folderlistmodel.cpp
Created December 3, 2010 02:06
QMF FolderListModel
// Qt
#include <QMap>
#include <QtAlgorithms>
// QMF
#include <qmfclient/qmailstore.h> // QMailStore
// project
#include "folderlistmodel.h"
@kovrov
kovrov / typedef-2.0.d
Created August 9, 2010 14:03
typedef-2.0.d
struct Typedef(T)
{
T _;
alias _ this;
}
alias Typedef!int myInt;
#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include <fstream>
class Convert
{
public:
template <typename T>