Hi,
Indeed, from looking at the patch you will need to call glGenTextures, then glBindTexture. Something like the following should. However if you anticipate the texture target getting rebound overtime, you will have to maintain the texture ID so you can rebind it with glBindTexture() before each call to glTexSubImage2D.
I got a bit delayed by a hard drive crash, but now I've come back to this problem. I added a glGenTextures, glBindTexture before drawing, and a glBindTexture(GL_TEXTURE_2D, 0) and a glDeleteTexture after drawing, but this didn't improve the problem. The texture still has the solid color of the first pixel :(
Another possible problem I've found was that I calculated the texture coords with a int / int division. I've typcasted that to float / float, but without any change.
The texture is meant to be used only once, because on the next UnlockRect call on a rendertarget, the app might have changed the whole memory, and I have to re-load the whole locked area