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'; 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 - 420; 26canvas.height = window.innerHeight; 27 28function myDraw() { 29 if ( 30 canvas.width != window.innerWidth - 420 || 31 canvas.height != window.innerHeight 32 ) { 33 canvas.width = window.innerWidth - 420; 34 canvas.height = window.innerHeight; 35 36 Scr.setLogicScreenSize(canvas.width, canvas.height); 37 GLFrame.gi().resize(); 38 } 39 40 let pm2f = X2DFast.gi(); 41 pm2f.swapMode2D(); 42 pm2f.clearBuffer(); 43 44 MainEditor.gi().draw(pm2f); 45 46 pm2f.freshBuffer(); 47} 48 49function myTouch(msg, x, y) { 50 MainEditor.gi().onTouch(msg, x, y); 51} 52 53function myKey(type, code) { 54 NapiLog.logError(type + code); 55 MainEditor.gi().onKey(code); 56} 57 58Scr.setLogicScreenSize(canvas.width, canvas.height); 59GLFrame.gi().go(canvas, myDraw, myTouch, myKey); 60