diff --git a/gpu.h b/gpu.h index 8fb4572..8dbb314 100644 --- a/gpu.h +++ b/gpu.h @@ -6,12 +6,11 @@ #define SWAPCHAIN_IMG_BUFFER_SIZE 4 -typedef float vec2_t[3]; typedef float vec3_t[3]; typedef float mat4_t[16]; typedef struct { - vec2_t position; + vec3_t position; vec3_t colour; } vertex_t; diff --git a/main.c b/main.c index b372f9b..37a3c46 100644 --- a/main.c +++ b/main.c @@ -13,13 +13,15 @@ #define H 600 static const vertex_t vertices[] = { - { { -1, -1 }, { 1, 0, 0 } }, - { { 1, -1 }, { 0, 1, 0 } }, - { { 1, 1 }, { 0, 0, 1 } }, - { { -1, 1 }, { 1, 1, 1 } }, + { { 0.000, 0.612, 0.000 }, { 1, 0, 0 } }, + { { -0.500, -0.204, -0.289 }, { 0, 1, 0 } }, + { { 0.500, -0.204, -0.289 }, { 0, 0, 1 } }, + { { 0.000, -0.204, 0.577 }, { 1, 1, 1 } }, }; -static const uint16_t indices[] = { 0, 1, 2, 2, 3, 0 }; +static const uint16_t indices[] = { + 0, 3, 1, 0, 1, 2, 0, 2, 3, 3, 2, 1, +}; typedef enum { AXIS_X, @@ -159,7 +161,7 @@ int main() gpu_init(&gpu, &gpu_config); mvp_t mvp = { - .model = ID, + .model = SCALE(2), .view = TRANSLATE(0, 0, 4.0), }; persp(mvp.proj, (float)W / H, M_PI / 6, 0.1, 10.0); diff --git a/vert.glsl b/vert.glsl index 1b02ecb..5839af9 100644 --- a/vert.glsl +++ b/vert.glsl @@ -1,6 +1,6 @@ #version 450 -layout(location = 0) in vec2 pos; +layout(location = 0) in vec3 pos; layout(location = 1) in vec3 colour; layout(location = 0) out vec3 frag_colour; @@ -12,6 +12,6 @@ layout(push_constant) uniform MVP { } mvp; void main() { - gl_Position = mvp.proj * mvp.view * mvp.model * vec4(pos, 0.0, 1.0); + gl_Position = mvp.proj * mvp.view * mvp.model * vec4(pos, 1.0); frag_colour = colour; }