Fix tests
This commit is contained in:
+21
-42
@@ -1,6 +1,6 @@
|
||||
|
||||
// Red triangle test
|
||||
// ../../../make --graphics vulkan --run
|
||||
// ../../make --run
|
||||
|
||||
let pipeline: iron_gpu_pipeline_t;
|
||||
let vb: any;
|
||||
@@ -8,60 +8,39 @@ let ib: any;
|
||||
|
||||
function render() {
|
||||
_gpu_begin(null, null);
|
||||
|
||||
let flags: i32 = 0;
|
||||
flags |= 1; // Color
|
||||
flags |= 2; // Depth
|
||||
iron_gpu_clear(0xff000000, 1.0, flags);
|
||||
|
||||
iron_gpu_clear(0xff000000, 1.0, clear_flag_t.COLOR | clear_flag_t.DEPTH);
|
||||
iron_gpu_set_pipeline(pipeline);
|
||||
gpu_set_vertex_buffer(vb);
|
||||
gpu_set_index_buffer(ib);
|
||||
gpu_draw_indexed_vertices(0, -1);
|
||||
|
||||
_gpu_end();
|
||||
}
|
||||
|
||||
function main() {
|
||||
let resizable: i32 = 1;
|
||||
let minimizable: i32 = 2;
|
||||
let maximizable: i32 = 4;
|
||||
_iron_init("Iron", 640, 480, true, 0, resizable | minimizable | maximizable, -1, -1, 60);
|
||||
let ops: iron_window_options_t = {
|
||||
title: "Iron",
|
||||
width: 640,
|
||||
height: 480,
|
||||
x: -1,
|
||||
y: -1,
|
||||
mode: window_mode_t.WINDOWED,
|
||||
features: window_features_t.RESIZABLE | window_features_t.MINIMIZABLE | window_features_t.MAXIMIZABLE,
|
||||
vsync: true,
|
||||
frequency: 60,
|
||||
use_depth: true
|
||||
};
|
||||
_iron_init(ops);
|
||||
|
||||
pipeline = gpu_create_pipeline();
|
||||
let f32_3x: vertex_data_t = vertex_data_t.F32_3X;
|
||||
let elem: iron_gpu_vertex_element_t = { name: "pos", data: f32_3x };
|
||||
let elems: iron_gpu_vertex_element_t[] = [elem];
|
||||
|
||||
let structure0: iron_gpu_vertex_structure_t = { elements: elems };
|
||||
|
||||
let vs_buffer: buffer_t = iron_load_blob("./data/test.vert.spirv");
|
||||
let fs_buffer: buffer_t = iron_load_blob("./data/test.frag.spirv");
|
||||
|
||||
let vs: iron_gpu_vertex_structure_t = gpu_vertex_struct_create();
|
||||
gpu_vertex_struct_add(vs, "pos", vertex_data_t.F32_3X);
|
||||
let vs_buffer: buffer_t = iron_load_blob("./data/test.vert" + sys_shader_ext());
|
||||
let fs_buffer: buffer_t = iron_load_blob("./data/test.frag" + sys_shader_ext());
|
||||
let vert: any = gpu_create_shader(vs_buffer, shader_type_t.VERTEX);
|
||||
let frag: any = gpu_create_shader(fs_buffer, shader_type_t.FRAGMENT);
|
||||
|
||||
let masks: bool[] = [true, true, true, true, true, true, true, true];
|
||||
let attachments: i32[] = [0];
|
||||
|
||||
pipeline.cull_mode = 0;
|
||||
pipeline.depth_write = false;
|
||||
pipeline.depth_mode = 0;
|
||||
pipeline.blend_source = 0;
|
||||
pipeline.blend_destination = 0;
|
||||
pipeline.alpha_blend_source = 0;
|
||||
pipeline.alpha_blend_destination = 0;
|
||||
pipeline.color_write_mask_red = masks;
|
||||
pipeline.color_write_mask_green = masks;
|
||||
pipeline.color_write_mask_blue = masks;
|
||||
pipeline.color_write_mask_alpha = masks;
|
||||
pipeline.color_attachment_count = 1;
|
||||
pipeline.color_attachment = attachments;
|
||||
pipeline.depth_attachment_bits = 0;
|
||||
pipeline.vertex_shader = vert;
|
||||
pipeline.fragment_shader = frag;
|
||||
pipeline.input_layout = structure0;
|
||||
|
||||
pipeline.input_layout = vs;
|
||||
gpu_compile_pipeline(pipeline);
|
||||
|
||||
let vertices: f32[] = [
|
||||
@@ -71,7 +50,7 @@ function main() {
|
||||
];
|
||||
let indices: i32[] = [0, 1, 2];
|
||||
|
||||
vb = gpu_create_vertex_buffer(vertices.length / 3, structure0.elements, 0);
|
||||
vb = gpu_create_vertex_buffer(vertices.length / 3, vs.elements, 0);
|
||||
let vb_data: buffer_t = gpu_lock_vertex_buffer(vb);
|
||||
for (let i: i32 = 0; i < vertices.length; i++) {
|
||||
buffer_set_f32(vb_data, i * 4, vertices[i]);
|
||||
|
||||
Reference in New Issue
Block a user