void DecoStat::DrawText(DecoRenderInterface* RI, char * text, UINT posX, UINT posY, INT win_width, INT win_height) { RI->PushState(); matrix44 identity = IdentityMatrix44(); RI->SetTransform(TT_CameraToScreen, identity); RI->SetTransform(TT_WorldToCamera, identity); RI->SetTransform(TT_LocalToWorld, identity); gluOrtho2D(0, win_width, 0, win_height); RI->ResetLight(); RI->EnableDepthTest(FALSE); RI->EnableTexture(FALSE); glListBase(1000); glRasterPos3d(posX,posY,0); glCallLists((GLsizei)strlen(text),GL_UNSIGNED_BYTE,text); RI->PopState(); }
// Invert the matrix44 matrix44 &matrix44::invert() { matrix44 a(*this); matrix44 b(IdentityMatrix44()); unsigned int r, c; unsigned int cc; unsigned int rowMax; // Points to max abs value row in this column unsigned int row; float tmp; // Go through columns for (c=0; c<4; c++) { // Find the row with max value in this column rowMax = c; for (r=c+1; r<4; r++) { if (fabs(a[c][r]) > fabs(a[c][rowMax])) { rowMax = r; } } // If the max value here is 0, we can't invert. Return identity. if (a[c][rowMax] == 0.0F) return(identity()); // Swap row "rowMax" with row "c" for (cc=0; cc<4; cc++) { tmp = a[cc][c]; a[cc][c] = a[cc][rowMax]; a[cc][rowMax] = tmp; tmp = b[cc][c]; b[cc][c] = b[cc][rowMax]; b[cc][rowMax] = tmp; } // Now everything we do is on row "c". // Set the max cell to 1 by dividing the entire row by that value tmp = a[c][c]; for (cc=0; cc<4; cc++) { a[cc][c] /= tmp; b[cc][c] /= tmp; } // Now do the other rows, so that this column only has a 1 and 0's for (row = 0; row < 4; row++) { if (row != c) { tmp = a[c][row]; for (cc=0; cc<4; cc++) { a[cc][row] -= a[cc][c] * tmp; b[cc][row] -= b[cc][c] * tmp; } } } } *this = b; return *this; }