square board and properly fit inside window

This commit is contained in:
2023-09-04 01:57:39 +03:00
parent 2023497beb
commit 4d03b0d3ee
7 changed files with 49 additions and 11 deletions
+14 -5
View File
@@ -3,10 +3,10 @@
#include "shader.h"
static const float quad_vertices[] = {
-0.5f, 1.0f, 0.0f, // top left
0.5f, 1.0f, 0.0f, // top right
-0.5f, -1.0f, 0.0f, // bottom left
0.5f, -1.0f, 0.0f, // bottom right
-1.0f, 1.0f, 0.0f, // top left
1.0f, 1.0f, 0.0f, // top right
-1.0f, -1.0f, 0.0f, // bottom left
1.0f, -1.0f, 0.0f, // bottom right
};
static const int quad_indices[] = {
@@ -34,9 +34,18 @@ unsigned int prepare_bg_rect() {
return vao;
}
void draw_bg_rect(Shader shader, unsigned int vao) {
void draw_bg_rect(Shader shader, unsigned int vao, float x_scale, float y_scale) {
use_shader(shader);
float mat[4][4] = {
{x_scale, 0, 0, 0},
{0, y_scale, 0, 0},
{0, 0, 1, 0},
{0, 0, 0, 1},
};
set_mat4(shader, "transform", (float *)mat);
glBindVertexArray(vao);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);