calculate help overlay width from text instead of hardcoding it

This commit is contained in:
2023-11-18 03:29:00 +02:00
parent 40f5ccabbe
commit d6cc129bed
3 changed files with 21 additions and 11 deletions
+16 -8
View File
@@ -1,14 +1,18 @@
#include "helper.h"
Matrix4x4 orthographic_projection_2d(float left, float right, float bottom, float top) {
Matrix4x4 result;
Matrix4x4 identity() {
Matrix4x4 result = {0};
// Identity matrix
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
result.m[i][j] = 0.0f;
}
}
result.m[0][0] = 1.0f;
result.m[1][1] = 1.0f;
result.m[2][2] = 1.0f;
result.m[3][3] = 1.0f;
return result;
}
Matrix4x4 orthographic_projection_2d(float left, float right, float bottom, float top) {
Matrix4x4 result = identity();
result.m[0][0] = 2.0f / (right - left);
result.m[3][0] = -(right + left) / (right - left);
@@ -19,3 +23,7 @@ Matrix4x4 orthographic_projection_2d(float left, float right, float bottom, floa
return result;
}
int max(int a, int b) {
return a > b ? a : b;
}