System.register(["../imgui-js/example/imgui_impl", "imgui-js"], function (exports_1, context_1) { "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var ImGui_Impl, ImGui, imgui_js_1, imgui_js_2, clearColor, windowOpen, text; var __moduleName = context_1 && context_1.id; function main() { return __awaiter(this, void 0, void 0, function* () { console.log("main()"); yield ImGui.default(); window.requestAnimationFrame(init); }); } function init() { console.log("init()"); console.log("Total allocated space (uordblks) @ _init:", ImGui.bind.mallinfo().uordblks); // Setup Dear ImGui binding ImGui.IMGUI_CHECKVERSION(); ImGui.CreateContext(); const io = ImGui.GetIO(); io.ConfigFlags |= ImGui.ConfigFlags.NavEnableKeyboard; // Enable Keyboard Controls // Setup style ImGui.StyleColorsLight(); const output = document.getElementById("output") || document.body; const canvas = document.createElement("canvas"); output.appendChild(canvas); canvas.tabIndex = 1; canvas.style.position = "absolute"; canvas.style.left = "0px"; canvas.style.right = "0px"; canvas.style.top = "0px"; canvas.style.bottom = "0px"; canvas.style.width = "100%"; canvas.style.height = "100%"; ImGui_Impl.Init(canvas); window.requestAnimationFrame(loop); } function render(timeElapsed) { ImGui.SetNextWindowSize(new imgui_js_2.ImVec2(600, 400), ImGui.ImGuiCond.Always); ImGui.Begin("Test Window", (_ = windowOpen) => windowOpen = _, 0); if (ImGui.Button("Add Text")) { text += "A"; } ImGui.Text(text); ImGui.End(); } function loop(timeElapsed) { ImGui_Impl.NewFrame(timeElapsed); ImGui.NewFrame(); render(timeElapsed); ImGui.EndFrame(); // Rendering ImGui.Render(); const gl = ImGui_Impl.gl; if (gl) { gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); gl.clearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w); gl.clear(gl.COLOR_BUFFER_BIT); //gl.useProgram(0); // You may want this if using this code in an OpenGL 3+ context where shaders may be bound } const ctx = ImGui_Impl.ctx; if (ctx) { // ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); ctx.fillStyle = `rgba(${clearColor.x * 0xff}, ${clearColor.y * 0xff}, ${clearColor.z * 0xff}, ${clearColor.w})`; ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height); } ImGui_Impl.RenderDrawData(ImGui.GetDrawData()); window.requestAnimationFrame(loop); } return { setters: [ function (ImGui_Impl_1) { ImGui_Impl = ImGui_Impl_1; }, function (ImGui_1) { ImGui = ImGui_1; imgui_js_1 = ImGui_1; imgui_js_2 = ImGui_1; } ], execute: function () { clearColor = new imgui_js_1.ImVec4(0.7, 0.9, 1, 1); windowOpen = true; text = "text"; (function () { window.onload = main; })(); } }; }); //# sourceMappingURL=main.js.map