Hi,
Is it possible to use Urho3D::Image in texture unit directly? For example if I have Urho3D::Image can I pass it to the diffuse texture unit?
Using Urho3D::Image in texture unit
This seems to work but it looks wrong. If I remove SetData it is not longer flipping the texture. What would be the correct way?
[code]ResourceCache* cache = GetSubsystem();
Texture2D* texture = cache->GetResource(filepath);
Image* image = cache->GetResource(filepath);
image->FlipVertical();
texture->SetData(image);
Renderer* renderer = GetSubsystem();
Viewport* viewport = renderer->GetViewport(0);
RenderPath * rp = viewport->GetRenderPath();
for ( int i = 0; i < rp->GetNumCommands(); i++ )
{
RenderPathCommand * cmd = rp->GetCommand( i );
if ( cmd->type_ == RenderCommandType::CMD_QUAD )
{
cmd->SetTextureName(TextureUnit::TU_DIFFUSE, image->GetName());
}
}[/code]
The correct way is to understand that Image and Texture2D are completely different under the skin.
You should consider them as unrelated resources that may be loaded from the same file and converted into each other through SetData/GetImage.
So if you change (i.e. flip) one, antoher remains unchanged.