   Software Renderer
  Hi all,I'm currently writing a 3d software renderer. It's currently implemented using C++ and GDI. Now, I was considering swapping out GDI for GDI+, however as I'm on XP I believe this would result in a performance hit as GDI+ is not GPU accelerated? What I'm wondering, is what's the best canvas rendering system to use to base my software renderer on. There's a video of my current progress at if it helps.   
  Best in what sense? Performance, quality, easy of use, being cross platform, license, having different back-ends for export, having hardware accelerated back-end? You have to specify some criteria.For performance and quality probably anti-grain. Some other options are Cairo and Qt's painting system (hardware accelerated back-end).Also what is wrong with GDI? I can't answer your question about GDI+, but when hardware acceleration is available why don't use it directly for 3d?   ;  What you use on the back-end shouldn't matter all that much. In my software renderer I use GDI. I have two buffers in raw memory that I treat as a 32bit color surface, and when I need to draw to the screen I create a DIB Section that points to those bits. This is very fast and only needs to happen at the rate at which your monitor updates.In my code, I can clear the screen (640x480) to an arbitrary color at over 6000 hz (on a 3.0ghz P4 with dual-channel DDR400 RAM)-- even the best displays are only 120hz or so, so its really not worth pre-optimizing. You can pretty easily have 25-50x overdraw before transfer to the screen even becomes an issue worth worrying about. In short, computers are *really good* at copying large, contiguous (or only slightly less though those of a known but partially empty stride) blocks of memory -- its *what they do*.If you use hardware acceleration, then somewhere along the line you either copy your bits over the video bus and/or convert to your adapters native format, and you throw away that buffer at the end of the frame. In other words, there's pretty much no benefit to hardware acceleration for a simple bit-blit.Since you've written a software rasterizer, there's nothing for a GPU to really do. You've already done clipping, transparancy, translucency, blending, modulation and all the other stuff that a GPU normally comes in handy for. Now, if you want to create a hardware-accelerated back-end to your software renderer API, then that's a nother matter, but there's little or no reason to involve hardware any more than GDI already does just to get a few bits to the screen.[Edited by - Ravyne on June 1, 2010 9:03:57 PM];  Thanks for your replies guys,Kambiz, I was looking into Qt as it seems quite cool.Ravyne, that's very informative. So your two buffers are presumably the back buffer and the presented buffer? So if I'm treating each buffer as a bitmap, do I need to bitblit the device context to display the bitmap or is there a simpler way?Cheers for your help.   ;  You temporarily create a dib section using whichever buffer is to be displayed onscreen. I don't have the specific code in front of me, but there's a way to create the dib structure without causing it to allocate its own buffer. The dib structure, otherwise, is relatively small, so its just a local variable in my Present method.As far as I'm aware, that's the easiest way to get things on-screen in windows without bringing in another library like SDL.If you don't want to deal with presentation issues and windowing yourself, however, something like TinyPTC is a relatively good base to build a software renderer on. I think its even cross-platform.   ;  We used Agg (anti-grain) on a recent project (on a device).  I can confirm it has good performance and excellent quality.  I can also confirm the same is true of GDI+.  We used agg because we were coding a GUI for a CE device, so GDI+ wasn't available to us.  Moreover, the device itself didn't have a floating point unit (!).  It wasn't all that snappy, but it was still better than we could have anticipated at the start of the project.  I would expect GDI+ to accelerate where it can, but when it comes to performance, again, it all depends on what you're actually wanting to do with it.  If I can give one performance tip for GDI+, it's if you're going to draw bitmaps on screen, make sure you use a pre-multiplied alpha bitmap format.  Anything else is impossibly slow :p.