Converting pixeldata to ITexture?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Kernle 32DLL
Posts: 10
Joined: Thu Oct 21, 2010 9:18 pm

Converting pixeldata to ITexture?

Post by Kernle 32DLL »

Hi there,

I'm kind of stuck with something: I want to create an ITexture from pixel data (aka bytearray, or byte pointer, etc.). As described here, I could create an IImage first, and load an ITexture from it then. However, this has 2 disadvantages. First, it’s a waste of memory, and second it doesn't work with threads in OpenGL (at least addTexture fails when used in a thread, and Irrlicht was initialized with OpenGL)

So, any better ideas?

So long,
Kernle
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Re: Converting pixeldata to ITexture?

Post by slavik262 »

Kernle 32DLL wrote:First, it’s a waste of memory.
False. If you drop the IImage as soon as you've created the texture from it, it will delete itself and you'll get the memory back. See IReferenceCounted, a base class of IImage (and most other classes in Irrlicht) which implements reference counting.
Kernle 32DLL wrote:and second it doesn't work with threads in OpenGL (at least addTexture fails when used in a thread, and Irrlicht was initialized with OpenGL)
Generally speaking, you can't perform ops which involve the GPU (such as loading/unloading textures, vertex buffers, rendering, etc.) in multiple threads. This isn't unique to Irrlicht - you'll find this to be the case pretty much anywhere. It's a DirectX and OpenGL problem (though IIRC DX11 is beginning to implement real multi-threaded rendering).
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

There's no problem with locking the texture and writing into it directly, though. The code should be largely the same, whether writing to image or texture.
Kernle 32DLL
Posts: 10
Joined: Thu Oct 21, 2010 9:18 pm

Post by Kernle 32DLL »

Tested it, and it fails just the same, this time while creating the texture (I dont even get to the locking part :/)

Seems like I have to drop that Threading idea, dang it :/

So long,
Kernle
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Oh yeah, I didn't mean the threading. Just the basic workflow for creating and writing the texture.
Kernle 32DLL
Posts: 10
Joined: Thu Oct 21, 2010 9:18 pm

Post by Kernle 32DLL »

Okay, thanks for the info anway ;)
Post Reply