Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,33 @@ class CompressedTextureDisplay extends Renderable {
return true;
}

/** @ignore */
drawText(
renderer: WebGLRenderer | CanvasRenderer,
font: Text,
text: string,
x: number,
y: number,
) {
font.pos.set(x, y);
font.setText(text);
font.preDraw(renderer);
font.draw(renderer);
font.postDraw(renderer);
Comment thread
obiot marked this conversation as resolved.
}

override draw(renderer: WebGLRenderer | CanvasRenderer) {
let y = 10;
const x = 10;

// Title
this.titleFont.draw(renderer, "Compressed Texture Format Support", x, y);
this.drawText(
renderer,
this.titleFont,
"Compressed Texture Format Support",
x,
y,
);
y += 32;

// Format support table
Expand All @@ -163,8 +184,9 @@ class CompressedTextureDisplay extends Renderable {
const supported =
this.formats[key] !== null && this.formats[key] !== undefined;
this.font.fillStyle.parseCSS(supported ? "#4ade80" : "#f87171");
this.font.draw(
this.drawText(
renderer,
this.font,
`${label}: ${supported ? "supported" : "not available"}`,
x,
y,
Expand All @@ -179,14 +201,21 @@ class CompressedTextureDisplay extends Renderable {
entry.sprite.postDraw(renderer);

this.smallFont.fillStyle.parseCSS("#94a3b8");
this.smallFont.draw(renderer, entry.label, entry.x, entry.y + 60);
this.drawText(
renderer,
this.smallFont,
entry.label,
entry.x,
entry.y + 60,
);
}

// Footer info
const footerY = game.viewport.height - 40;
this.font.fillStyle.parseCSS("#64748b");
this.font.draw(
this.drawText(
renderer,
this.font,
`${this.sprites.length} compressed texture(s) loaded. Assets: sevmeyer/ktxtest (CC0).`,
x,
footerY,
Expand Down
9 changes: 9 additions & 0 deletions packages/melonjs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [19.1.0] (melonJS 2) - _2026-04-15_

### Changed
- WebGL: `CanvasRenderTarget` internal default for `failIfMajorPerformanceCaveat` changed from `true` to `false` — allows WebGL context creation on machines with blocklisted GPU drivers when creating render targets directly. Application default remains `true`; set `failIfMajorPerformanceCaveat: false` in Application options to opt in.

Comment thread
obiot marked this conversation as resolved.
### Fixed
- WebGL: `getSupportedCompressedTextureFormats()` no longer crashes when the GL context is unavailable — falls back to the base renderer's empty format list
- Examples: compressed textures example updated to use `setText()`/`preDraw()`/`draw()`/`postDraw()` pattern — fixes text not rendering after `Text.draw()` standalone removal in 19.0

## [19.0.0] (melonJS 2) - _2026-04-14_

### Added
Expand Down
2 changes: 1 addition & 1 deletion packages/melonjs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "melonjs",
"version": "19.0.0",
"version": "19.1.0",
"description": "melonJS Game Engine",
"homepage": "http://www.melonjs.org/",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const defaultAttributes = {
premultipliedAlpha: true,
stencil: true,
blendMode: "normal",
failIfMajorPerformanceCaveat: true,
failIfMajorPerformanceCaveat: false,
preferWebGL1: false,
powerPreference: "default",
Comment thread
obiot marked this conversation as resolved.
};
Expand Down
4 changes: 4 additions & 0 deletions packages/melonjs/src/video/webgl/webgl_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@ export default class WebGLRenderer extends Renderer {
getSupportedCompressedTextureFormats() {
if (typeof supportedCompressedTextureFormats === "undefined") {
const gl = this.gl;
if (typeof gl === "undefined" || gl === null) {
// WebGL context not available
return super.getSupportedCompressedTextureFormats();
}
supportedCompressedTextureFormats = {
Comment on lines +234 to 238
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

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

getSupportedCompressedTextureFormats() uses this._gl.getExtension(...) in the extension fallbacks, but _gl is not defined anywhere on WebGLRenderer (repo-wide search shows no assignment/definition). This will throw whenever the non-prefixed extension is unavailable (common), which defeats the intent of the new guard. Use gl.getExtension("WEBKIT_...") instead (same context) or explicitly define _gl in the constructor before calling it.

Copilot uses AI. Check for mistakes.
astc:
gl.getExtension("WEBGL_compressed_texture_astc") ||
Expand Down
1 change: 1 addition & 0 deletions packages/melonjs/tests/font.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe("Font : Text", () => {
parent: "screen",
scale: "auto",
renderer: video.AUTO,
Comment thread
obiot marked this conversation as resolved.
failIfMajorPerformanceCaveat: true,
});

font = new Text(0, 0, {
Expand Down
2 changes: 2 additions & 0 deletions packages/melonjs/tests/webgl_save_restore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe("WebGL Renderer save/restore", () => {
parent: "screen",
scale: "auto",
renderer: video.AUTO,
failIfMajorPerformanceCaveat: true,
});
renderer = video.renderer;
isWebGL = renderer instanceof WebGLRenderer;
Expand All @@ -30,6 +31,7 @@ describe("WebGL Renderer save/restore", () => {
parent: "screen",
scale: "auto",
renderer: video.AUTO,
failIfMajorPerformanceCaveat: true,
});
});

Expand Down
Loading