0

I'm writting a simple software renderer, load 3d model, process vertex, rasterization, texture, lighting, all that things, all done. I used SDL(not using OpenGL mode) to draw pixel on its SDL_Surface, and call SDL_Flip, so one frame appears.

for some reason now I don't want to use SDL, I just need a double-buffer to draw pixel.

I know there're someway to do this, OpenGL, Direct3D, gdi, maybe they're too "advanced" for this project, what is the direct(or fastest) way to draw pixels to back-buffer on win32 ?

amanjiang
  • 1,213
  • 14
  • 33

1 Answers1

4

I'd recommend using a graphics API for this (OpenGL or Direct3D), but GDI would be the easiest option. You can create a DIB (Device Independent Bitmap) using the CreateDIBSection function which returns a pointer to the bitmap's memory. You can then modify the pixels of the bitmap however you please and draw it to your window's client area. See chapter 15 of Programming Windows (5th) by Charles Petzold for source code and explanation of this technique.

PeddleSpam
  • 418
  • 3
  • 10
  • in that case you need to use either OpenGL or DirectX. DirectX may be easier for you to get started with, though personally I'd favour OpenGL. – PeddleSpam Apr 19 '13 at 13:20