• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2023 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';
19const { NapiLog } = require('./ir/NapiLog');
20const { MainEditor } = require('./MainEditor');
21
22let canvas = document.getElementById('visual_area');
23const sideWidth = 0;//420;
24canvas.width = window.innerWidth - sideWidth;
25canvas.height = window.innerHeight;
26
27function myDraw() {
28  if (
29    canvas.width != window.innerWidth - sideWidth ||
30    canvas.height != window.innerHeight
31  ) {
32    canvas.width = window.innerWidth - sideWidth;
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().onDraw(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  MainEditor.gi().onKey(code);
54}
55
56Scr.setLogicScreenSize(canvas.width, canvas.height);
57GLFrame.gi().go(canvas, myDraw, myTouch, myKey);
58