2

I'm currently taking a course on polygonal 3D rendering from scratch. We write our own line drawing and clipping algorithms that are eventually used to draw polygons in 3D space using code for perspective transformations that we write ourself. The assumption of the course is that we write to 2D arrays that represent the window, viewport, or display device. In the first week of the course we wrote code to write out these 2D arrays as bitmap files so we could view the output.

Now I want to see the output of my software renderer in real-time and interact with it. What is the fastest way to draw a 2D bitmap array to the screen, in Mac OSX 10.9 for example? Linux? Windows?

I'm specifically looking for speed here, as the only thing that I want the GPU to do is draw the 2D array that I just rendered in main memory at runtime.

OregonTrail
  • 8,594
  • 7
  • 43
  • 58
  • I draw rendered bitmap to Win32 Window Canvas directly by GDI is much faster then load bmp to GL and render it back ... Also I render directly to bitmaps via ScanLine[] no point to have separate copy of array ... just create list of scanlines in array of pointers so it would be fast (no GDI checking) (have 2 bmps one for color and one for Z-buffer) – Spektre May 27 '14 at 08:07
  • @Spektre if you use GDI then your output will be subject to DWM(Windows Vista+) and there will be overhead. But if you request direct full screen access with 3D API you will write directly to the final GPU memory buffer bypassing DWM. – JAre May 27 '14 at 18:22
  • @JAre I do not use GDI for render just for final swap buffers ... so little overhead is no problem I do not need 2000fps – Spektre May 27 '14 at 20:28
  • @Spektre as far as i know in Windows Vista+ each window is represented as it's own framebuffer of some sort. When all of the windows are rendered to the texture set(might be atlases of some sort) with all internal contexts like flash or DirectX embedded to the window - then DWM(Desktop Window Manager) will z-sort, blend(apply effects like windows Aero blurry alpha) and combine them to the final render buffer that will be displayed. But! If you request exclusive full screen context (like all modern 3D games do in the full screen mode) you will directly render to the final buffer without DWM. – JAre May 27 '14 at 20:44
  • @Spektre So that is why GDI isn't fastest way even if it allows you to send bitmap data across the buss without overhead it will be the same for the OpenGL or DirectX, but they will push it right to the final stage in the exclusive mode bypassing graphic managers of the OS. And in both cases some sort of scaffolding will be used on the shader side. – JAre May 27 '14 at 20:56
  • @JAre wow did not know about that. (migrate from XP only recently) In that case you are right but I still think it is overkill to use DX or GL for just frame copy because in this way it gains only few ms per frame and it is not critical unless target framerate is not bigger then 200fps ... – Spektre May 28 '14 at 07:24

1 Answers1

1

Without the initialization step it should be OpenGL rendering of the bitmap on screen aligned quad(What's the best way to draw a fullscreen quad in OpenGL 3.2?) Only costly operation will be uploading the bitmap but it's unavoidable anyway.

Community
  • 1
  • 1
JAre
  • 4,666
  • 3
  • 27
  • 45