godotengine / godot

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

Add dawing api to Texture class #7727

Closed TeddyDD closed 7 years ago

TeddyDD commented 7 years ago

Feature request. Basically all CanvasItem drawing methods but for Texture. Could be useful in procedural textures etc.

Alternativly method to dump CanvasItem content to texture so drawing could be done in CanvasItem.

bojidar-bg commented 7 years ago

I'm sure I've seen a request for this, but I can't find it now (maybe it was on QA?). Anyway, sounds cool to have.

bojidar-bg commented 7 years ago

Note that it would have to be in the Image class, not the Texture class (unless it is done in CanvasItem as OP mentioned). That's because it would be hard to draw to a RenderTargetTexture, right? :smiley:

Zylann commented 7 years ago

draw methods are part of the whole rendering engine, which appears to draw on the screen. Actually, it draws on a Viewport. And Viewport can be offscreen... And offscreen means Texture under the hood, here you go :)

So you can draw on a texture, it's just that it doesn't have to be explicit, because you can draw things in sooo many ways (draw methods, sprites, custom geometry, shaders...). You can choose where to draw by using a Viewport and get the texture from it with get_render_target_texture(), or simply draw it on screen with a ViewportSprite.

If what you mean is just drawing on an Image without using OpenGL, it won't benefit from the rendering engine and will have a different, limited (and slower) implementation.

TeddyDD commented 7 years ago

@Zylann You are correct, I forgot about viewports! They are pretty flexible and I was able to achieve what I wanted. I guess I'll close this issue.