home *** CD-ROM | disk | FTP | other *** search
/ NEXT Generation 27 / NEXT27.iso / pc / demos / emperor / dx3.exe / SDK / SAMPLES / IKLOWNS / CGUPDATE.CPP < prev    next >
C/C++ Source or Header  |  1996-08-28  |  3KB  |  100 lines

  1. /*===========================================================================*\
  2. |
  3. |  File:        cgupdate.cpp
  4. |
  5. |  Description: 
  6. |       
  7. |-----------------------------------------------------------------------------
  8. |
  9. |  Copyright (C) 1995-1996 Microsoft Corporation.  All Rights Reserved.
  10. |
  11. |  Written by Moss Bay Engineering, Inc. under contract to Microsoft Corporation
  12. |
  13. \*===========================================================================*/
  14.  
  15. /**************************************************************************
  16.  
  17.     (C) Copyright 1995-1996 Microsoft Corp.  All rights reserved.
  18.  
  19.     You have a royalty-free right to use, modify, reproduce and 
  20.     distribute the Sample Files (and/or any modified version) in 
  21.     any way you find useful, provided that you agree that 
  22.     Microsoft has no warranty obligations or liability for any 
  23.     Sample Application Files which are modified. 
  24.  
  25.     we do not recomend you base your game on IKlowns, start with one of
  26.     the other simpler sample apps in the GDK
  27.  
  28.  **************************************************************************/
  29.  
  30. #include <windows.h>
  31. #include "cgupdate.h"
  32. #include "cgimage.h"
  33. #include "cgglobl.h"
  34.  
  35. //#define FULL_SCREEN_DIRTY
  36.  
  37. /*---------------------------------------------------------------------------*\
  38. |
  39. |       Class CGameUpdateList
  40. |
  41. |  DESCRIPTION:
  42. |       
  43. |
  44. |
  45. \*---------------------------------------------------------------------------*/
  46. CGameUpdateList::CGameUpdateList(
  47.     )
  48. {
  49.     Clear();
  50. }
  51.  
  52. CGameUpdateList::~CGameUpdateList()
  53. {
  54.     mDirty = FALSE;
  55. }
  56.  
  57. // we make a copy of the rect & add the copy to the list
  58. void
  59. CGameUpdateList::AddRect(
  60.     RECT Rect
  61.     )
  62. {
  63.     // first clip new rect to screen boundaries
  64.     RECT temp = 
  65.     {
  66.         0,0,SCREEN_WIDTH-1,SCREEN_HEIGHT-1
  67.     };
  68.  
  69. //#ifndef FULL_SCREEN_DIRTY
  70.     if (!gUse_DDraw)
  71.     {
  72.         // only add if we're on the screen
  73.         if (IntersectRect( &temp, &Rect, &temp))
  74.         {
  75.             if (mDirty)
  76.             {
  77.                 // already have a rect. Let's make the union of them the new one...
  78.                 UnionRect(&temp, &mRect, &temp);
  79.             }
  80.             else
  81.             {
  82.                 // don't have a rect yet... use this one
  83.                 mDirty = TRUE;
  84.             }
  85.             mRect = temp;
  86.         }       
  87.     }
  88.     else
  89.     {
  90.         mDirty = TRUE;
  91.         mRect = temp;
  92.     }
  93. }
  94.  
  95. BOOL CGameUpdateList::Intersect( RECT Rect )        // find out if rectangle intersects us...
  96. {
  97.     RECT temp;
  98.     return(IntersectRect(&temp, &Rect, &mRect));
  99. }   
  100.