Transformation matricies were being multiplied backwards

This commit is contained in:
Thomas Muller 2021-08-03 23:02:00 -04:00
parent fd1a97507b
commit ff7e296d92
Signed by: thomas
GPG key ID: AF006EB730564952

View file

@ -100,10 +100,10 @@ void Render::pop_matrix() {
void Render::translate(Vector2<float> trans) { void Render::translate(Vector2<float> trans) {
switch(m_matrix_mode) { switch(m_matrix_mode) {
case MODEL: case MODEL:
m_matrix *= translation_matrix(trans); m_matrix = translation_matrix(trans) * m_matrix;
break; break;
case PROJECTION: case PROJECTION:
m_view_matrix *= translation_matrix(trans); m_view_matrix = translation_matrix(trans) * m_view_matrix;
break; break;
} }
} }
@ -111,10 +111,10 @@ void Render::translate(Vector2<float> trans) {
void Render::rotate(float theta) { void Render::rotate(float theta) {
switch(m_matrix_mode) { switch(m_matrix_mode) {
case MODEL: case MODEL:
m_matrix *= rotation_matrix(theta); m_matrix = rotation_matrix(theta) * m_matrix;
break; break;
case PROJECTION: case PROJECTION:
m_view_matrix *= rotation_matrix(theta); m_view_matrix = rotation_matrix(theta) * m_view_matrix;
break; break;
} }
} }
@ -122,10 +122,10 @@ void Render::rotate(float theta) {
void Render::scale(Vector2<float> scale) { void Render::scale(Vector2<float> scale) {
switch(m_matrix_mode) { switch(m_matrix_mode) {
case MODEL: case MODEL:
m_matrix *= scale_matrix(scale); m_matrix = scale_matrix(scale) * m_matrix;
break; break;
case PROJECTION: case PROJECTION:
m_view_matrix *= scale_matrix(scale); m_view_matrix = scale_matrix(scale) * m_view_matrix;
} }
} }