godot icon indicating copy to clipboard operation
godot copied to clipboard

Using draw_texture() with load() causes an error

Open vybr opened this issue 9 years ago • 6 comments

Operating system or device - Godot version: 2.1.3

Issue description: Doing this:

func _draw():
    draw_texture(load("res://texture.png"), Vector2(0,0))

will cause an error to flood the debugger and the texture is shown completely white. However, doing this is fine:

var tex = load("res://texture.png")

func _draw():
    draw_texture(tex, Vector2(0,0))

Is this a limitation or a bug?

This is the error displayed:

C Error: Condition ' !elem ' is true. returned: 0
C Source: c:\projects\godot-builds\godot\core\rid.h:143
C Function: RID_Owner<struct RasterizerGLES2:Texture,0>::get

vybr avatar Jun 02 '17 17:06 vybr

Tagging as bug/rendering as it seems that the renderer fails to get a reference to the texture, which causes it to be freed.

bojidar-bg avatar Jun 02 '17 19:06 bojidar-bg

I can't reproduce on Ubuntu, is this a Windows only problem or was solved already?

eon-s avatar Aug 01 '17 23:08 eon-s

I had this issue on Windows (not sure about Mac). I don't think it has been solved yet, can't see any related patch notes in the 2.1.4 beta.

vybr avatar Aug 08 '17 14:08 vybr

This issue is still present in Godot 3.0 Beta 2. Tested on a Windows 10 laptop with an Intel HD 4000.

vybr avatar Jan 07 '18 16:01 vybr

Isn't this the same as #15023? That is, once the function is over, the texture will be freed since it's out of scope, thus the visual server won't find the texture.

vnen avatar Jan 07 '18 17:01 vnen

Oh, that makes sense. Thanks for clarifying.

vybr avatar Jan 07 '18 17:01 vybr