fpo

07-19-2005, 02:55 PM

Hi... does anyone have the source for GLU functions gluProject and gluUnProject???

I want to create float versions of them so I do not need to convert my matrices to double every frame. I made a float version of gluProject and it matches the results from the original double version. Here it is:

void gluProject_float(const vector3& p_obj, vector3& p_win)

{

vector4 t;

t = p_obj * view_matrix; // v3 * m(4x3)

t = t * proj_matrix; // v4 * m(4x4)

p_win.x = win_sizex * (t.x / t.w + 1.0f) * 0.5f;

p_win.y = win_sizey * (t.y / t.w + 1.0f) * 0.5f;

p_win.z = (t.z / t.w + 1.0f) * 0.5f;

}But can not find any info on how to implement gluUnProject. Any links for its definition or implementation in GLU???

I need this for a deferred shading demo ... works ok when converting to double before gluUnProject but think a float version would be nice as I do not use double anywere else.

I want to create float versions of them so I do not need to convert my matrices to double every frame. I made a float version of gluProject and it matches the results from the original double version. Here it is:

void gluProject_float(const vector3& p_obj, vector3& p_win)

{

vector4 t;

t = p_obj * view_matrix; // v3 * m(4x3)

t = t * proj_matrix; // v4 * m(4x4)

p_win.x = win_sizex * (t.x / t.w + 1.0f) * 0.5f;

p_win.y = win_sizey * (t.y / t.w + 1.0f) * 0.5f;

p_win.z = (t.z / t.w + 1.0f) * 0.5f;

}But can not find any info on how to implement gluUnProject. Any links for its definition or implementation in GLU???

I need this for a deferred shading demo ... works ok when converting to double before gluUnProject but think a float version would be nice as I do not use double anywere else.