From 797cac35c4e2af09aac36ae1dde6a0844ce705fa Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Tue, 31 Oct 2023 11:37:58 +0400 Subject: [PATCH] Cleanup debug --- examples/main.ts | 75 +++++++++++++++++++---------------------------- package-lock.json | 8 ++--- package.json | 2 +- 3 files changed, 35 insertions(+), 50 deletions(-) diff --git a/examples/main.ts b/examples/main.ts index 79fe8aa..789adfe 100644 --- a/examples/main.ts +++ b/examples/main.ts @@ -2,55 +2,48 @@ import Img from 'image-raub'; import gl from 'webgl-raub'; -import glfw, { Document, platformDevice } from 'glfw-raub'; +import { Document } from 'glfw-raub'; import { View } from 'qml-raub'; Document.setWebgl(gl); const document = new Document({ vsync: true, autoEsc: true }); +const release = () => document.makeCurrent(); const icon = new Img(__dirname + '/qml.png'); icon.on('load', () => { document.icon = (icon as unknown as typeof document.icon); }); document.title = 'QML'; -console.log('p', document.platformContext, document.platformWindow, document.platformDevice); - -const release = () => document.makeCurrent(); - -release(); View.init(process.cwd(), document.platformWindow, document.platformContext, document.platformDevice); const ui = new View({ width: document.w, height: document.h, file: 'qml/gui.qml' }); release(); -// document.on('mousedown', ui.mousedown.bind(ui)); -// document.on('mouseup', ui.mouseup.bind(ui)); -// document.on('mousemove', ui.mousemove.bind(ui)); -// document.on('keydown', ui.keydown.bind(ui)); -// document.on('keyup', ui.keyup.bind(ui)); -// document.on('wheel', ui.wheel.bind(ui)); - -// document.on('resize', ({width, height}) => ui.wh = [width, height]); - -// ui.on('mousedown', e => console.log('[>mousedown]', e)); -// ui.on('mouseup', e => console.log('[>mouseup]', e)); -// // ui.on('mousemove', e => console.log('[mousemove]', e)); -// ui.on('keydown', e => console.log('[>keydown]', e)); -// ui.on('keyup', e => console.log('[>keyup]', e)); -// ui.on('wheel', e => console.log('[>wheel]', e)); - -// ui.on('ohai', data => { -// console.log('RECV', data); -// ui.set('myButton1', 'text', `${Date.now()}`); -// ui.invoke('myButton1', 'func', [{ uid: 'dwad2312414', value: 17 }]); -// }); - -// let texture = gl.createTexture(); +document.on('mousedown', ui.mousedown.bind(ui)); +document.on('mouseup', ui.mouseup.bind(ui)); +document.on('mousemove', ui.mousemove.bind(ui)); +document.on('keydown', ui.keydown.bind(ui)); +document.on('keyup', ui.keyup.bind(ui)); +document.on('wheel', ui.wheel.bind(ui)); + +document.on('resize', ({width, height}) => ui.wh = [width, height]); + +ui.on('mousedown', e => console.log('[>mousedown]', e)); +ui.on('mouseup', e => console.log('[>mouseup]', e)); +// ui.on('mousemove', e => console.log('[mousemove]', e)); +ui.on('keydown', e => console.log('[>keydown]', e)); +ui.on('keyup', e => console.log('[>keyup]', e)); +ui.on('wheel', e => console.log('[>wheel]', e)); + +ui.on('ohai', data => { + console.log('RECV', data); + ui.set('myButton1', 'text', `${Date.now()}`); + ui.invoke('myButton1', 'func', [{ uid: 'dwad2312414', value: 17 }]); +}); + let texture = ui.textureId === null ? gl.createTexture() : new gl.WebGLTexture(ui.textureId); -console.log('tid0', ui.textureId); -// let texture = new gl.WebGLTexture(ui.textureId || 0); + ui.on('reset', (texId: number) => { - console.log('tid1', texId); release(); texture = texId ? new gl.WebGLTexture(texId) : gl.createTexture(); }); @@ -85,8 +78,7 @@ const shaders = { uniform vec2 size; void main() { vec2 uv = gl_FragCoord.xy / size.xy; - // gl_FragColor = texture2D(tex, uv); - gl_FragColor = (vec4(1.0, 0.0, 0.0, 1.0) + texture2D(tex, uv)) * 0.5; + gl_FragColor = texture2D(tex, uv); } `, } as const; @@ -194,26 +186,19 @@ const drawScene = () => { const tick = () => { setTimeout(tick, 16); - // View.update(); + View.update(); release(); drawScene(); - // (glfw.testScene as (w: number, h: number) => void)(document.width, document.height); - document.swapBuffers(); - - glfw.pollEvents(); - - - - // requestAnimFrame(tick); + requestAnimFrame(tick); }; const start = () => { initShaders(); initBuffers(); - // gl.clearColor(0.0, 1.0, 0.0, 1.0); - // gl.enable(gl.DEPTH_TEST); + gl.clearColor(0.0, 0.0, 0.0, 1.0); + gl.enable(gl.DEPTH_TEST); tick(); }; diff --git a/package-lock.json b/package-lock.json index de5f88f..370d39b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "MIT", "dependencies": { "addon-tools-raub": "^7.4.0", - "deps-qmlui-raub": "^3.1.0", + "deps-qmlui-raub": "^3.1.1", "segfault-raub": "^2.1.2" }, "devDependencies": { @@ -361,9 +361,9 @@ "dev": true }, "node_modules/deps-qmlui-raub": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/deps-qmlui-raub/-/deps-qmlui-raub-3.1.0.tgz", - "integrity": "sha512-Qzsfr4e80UyHaQhNN8ROcXBcf3BR3qKugsWC4J86uFHJc/zhvvTJMOqINdfMGN7cfIAs+qCrw4p7FsF2EtVz4Q==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/deps-qmlui-raub/-/deps-qmlui-raub-3.1.1.tgz", + "integrity": "sha512-QM1KzEN0mvIFz4W8EoeTBpfOAbxh7GIinj2uGzvZvNnwu4OavJlIAnXASlhQ10Cun7/VpTB2cDe0qKTsMEyinA==", "hasInstallScript": true, "dependencies": { "addon-tools-raub": "^7.4.0", diff --git a/package.json b/package.json index 73ca8ea..be32b98 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ }, "dependencies": { "addon-tools-raub": "^7.4.0", - "deps-qmlui-raub": "^3.1.0", + "deps-qmlui-raub": "^3.1.1", "segfault-raub": "^2.1.2" }, "devDependencies": {