Programming texture plugin


this is probably a question for our beloved devvvv’s.

I have some questions regarding writing plugins that produce textures.

In the template, in CreateTexture a function
TextureUtils.CreateTexture( device, w, h );
is used for creating a new texture.

I was trying (messing around for different reasons :) to do it myself using
new Texture(device, w, h, 0, Usage.None, Format.A8B8G8R8, Pool.Default)
but this fails with D3DERR_INVALIDCALL (-2005530516) because 1. i don’t know if this is possible and 2. maybe the Utils function does a lot of other stuff that I am unaware of.

Also, when I use the TextureUtils.CreateTexture function twice from within CreateTexture(device), things don’t seem to work. I am wondering why.

The reason I am experimenting with this is that I want to copy data to video memory, but I wanted to keep 2 different textures, to create some sort of double buffer, so that I could copy information to the texture that is not visible from a separate thread, and show the other texture, then switch them as needed, because the way the template is implemented is easy and clear, but speed really sucks a soon as textures start to grow and change often.
My ‘CreateTexture’ function (that is called whenever Reinitialize() is called), would not always create a new texture, but would simply return the ‘frontbuffer’ texture…

Maybe this is a bad idea and I should do it otherwise? What I can see now is that I have quite a good frame rate (because I am not blocking vvvv’s main thread while copying data), but since I could be writing to a texture while it is being shown on screen, I sometimes see frames that actually consist of 2 halves of 2 different frames. Another way would be to lock the texture while it is being written to or something but I don’t really know how i could do that either…

Any ideas? Things I missed, info I should check out? How does the VideoTexture node work (it’s something like that I need I guess)?



A8B8G8R8 format is not supported anymore in general, you need to use A8R8G8B8.

Got a screenshot somewhere where i went through all formats to check if it was supported or not. Will post tomo :)

I just typed this in by heart…
I tried A8R8G8B8 too, and some others, I don’t think that is the reason for the failure.

What I’m saying is I couldn’t get it to work with other settings too, and there are many options. I believe it didn’t crash when I used Pool.Scratch, but I didn’t see any output on screen either. And from what I read on the internet, I remember thinking that the scratch pool seems unlikely to be the one that should be used for creating the texture.

there isn’t any magic and its open source: TextureUtils.cs

I had no clue that that part was open source, thanks for pointing that out, tonfilm!