Path: blob/master/platform/web/js/libs/library_godot_webgl2.js
10279 views
/**************************************************************************/1/* library_godot_webgl2.js */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930const GodotWebGL2 = {31$GodotWebGL2__deps: ['$GL', '$GodotRuntime'],32$GodotWebGL2: {},3334// This is implemented as "glGetBufferSubData" in new emscripten versions.35// Since we have to support older (pre 2.0.17) emscripten versions, we add this wrapper function instead.36godot_webgl2_glGetBufferSubData__proxy: 'sync',37godot_webgl2_glGetBufferSubData__sig: 'vippp',38godot_webgl2_glGetBufferSubData__deps: ['$GL', 'emscripten_webgl_get_current_context'],39godot_webgl2_glGetBufferSubData: function (target, offset, size, data) {40const gl_context_handle = _emscripten_webgl_get_current_context();41const gl = GL.getContext(gl_context_handle);42if (gl) {43gl.GLctx['getBufferSubData'](target, offset, HEAPU8, data, size);44}45},4647godot_webgl2_glFramebufferTextureMultiviewOVR__deps: ['emscripten_webgl_get_current_context'],48godot_webgl2_glFramebufferTextureMultiviewOVR__proxy: 'sync',49godot_webgl2_glFramebufferTextureMultiviewOVR__sig: 'viiiiii',50godot_webgl2_glFramebufferTextureMultiviewOVR: function (target, attachment, texture, level, base_view_index, num_views) {51const context = GL.currentContext;52if (typeof context.multiviewExt === 'undefined') {53const /** OVR_multiview2 */ ext = context.GLctx.getExtension('OVR_multiview2');54if (!ext) {55GodotRuntime.error('Trying to call glFramebufferTextureMultiviewOVR() without the OVR_multiview2 extension');56return;57}58context.multiviewExt = ext;59}60const /** OVR_multiview2 */ ext = context.multiviewExt;61ext.framebufferTextureMultiviewOVR(target, attachment, GL.textures[texture], level, base_view_index, num_views);62},6364godot_webgl2_glFramebufferTextureMultisampleMultiviewOVR__deps: ['emscripten_webgl_get_current_context'],65godot_webgl2_glFramebufferTextureMultisampleMultiviewOVR__proxy: 'sync',66godot_webgl2_glFramebufferTextureMultisampleMultiviewOVR__sig: 'viiiiiii',67godot_webgl2_glFramebufferTextureMultisampleMultiviewOVR: function (target, attachment, texture, level, samples, base_view_index, num_views) {68const context = GL.currentContext;69if (typeof context.oculusMultiviewExt === 'undefined') {70const /** OCULUS_multiview */ ext = context.GLctx.getExtension('OCULUS_multiview');71if (!ext) {72GodotRuntime.error('Trying to call glFramebufferTextureMultisampleMultiviewOVR() without the OCULUS_multiview extension');73return;74}75context.oculusMultiviewExt = ext;76}77const /** OCULUS_multiview */ ext = context.oculusMultiviewExt;78ext.framebufferTextureMultisampleMultiviewOVR(target, attachment, GL.textures[texture], level, samples, base_view_index, num_views);79},80};8182autoAddDeps(GodotWebGL2, '$GodotWebGL2');83mergeInto(LibraryManager.library, GodotWebGL2);848586