I need to update a texture dynamically for real time video streaming.
I have successfully done this in Direct3D directly without much performance decreas, although video streaming needs heavy thread syncronization.
Unfortunatly calling ITexture:lock() & ITexture:unlock() in irrlich is very slow.
I have created a 32Bit texture and fill it every render loop with buffered video stream data. I do not write to the texture in a different thread, so that cannot be the problem.
I have modified Direct3D device creation inside irrlich to support Multithreading though.
I have also disabled mip maps on the texture I want to draw into.
Without locking the texture I get about 500fps, if I lock it and just unlock it right away the framerate drops to 37fps.
The prefered texture creation bit depth is set to 32bits.
Is that a known issue? Or am I doing something wrong?
Thanks for your help!
Phil
Texture Lock very slow
Thanks for your fast reply Niko.
First of all let me tell you I really appreciate the strict and clean OOD design of your engine.
I will have to dig deeper in the D3D implementation of it to find the reason for the problem. Maybe I create the D3D device or textures in a very different way than you do. Also I dont see why it is neccesary to create IImage and copy the (empty) image onto the texture when I call "addTexture". Is there any reason for that?
So far I see no differences in your code and the directx9 sample code i use for reference testing. The only difference is that the swap effect used. But I dont see that has any relevance in windowed mode.
Keep up the work!
Phil
First of all let me tell you I really appreciate the strict and clean OOD design of your engine.
I will have to dig deeper in the D3D implementation of it to find the reason for the problem. Maybe I create the D3D device or textures in a very different way than you do. Also I dont see why it is neccesary to create IImage and copy the (empty) image onto the texture when I call "addTexture". Is there any reason for that?
So far I see no differences in your code and the directx9 sample code i use for reference testing. The only difference is that the swap effect used. But I dont see that has any relevance in windowed mode.
Keep up the work!
Phil
You're right, there is no reason. If you want to create an empty texture, just use addTexture(const core::dimension2d< s32 > & size, const c8 * name);PhilK wrote:Also I dont see why it is neccesary to create IImage and copy the (empty) image onto the texture when I call "addTexture". Is there any reason for that?
How do you alter an image after you lock it?
I want to write a 2d game that uses simple actor-world collision detection by checking the color of pixels in a bitmap used as a level mask. I think I can just use IImage and getPixel (x, y) and check the color, certain colors for passable or unpassable. But I also want to be able to add walls or destroy them while in the game. How could I edit this bitmap in game? I know I can lock the bitmap and get a pointer to it, but what do I do after that if say I wanted to draw a line or circle in it?
I want to write a 2d game that uses simple actor-world collision detection by checking the color of pixels in a bitmap used as a level mask. I think I can just use IImage and getPixel (x, y) and check the color, certain colors for passable or unpassable. But I also want to be able to add walls or destroy them while in the game. How could I edit this bitmap in game? I know I can lock the bitmap and get a pointer to it, but what do I do after that if say I wanted to draw a line or circle in it?
i wouldn't use a bitmap for that. it looks like you are trying to create a map of 2d coordinates that are used to check for a specified attribute at those coordinates. when you use a bitmap it has to take the input then encode it in the proper format to be stored in the image and them possibly transfer that data to the video card. the best method would be to use a 2d array to store ints that is used to check what is at that coordinate. this way you do not have to call lock on the bitmap and you can access the needed info directly.