Wednesday, December 06, 2006

The small grey children, who stand by your bed and watch you while you're sleeping.

Sometimes we need pointers to pointers. Today was one of those days, it's used to pass back information. If you want to pass back info and just pass in a normal pointer, then a copy is made and the pointer outside of the function is never changed.

This is my *arghh* how does it work code.

#include "stdafx.h"

using namespace std;

int b = 3;

void func(int ** i){
*i = &b;

int _tmain(int argc, _TCHAR* argv[])
int * p;
std::cout << (*p) << std::endl;
char a;
cin >> a;
return 0;

My second sweet snippet is cheap cheap openGL matrices.

This takes in an openGL matrix array, like you'd get from glLoadMatrix, then applies to a vector or vertex.

void TransformVector(float * m, Vector3d &v, Vector3d &d)
d.x = (m[0] * v.x) + (m[4] * v.y) + (m[8] * v.z) + m[12];
d.y = (m[1] * v.x) + (m[5] * v.y) + (m[9] * v.z) + m[13];
d.z = (m[2] * v.x) + (m[6] * v.y) + (m[10] * v.z) + m[14];


Flavio said...

i would like you write about alpha blending c# managed with sprites =]

Dan said...

There's some basic blending stuff under 2:2 movement. But at the moment I'm not going to be writing anything more - sorry!

I have some time free after Christmas so I might expand / rewrite parts of the tutorials then.

Flavio said...

okay thanks, uh nice page very usefull!