System.register(["./imgui_impl", "imgui-js", "pixi.js", "./utils"], 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_impl_1, ImGui, imgui_js_1, imgui_js_2, PIXI, U, 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);
ImGui_Impl.PrePIXIInit();
let settings = { width: 1, height: 1, antialias: true, backgroundColor: U.vec2col(clearColor), floatTexInternalFormat: PIXI.FLOAT_FORMATS.RGBA16F };
let app = new PIXI.Application(settings);
const output = document.getElementById("output") || document.body;
output.appendChild(app.view);
app.view.tabIndex = 1;
app.view.style.position = "absolute";
app.view.style.left = "0px";
app.view.style.right = "0px";
app.view.style.top = "0px";
app.view.style.bottom = "0px";
app.view.style.width = "100%";
app.view.style.height = "100%";
ImGui_Impl.Init(app);
ImGui.StyleColorsLight();
ImGui_Impl.CreateDeviceObjects();
app.ticker.add((deltaTime) => {
const dt = deltaTime * 1 / (1000 * PIXI.settings.TARGET_FPMS);
app.render();
});
let resizeFunc = function () {
app.renderer.resize(window.innerWidth, window.innerHeight);
};
let bg = new PIXI.Graphics();
bg.beginFill(0xFF0000);
bg.drawRect(0, 0, 600, 600);
bg.endFill();
const imgui = new imgui_impl_1.ImGuiWindow(512, 512, update);
app.stage.addChild(bg);
app.stage.addChild(imgui);
window.onresize = resizeFunc;
resizeFunc();
}
function update(timeElapsed) {
ImGui.SetNextWindowPos(new imgui_js_2.ImVec2(0, 0));
ImGui.SetNextWindowSize(new imgui_js_2.ImVec2(600, 400), ImGui.ImGuiCond.Always);
ImGui.Begin("Test Window");
if (ImGui.Button("Add Text")) {
text += "A";
}
ImGui.Text(text);
ImGui.End();
}
return {
setters: [
function (ImGui_Impl_1) {
ImGui_Impl = ImGui_Impl_1;
imgui_impl_1 = ImGui_Impl_1;
},
function (ImGui_1) {
ImGui = ImGui_1;
imgui_js_1 = ImGui_1;
imgui_js_2 = ImGui_1;
},
function (PIXI_1) {
PIXI = PIXI_1;
},
function (U_1) {
U = U_1;
}
],
execute: function () {
clearColor = new imgui_js_1.ImVec4(0.7, 0.9, 1, 1);
windowOpen = true;
text = "text";
(function () {
if (document.readyState == "complete") {
main();
}
else {
window.onload = main;
}
})();
}
};
});
//# sourceMappingURL=main.js.map