Advertisement

Using D2D bitmap as framebuffer

Started by October 05, 2019 01:44 AM
3 comments, last by Prototype 5 years, 4 months ago

I am writing a software renderer for fun/education. I have been using the Windows GDI with SetPixel to draw pixels, but it seems too slow. I have discovered that Direct2D and Direct3D do not have functions to plot individual pixels (so lame). It seems the workaround is to draw to a bitmap, and copy that bit map to the screen.

There is VERY little info that I can find on how to do this. MSDN is (as usual)  useless.

Any examples, or links? Thoughts? If there exists a library out there for this, I may be interested.

I just want to plot stink'n pixels individually . Why is this not a thing!

 

You can draw your pixels to a texture and display that on a quad. This can be done with any version of Direct3D.

I wonder though if it would be much faster than a GDI blit, which basically does the same thing under the hood. Drawing individual pixels is just slow, even on 3D hardware. The GPU doesn't let you magically plot any faster, so to speak.

Advertisement

It seems to me that the GDI is slow when I try to do Invalidate rectangle every pass through my main loop. When I just update the screen when I press a key, thus far with simple geometry, it is basically faster than the debugger can measure. I'm writing a pretty basic renderer.

BTW, why do I so often find mention of using a texture, rather than a generic bitmap? For context, last time I did this sort of thing was on DOS, where I could just write to the hardware. I know I can't do that, at least not practically. I want the closest I can get. I just need a PutPixel ability that isn't the bottleneck.

 

Since the GPU can emulate any 2D surface, there is no need anymore to have specialized hardware for it. So everything goes through the same pipeline. This means the only way to natively write to the screen is using the 3D method, or some abstraction written on top of it. Which for example your OS does with GDI.

I'm guessing you don't need to invalidate if you update the buffer directly, but it's been ages since I used GDI.

This topic is closed to new replies.

Advertisement