Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update version of gl.js to 0.1.23 #16

Merged
merged 1 commit into from
Mar 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 59 additions & 42 deletions docs/gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

"use strict";

const version = "0.1.22";
const version = "0.1.23";

const canvas = document.querySelector("#glcanvas");
const gl = canvas.getContext("webgl");
Expand Down Expand Up @@ -547,7 +547,7 @@ function into_sapp_keycode(key_code) {
console.log("Unsupported keyboard key: ", key_code)
}

function dpi_scale() {
function dpi_scale() {
if (high_dpi) {
return window.devicePixelRatio || 1.0;
} else {
Expand Down Expand Up @@ -599,7 +599,7 @@ var importObject = {
set_emscripten_shader_hack: function (flag) {
emscripten_shaders_hack = flag;
},
sapp_set_clipboard: function (ptr, len) {
sapp_set_clipboard: function(ptr, len) {
clipboard = UTF8ToString(ptr, len);
},
dpi_scale,
Expand Down Expand Up @@ -651,7 +651,7 @@ var importObject = {
gl.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
pixels ? getArray(pixels, Uint8Array, texture_size(format, width, height)) : null);
},
glReadPixels: function (x, y, width, height, format, type, pixels) {
glReadPixels: function(x, y, width, height, format, type, pixels) {
var pixelData = getArray(pixels, Uint8Array, texture_size(format, width, height));
gl.readPixels(x, y, width, height, format, type, pixelData);
},
Expand Down Expand Up @@ -1019,41 +1019,41 @@ var importObject = {
GL.textures[id] = null;
}
},
glGenQueries: function (n, ids) {
_glGenObject(n, ids, 'createQuery', GL.timerQueries, 'glGenQueries');
},
glDeleteQueries: function (n, ids) {
glGenQueries: function (n, ids) {
_glGenObject(n, ids, 'createQuery', GL.timerQueries, 'glGenQueries');
},
glDeleteQueries: function (n, ids) {
for (var i = 0; i < n; i++) {
var id = getArray(textures + i * 4, Uint32Array, 1)[0];
var query = GL.timerQueries[id];
if (!query) {
continue;
}
continue;
}
gl.deleteQuery(query);
query.name = 0;
GL.timerQueries[id] = null;
}
},
glBeginQuery: function (target, id) {
GL.validateGLObjectID(GL.timerQueries, id, 'glBeginQuery', 'id');
gl.beginQuery(target, GL.timerQueries[id]);
},
glEndQuery: function (target) {
gl.endQuery(target);
},
glGetQueryObjectiv: function (id, pname, ptr) {
GL.validateGLObjectID(GL.timerQueries, id, 'glGetQueryObjectiv', 'id');
let result = gl.getQueryObject(GL.timerQueries[id], pname);
getArray(ptr, Uint32Array, 1)[0] = result;
},
glGetQueryObjectui64v: function (id, pname, ptr) {
GL.validateGLObjectID(GL.timerQueries, id, 'glGetQueryObjectui64v', 'id');
let result = gl.getQueryObject(GL.timerQueries[id], pname);
let heap = getArray(ptr, Uint32Array, 2);
heap[0] = result;
heap[1] = (result - heap[0]) / 4294967296;
},
setup_canvas_size: function (high_dpi) {
},
glBeginQuery: function (target, id) {
GL.validateGLObjectID(GL.timerQueries, id, 'glBeginQuery', 'id');
gl.beginQuery(target, GL.timerQueries[id]);
},
glEndQuery: function (target) {
gl.endQuery(target);
},
glGetQueryObjectiv: function (id, pname, ptr) {
GL.validateGLObjectID(GL.timerQueries, id, 'glGetQueryObjectiv', 'id');
let result = gl.getQueryObject(GL.timerQueries[id], pname);
getArray(ptr, Uint32Array, 1)[0] = result;
},
glGetQueryObjectui64v: function (id, pname, ptr) {
GL.validateGLObjectID(GL.timerQueries, id, 'glGetQueryObjectui64v', 'id');
let result = gl.getQueryObject(GL.timerQueries[id], pname);
let heap = getArray(ptr, Uint32Array, 2);
heap[0] = result;
heap[1] = (result - heap[0])/4294967296;
},
setup_canvas_size: function(high_dpi) {
window.high_dpi = high_dpi;
resize(canvas);
},
Expand Down Expand Up @@ -1170,24 +1170,24 @@ var importObject = {
window.onresize = function () {
resize(canvas, wasm_exports.resize);
};
window.addEventListener("copy", function (e) {
window.addEventListener("copy", function(e) {
if (clipboard != null) {
event.clipboardData.setData('text/plain', clipboard);
event.preventDefault();
}
});
window.addEventListener("cut", function (e) {
window.addEventListener("cut", function(e) {
if (clipboard != null) {
event.clipboardData.setData('text/plain', clipboard);
event.preventDefault();
}
});

window.addEventListener("paste", function (e) {
window.addEventListener("paste", function(e) {
e.stopPropagation();
e.preventDefault();
clipboardData = e.clipboardData || window.clipboardData;
pastedData = clipboardData.getData('Text');
var clipboardData = e.clipboardData || window.clipboardData;
var pastedData = clipboardData.getData('Text');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines fix copy-pasting.


if (pastedData != undefined && pastedData != null && pastedData.length != 0) {
var len = pastedData.length;
Expand Down Expand Up @@ -1249,8 +1249,25 @@ var importObject = {
document.exitPointerLock();
}
},
sapp_set_cursor: function (ptr, len) {
sapp_set_cursor: function(ptr, len) {
canvas.style.cursor = UTF8ToString(ptr, len);
},
sapp_is_fullscreen: function() {
let fullscreenElement = document.fullscreenElement;

return fullscreenElement != null && fullscreenElement.id == canvas.id;
},
sapp_set_fullscreen: function(fullscreen) {
if (!fullscreen) {
document.exitFullscreen();
} else {
canvas.requestFullscreen();
}
},
sapp_set_window_size: function(new_width, new_height) {
canvas.width = new_width;
canvas.height = new_height;
resize(canvas, wasm_exports.resize);
}
}
};
Expand Down Expand Up @@ -1297,11 +1314,11 @@ function init_plugins(plugins) {

if (plugins[i].version != crate_version) {
console.error("Plugin " + plugins[i].name + " version mismatch" +
"js version: " + plugins[i].version + ", crate version: " + crate_version)
"js version: " + plugins[i].version + ", crate version: " + crate_version)
}
}
}
}
}
}


Expand All @@ -1318,7 +1335,7 @@ function add_missing_functions_stabs(obj) {
for (const i in imports) {
if (importObject["env"][imports[i].name] == undefined) {
console.warn("No " + imports[i].name + " function in gl.js");
importObject["env"][imports[i].name] = function () {
importObject["env"][imports[i].name] = function() {
console.warn("Missed function: " + imports[i].name);
};
}
Expand All @@ -1345,7 +1362,7 @@ function load(wasm_path) {
if (version != crate_version) {
console.error(
"Version mismatch: gl.js version is: " + version +
", rust sapp-wasm crate version is: " + crate_version);
", rust sapp-wasm crate version is: " + crate_version);
}
init_plugins(plugins);
obj.exports.main();
Expand All @@ -1370,7 +1387,7 @@ function load(wasm_path) {
if (version != crate_version) {
console.error(
"Version mismatch: gl.js version is: " + version +
", rust sapp-wasm crate version is: " + crate_version);
", rust sapp-wasm crate version is: " + crate_version);
}
init_plugins(plugins);
obj.exports.main();
Expand Down