Switch to 3D geometry
This commit is contained in:
1 parent
4180c4549b
commit
7f4dffc7fb
3 files changed
+11
-10
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user