Jump to content
  • Advertisement
  • Remove ads and support GameDev.net for only $3. Learn more: The New GDNet+: No Ads!

  • 09/14/99 04:50 PM
    Sign in to follow this  

    Fast Graphics Under Windows

    Graphics and GPU Programming

    Myopic Rhino
    Lots of books have been written on this subject. The bottom line for 2D graphics is to use CreateDIBSection() (consult your handy dandy Windows development environment documentation) and friends for windowed or otherwise very system-friendly fast graphics, and DirectDraw for fast full screen graphics where you get to dictate the color mode (8-bit, 16-bit, 32-bit, etc.).

    The trick to CreateDIBSection() is that to actually get your bitmap to the screen, you have to jump through a few hoops. First you have to use CreateCompatibleDC() to create a Device Context to blit from (think of it as just a hunk of program that knows how to move pixels), SelectObject() your HBITMAP into it, then obtain the DC for your destination window, and use BitBlt() to blit from the created DC to the window's DC.

    DirectDraw is pretty straight forward if all you want is a linear full screen framebuffer to manually throw pixels at (that's all I usually use, for compatability with as much hardware as possible). First buy a good book on DirectDraw. Then create a DirectDraw object, switch to Exclusive mode, change the screen mode to whatever you like, acquire the DDSurface object for the Primary surface, create an Off-Screen System Memory surface of the same size and bit depth to be your Back Buffer, then every frame Lock the Back Buffer surface, compose your graphics there in system memory, Unlock the surface, and do a DirectDraw Blit from the off-screen surface to the Primary surface. This works for a lot of things, and gives you the advantage of being able to quickly read pixels back from your back buffer (to do alpha-blending, additive-blending, burn effects, etc.), as reading pixels from a Video Memory surface is SLOW, and dangerous. To get more speed in certian styles of games, you can use Dirty Rectangle updating to only blit the changed parts of the back buffer to the visible primary surface (DX-Ball 2 uses this technique).

    Check out the BackBuffer Page for some free source code that handles DirectDraw, CreateDIBSection, and even OpenGL windows!

    Copyright 1998-1999 by Seumas McNally.
    No reproduction may be made without the author's written consent.

    Courtesy Of Longbow Digital Artists


      Report Article
    Sign in to follow this  


    User Feedback

    Create an account or sign in to leave a review

    You need to be a member in order to leave a review

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    There are no reviews to display.


  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!