godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.06k stars 21.18k forks source link

Not power-of-two ImageTexture set as custom cursor causes garbled image in HTML5. #56083

Open elektito opened 2 years ago

elektito commented 2 years ago

Godot version

3.4.1.stable

System information

Ubuntu 20.04, GLES2, RTX 2070 Super, Chrome/Firefox

Issue description

When setting a custom mouse cursor to a (programatically created) ImageTexture with a non-power-of-two size, the cursor image appears garbled in the browser with HTML5 export.

I couldn't take a screenshot of the situation, because none of my screenshot software managed to capture the custom cursor in the browser (recording a normal cursor instead).

Non-HTML5 build works fine, and so does the original 43x43 texture when directly used as custom cursor. I've tried this in both Google Chrome and Firefox.

Steps to reproduce

  1. Create a new project.
  2. Add a non-power-of-two image to the project named cursor.png.
  3. Create a scene and attach a script.
  4. Add the following code to the script.
   func _ready():
    var tex: Texture = preload("res://cursor.png") # size: 43x43
    var img: Image = tex.get_data()
    var itex := ImageTexture.new()
    itex.create_from_image(img)
    Input.set_custom_mouse_cursor(itex)
  1. Add an HTML5 export and run in the browser.

Minimal reproduction project

TestCustomCursor.zip

Calinou commented 2 years ago

This is likely OS-specific in addition to being HTML5-specific, since setting a custom cursor is done by the browser via X11 APIs.