adding gfx and ui stuff
This commit is contained in:
102
gfx/geometry.c
Normal file
102
gfx/geometry.c
Normal file
@@ -0,0 +1,102 @@
|
||||
#include "geometry.h"
|
||||
#include "gfx-common.h"
|
||||
#include "../core.h"
|
||||
|
||||
// Buffer layout:
|
||||
// X, Y, Z, U, V
|
||||
|
||||
const FloatList triangle_vertices = AsList(FloatList, {
|
||||
-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,
|
||||
});
|
||||
|
||||
const UInt32List triangle_indices = AsList(UInt32List, {
|
||||
0, 1, 2
|
||||
});
|
||||
|
||||
const FloatList cube_vertices = AsList(FloatList, {
|
||||
-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
|
||||
});
|
||||
|
||||
const UInt32List cube_indices = AsList(UInt32List, {
|
||||
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
|
||||
});
|
||||
|
||||
const FloatList square_xyz = AsList(FloatList, {
|
||||
200.0f, 200.0f, 0.0f,
|
||||
200.0f, -200.0f, 0.0f,
|
||||
-200.0f, -200.0f, 0.0f,
|
||||
-200.0f, 200.0f, 0.0f,
|
||||
});
|
||||
|
||||
const FloatList square_uv = AsList(FloatList, {
|
||||
1.0f, 1.0f,
|
||||
1.0f, 0.0f,
|
||||
0.0f, 0.0f,
|
||||
0.0f, 1.0f,
|
||||
});
|
||||
|
||||
const UInt32List square_indices = AsList(UInt32List, {
|
||||
0, 1, 3,
|
||||
1, 2, 3,
|
||||
});
|
||||
|
||||
const Shape TRIANGLE = {
|
||||
triangle_indices,
|
||||
triangle_vertices,
|
||||
triangle_vertices,
|
||||
};
|
||||
|
||||
const Shape SQUARE = {
|
||||
square_indices,
|
||||
square_uv,
|
||||
square_xyz,
|
||||
};
|
||||
|
||||
const Shape CUBE = {
|
||||
cube_indices,
|
||||
triangle_vertices,
|
||||
triangle_vertices,
|
||||
};
|
||||
Reference in New Issue
Block a user