Try something like this:
Assume proj contains projection matrix and mv contains modelview matrix...
Matrix4 proj, mv, temp, inv;
temp = proj * mv;
inv = inverse(temp); // compute inverse of matrix
VECTOR4 fr[8]=
{
// near
{-1, -1, -1, 1}, { 1, -1, -1, 1}, { 1, 1, -1, 1}, {-1, 1, -1, 1},
// far
{-1, -1, 1, 1}, { 1, -1, 1, 1}, { 1, 1, 1, 1}, {-1, 1, 1, 1}
};
// Transform all vertices:
// multiply vertex array (fr) by matrix. result is transformed vertex array (tfr)
VECTOR4 tfr[8];
transform_points(fr, 8, inv, tfr);
int i;
for (i=0; i<8; i++)
{
tfr[i].x /= tfr[i].w;
tfr[i].y /= tfr[i].w;
tfr[i].z /= tfr[i].w;
tfr[i].w = 1.0f;
}
glBegin(GL_LINES);
connect tfr points as follow:
0-1, 1-2, 2-3, 3-0,
4-5, 5-6, 6-7, 7-4,
0-4, 1-5, 2-6, 3-7
glEnd();
This is a pseudo code. I suppose that you already have your math library with matrix and vector functions (inverse, transform_points and matrix_mult (*).
yooyo