Hi, could anyone send me a link to a picture of CORRECT orthogonal 4x4 matrix implementation? I can't seem to find it on the google. Not sure if I did it right myself.

This is the code I got for the matrix:

#include "Matrix4.h" Matrix4::Matrix4() { m_data = new float[16]; loadIdentity(); } void Matrix4::set(const float matrix[16]) { for(int i = 0; i < 16; i++){ m_data[i] = matrix[i]; } } void Matrix4::loadIdentity() { m_data[0] = 1.0f; m_data[1] = 0.0f; m_data[2] = 0.0f; m_data[3] = 0.0f; m_data[4] = 0.0f; m_data[5] = 1.0f; m_data[6] = 0.0f; m_data[7] = 0.0f; m_data[8] = 0.0f; m_data[9] = 0.0f; m_data[10] = 1.0f; m_data[11] = 0.0f; m_data[12] = 0.0f; m_data[13] = 0.0f; m_data[14] = 0.0f; m_data[15] = 1.0f; } void Matrix4::setFrustum(float left, float right, float bottom, float top, float near, float far) { // TODO implement this } void Matrix4::setOrtho(float left, float right, float bottom, float top, float near, float far) { m_data[0] = 2.0f/(right-left); m_data[1] = 0.0f; m_data[2] = 0.0f; m_data[3] = -((right+left)/(right-left)); m_data[4] = 0.0f; m_data[5] = 2.0f/(top-bottom); m_data[6] = 0.0f; m_data[7] = -((top+bottom)/(top-bottom)); m_data[8] = 0.0f; m_data[9] = 0.0f; m_data[10] = 2.0f/(far-near); m_data[11] = -((far+near)/(far-near)); m_data[12] = 0.0f; m_data[13] = 0.0f; m_data[14] = 0.0f; m_data[15] = 1.0f; } Matrix4 Matrix4::operator*(const Matrix4 & matrix) { Matrix4 outMatrix; for(int y = 0; y < 4; y++){ for(int x = 0; x < 4; x++){ float outVal = 0; for(int i = 0; i < 4; i++){ outVal += getData(i,y)*matrix.getData(x,i); } outMatrix.setData(x,y,outVal); } } return outMatrix; } void Matrix4::operator=(const Matrix4 & matrix) { set(matrix.toArray()); } std::ostream& operator<<(std::ostream& os, const Matrix4& matrix) { for(int y = 0; y < 4; y++){ for(int x = 0; x < 4; x++){ os << matrix.getData(x,y) << "\t"; } os << std::endl; } } float * Matrix4::toArray() const { return m_data; } float Matrix4::getData(int col, int row) const { return m_data[(row*4)+col]; } void Matrix4::setData(int col, int row, float data) { m_data[(row*4)+col] = data; } Matrix4::~Matrix4() { delete [] m_data; }

Does this look good? The multiplication part seems to work fine. But I'm not sure about setOrtho method.