111 lines
2.6 KiB
C++
111 lines
2.6 KiB
C++
#include "geometry.h"
|
|
#include "../lib/djstdlib/core.h"
|
|
|
|
// Buffer layout:
|
|
// X, Y, Z, U, V
|
|
|
|
real32 triangle_vertices[] = {
|
|
-0.5f, -0.5f, 0.0f, 1.0f, 1.0f,
|
|
0.5f, -0.5f, 0.0f, 0.5f, 0.5f,
|
|
0.0f, 0.5f, 0.0f, 0.0f, 0.0f,
|
|
};
|
|
|
|
uint32 triangle_indices[] = {
|
|
0, 1, 2
|
|
};
|
|
|
|
real32 cube_vertices[] = {
|
|
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
|
|
0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
|
|
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
|
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
|
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
|
|
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
|
|
|
|
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
|
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
|
|
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
|
|
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
|
|
-0.5f, 0.5f, 0.5f, 0.0f, 1.0f,
|
|
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
|
|
|
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
-0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
|
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
|
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
|
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
|
-0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
|
|
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
|
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
|
0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
|
0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
|
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
|
|
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
|
0.5f, -0.5f, -0.5f, 1.0f, 1.0f,
|
|
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
|
|
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
|
|
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
|
|
-0.5f, -0.5f, -0.5f, 0.0f, 1.0f,
|
|
|
|
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
|
|
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
|
|
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
0.5f, 0.5f, 0.5f, 1.0f, 0.0f,
|
|
-0.5f, 0.5f, 0.5f, 0.0f, 0.0f,
|
|
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f
|
|
};
|
|
|
|
uint32 cube_indices[] = {
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
|
|
17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
|
|
};
|
|
|
|
real32 square_xyz[] = {
|
|
200.0f, 200.0f, 0.0f,
|
|
200.0f, -200.0f, 0.0f,
|
|
-200.0f, -200.0f, 0.0f,
|
|
-200.0f, 200.0f, 0.0f,
|
|
};
|
|
|
|
real32 square_uv[] = {
|
|
1.0f, 1.0f,
|
|
1.0f, 0.0f,
|
|
0.0f, 0.0f,
|
|
0.0f, 1.0f,
|
|
};
|
|
|
|
uint32 square_indices[] = {
|
|
0, 1, 3,
|
|
1, 2, 3,
|
|
};
|
|
|
|
const Shape TRIANGLE = {
|
|
triangle_indices,
|
|
ArrayCount(triangle_indices),
|
|
triangle_vertices,
|
|
ArrayCount(triangle_vertices),
|
|
triangle_vertices,
|
|
ArrayCount(triangle_vertices),
|
|
};
|
|
|
|
const Shape SQUARE = {
|
|
square_indices,
|
|
ArrayCount(square_indices),
|
|
square_uv,
|
|
ArrayCount(square_uv),
|
|
square_xyz,
|
|
ArrayCount(square_xyz),
|
|
};
|
|
|
|
const Shape CUBE = {
|
|
cube_indices,
|
|
ArrayCount(cube_indices),
|
|
triangle_vertices,
|
|
ArrayCount(triangle_vertices),
|
|
triangle_vertices,
|
|
ArrayCount(triangle_vertices),
|
|
};
|