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)
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.
Your code for gluProject looks weird.
Shouldn’t that be
t = view_matrix * p_obj; // v3 * m(4x3)
t = proj_matrix * t; // v4 * m(4x4)
I have a lib that is a a glu replacement
The functions you would be interested in
The 5 to 14 are for mass processing.
The source for the original GLU can be found in MESA (mesa3d.org)
Go to http://www.mesa3d.org and get the latest source for the Mesa library, which includes its own version of libGLU, as well as SGI’s implementation.
Thanks for the links and the quick reply.
V-man, the (matrix * vector) or (vertor * matrix) would be the same thing… anyway that was just a pseudo code not my actual code.
And thanks again for the library and source link.