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