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

Fixes some WebGL types #4197

Merged
merged 4 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion src/graphics/shader-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ShaderInput {
* @param {GraphicsDevice} graphicsDevice - The graphics device used to manage this shader input.
* @param {string} name - The name of the shader input.
* @param {number} type - The type of the shader input.
* @param {number} locationId - The location id of the shader input.
* @param {number | WebGLUniformLocation} locationId - The location id of the shader input.
*/
constructor(graphicsDevice, name, type, locationId) {
// Set the shader attribute location
Expand Down
2 changes: 1 addition & 1 deletion src/graphics/webgl/webgl-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ class WebglGraphicsDevice extends GraphicsDevice {
/**
* Binds the specified framebuffer object.
*
* @param {WebGLFramebuffer} fb - The framebuffer to bind.
* @param {WebGLFramebuffer | null} fb - The framebuffer to bind.
* @ignore
*/
setFramebuffer(fb) {
Expand Down
14 changes: 8 additions & 6 deletions src/graphics/webgl/webgl-shader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Preprocessor } from '../../core/preprocessor.js';
import { ShaderInput } from '../shader-input.js';
import { SHADERTAG_MATERIAL, semanticToLocation } from '../constants.js';

/** @typedef {import('../graphics-device.js').GraphicsDevice} GraphicsDevice */
/** @typedef {import('./webgl-graphics-device.js').WebglGraphicsDevice} WebglGraphicsDevice */
/** @typedef {import('../shader.js').Shader} Shader */

/**
Expand Down Expand Up @@ -34,6 +34,8 @@ class WebglShader {
* @param {Shader} shader - The shader to free.
*/
destroy(shader) {
/** @type {WebglGraphicsDevice} */
// @ts-ignore
mvaligursky marked this conversation as resolved.
Show resolved Hide resolved
const device = shader.device;
const idx = device.shaders.indexOf(shader);
if (idx !== -1) {
Expand All @@ -50,7 +52,7 @@ class WebglShader {
/**
* Restore shader after the context has been obtained.
*
* @param {GraphicsDevice} device - The graphics device.
* @param {WebglGraphicsDevice} device - The graphics device.
* @param {Shader} shader - The shader to restore.
*/
restoreContext(device, shader) {
Expand All @@ -60,7 +62,7 @@ class WebglShader {
/**
* Compile and link a shader program.
*
* @param {GraphicsDevice} device - The graphics device.
* @param {WebglGraphicsDevice} device - The graphics device.
* @param {Shader} shader - The shader to compile.
*/
compileAndLink(device, shader) {
Expand Down Expand Up @@ -173,7 +175,7 @@ class WebglShader {
/**
* Extract attribute and uniform information from a successfully linked shader.
*
* @param {GraphicsDevice} device - The graphics device.
* @param {WebglGraphicsDevice} device - The graphics device.
* @param {Shader} shader - The shader to query.
* @returns {boolean} True if the shader was successfully queried and false otherwise.
*/
Expand Down Expand Up @@ -265,7 +267,7 @@ class WebglShader {
/**
* Check the compilation status of a shader.
*
* @param {GraphicsDevice} device - The graphics device.
* @param {WebglGraphicsDevice} device - The graphics device.
* @param {Shader} shader - The shader to query.
* @param {WebGLShader} glShader - The WebGL shader.
* @param {string} source - The shader source code.
Expand Down Expand Up @@ -297,7 +299,7 @@ class WebglShader {
*
* @param {string} src - The shader source code.
* @param {string} infoLog - The info log returned from WebGL on a failed shader compilation.
* @returns {Array} An array where the first element is the 10 lines of code around the first
* @returns {[string, {message?: string, line?: number, source?: string}]} A tuple where the first element is the 10 lines of code around the first
* detected error, and the second element an object storing the error messsage, line number and
* complete shader source.
* @private
Expand Down