Learn to think in the terms of 3D hardware
Doing the following is catastrophically slow in .NET (and native code):
CreateSexyTextureFromHell();I don't do that. But, consequently, for the speed increase you lose a little flexibility. So here are the ru-els:
Enter crazy fucking loop.
Write pornographic image pixel by pixel.
- You can only draw to a render target (this includes rendering windows like the Screen).
- You can only write data, you cannot read it (unless someone knows a good method of reading pixels from a render target).
Of course, it's not free, but I do get a FPS of ~180 FPS with constant pixel drawing and 1000 sprites and 2 render targets. I'm sure this could be optimized more, but I don't care at this point, you should probably only draw shit up front before your app begins its rendering cycle.
Overall, I'm pleased with this. Sadly though, I wish I could implement a flood fill function, but I cannot without reading pixels (for borders), which can't be done using this model.
Still, this is indeed awesometastic. I'd like to be able to implement something like this with textures in general using lock-write/read-unlock, but I honestly don't know if it's worth it.
You can't see it, but the blue background in the render targets are being 'eaten' away by filled circles being drawn in realtime. All drawing functions can take an image as a pattern and do patterned drawing as well. In this instance it's drawing the circles using the texture for the balls as a pattern. Notice that even the alpha from the pattern texture is preserved and passed on through to the render target (notice the translucent ellipse in the center and that some areas in the swiss cheese effect are totally transparent).
Soon I'll actually do something useful with this. Or I'll scrap it.. again...