You should take a reference or a pointer from the RenderComponent constructor. No other way will work.
But for your use you should take a wchar_t* instead of the image.
Now that I am from pc, let me explain you why:
1 2 3 4 5
|
// Suppose your constructor looks like:
RenderComponent::RenderComponent( unsigned ID, Gdiplus::Image image )
{
//...
}
|
What's wrong is, in that line, no matter what, 'image' is a copy of the variable you input. Windows does not want you to copy an image like that, so, to solve this problem, you can take a reference.
But to store the texture, you will have to make another copy, and you cannot.
So you should use something like:
1 2 3 4
|
RenderComponent::RenderComponent( unsigned ID, const wchar_t * ImagePath ) : MyImageInTheClass( ImagePath )
{
//...
}
|
And use it like:
|
new RenderComponent( o->GetID(), L"res/Player.bmp");
|
(MyImageInTheClass is a Gdiplus::Image)
Remember that you cannot copy objects of type RenderComponent, unless you are copying a pointer and/or using reference counting.
Also note that GDI/GDI+ haven't been built to make games, but simple graphics instead. You should use something hardware-accelerated to make things faster, like OpenGL/D3D/D2D1.