main.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // ../../make --run
  2. function main() {
  3. let ops: iron_window_options_t = {
  4. title : "Empty",
  5. width : 1280,
  6. height : 720,
  7. x : -1,
  8. y : -1,
  9. features : window_features_t.RESIZABLE | window_features_t.MINIMIZABLE | window_features_t.MAXIMIZABLE,
  10. mode : iron_window_mode_t.WINDOW,
  11. frequency : 60,
  12. vsync : true,
  13. depth_bits : 32
  14. };
  15. sys_start(ops);
  16. ready();
  17. }
  18. function render_commands() {
  19. render_path_set_target("", null, null, gpu_clear_t.COLOR | gpu_clear_t.DEPTH, 0xff6495ed, 1.0);
  20. render_path_draw_meshes("mesh");
  21. }
  22. function ready() {
  23. render_path_commands = render_commands;
  24. let scene: scene_t = {
  25. name : "Scene",
  26. objects : [
  27. {name : "Cube", type : "mesh_object", data_ref : "cube.arm/Cube", material_ref : "MyMaterial", visible : true, spawn : true},
  28. {name : "Camera", type : "camera_object", data_ref : "MyCamera", visible : true, spawn : true}
  29. ],
  30. camera_datas : [ {name : "MyCamera", near_plane : 0.1, far_plane : 100.0, fov : 0.85} ],
  31. camera_ref : "Camera",
  32. material_datas :
  33. [ {name : "MyMaterial", shader : "MyShader", contexts : [ {name : "mesh", bind_textures : [ {name : "my_texture", file : "texture.k"} ]} ]} ],
  34. shader_datas : [ {
  35. name : "MyShader",
  36. contexts : [ {
  37. name : "mesh",
  38. vertex_shader : "mesh.vert",
  39. fragment_shader : "mesh.frag",
  40. compare_mode : "less",
  41. cull_mode : "clockwise",
  42. depth_write : true,
  43. vertex_elements : [ {name : "pos", data : "short4norm"}, {name : "tex", data : "short2norm"} ],
  44. constants : [ {name : "WVP", type : "mat4", link : "_world_view_proj_matrix"} ],
  45. texture_units : [ {name : "my_texture"} ]
  46. } ]
  47. } ]
  48. };
  49. map_set(data_cached_scene_raws, scene.name, scene);
  50. // Instantiate scene
  51. scene_create(scene);
  52. scene_ready();
  53. }
  54. function scene_ready() {
  55. // Set camera
  56. let t: transform_t = scene_camera.base.transform;
  57. t.loc = vec4_create(0, -6, 0);
  58. t.rot = quat_from_to(vec4_create(0, 0, 1), vec4_create(0, -1, 0));
  59. transform_build_matrix(t);
  60. // Rotate cube
  61. sys_notify_on_update(spin_cube);
  62. }
  63. function spin_cube(_: any) {
  64. let cube: object_t = scene_get_child("Cube");
  65. transform_rotate(cube.transform, vec4_create(0, 0, 1), 0.01);
  66. }
  67. ////
  68. type config_t = {
  69. server: string;
  70. };
  71. let config_raw: config_t;
  72. function strings_check_internet_connection(): string {
  73. return "";
  74. }
  75. function console_error(s: string) {}
  76. function console_info(s: string) {}
  77. function plugin_embed() {}
  78. function tr(id: string, vars: map_t<string, string> = null): string {
  79. return id;
  80. }
  81. let pipes_offset: i32;
  82. function pipes_get_constant_location(s: string): i32 {
  83. return 0;
  84. }