• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
3* Licensed under the Apache License, Version 2.0 (the "License");
4* you may not use this file except in compliance with the License.
5* You may obtain a copy of the License at
6*
7* http://www.apache.org/licenses/LICENSE-2.0
8*
9* Unless required by applicable law or agreed to in writing, software
10* distributed under the License is distributed on an "AS IS" BASIS,
11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12* See the License for the specific language governing permissions and
13* limitations under the License.
14*/
15
16import { Scr } from "./engine/XDefine.js"
17import { GLFrame } from "./engine/GLFrame.js"
18import { X2DFast } from "./engine/graphics/X2DFast.js"
19import { RandInt } from "./engine/XTools.js"
20import { XTexture } from "./engine/graphics/XTexture.js";
21const { NapiLog } = require("./hcs/NapiLog");
22const { MainEditor } = require("./MainEditor");
23
24let canvas = document.getElementById("visual_area");
25canvas.width = window.innerWidth - 200
26canvas.height = window.innerHeight
27
28function myDraw() {
29    if (canvas.width != window.innerWidth - 200 ||
30        canvas.height != window.innerHeight) {
31
32        canvas.width = window.innerWidth - 200
33        canvas.height = window.innerHeight
34
35        Scr.setLogicScreenSize(canvas.width, canvas.height)
36        GLFrame.gi().resize();
37    }
38
39    let pm2f = X2DFast.gi()
40    pm2f.swapMode2D();
41    pm2f.clearBuffer();
42
43    MainEditor.gi().draw(pm2f);
44
45    pm2f.freshBuffer();
46}
47
48function myTouch(msg, x, y) {
49    MainEditor.gi().onTouch(msg, x, y)
50}
51
52function myKey(type, code) {
53    NapiLog.logError(type + code);
54    MainEditor.gi().onKey(code)
55}
56
57Scr.setLogicScreenSize(canvas.width, canvas.height)
58GLFrame.gi().go(canvas, myDraw, myTouch, myKey)