home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-11-05 | 3.1 KB | 99 lines | [TEXT/CWIE] |
- /*************************************************************************************
- Scaling.cp
-
- Scaling implements a standard 2D canvas to draw a set of TGraphics and tiles into.
- It also provides a set of globals that allow the sprite's location to be relative
- to a specific camera location.
-
-
- Author: Timothy Carroll
- Apple Developer Technical Support
- timc@apple.com
-
- Modification History:
- 2/27/97 TMC Now properly includes error macros directly
- 1/23/97 TMC Added include for Moofwars.h so that MrC will compile
- 8/15/96 TMC Initial Release
-
- Copyright © 1996, 1997 Apple Computer, Inc., All Rights Reserved
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours. However, what you are
- not permitted to do is to redistribute the source as "DSC Sample Code"
- after having made changes. If you're going to re-distribute the source,
- we require that you make it clear in the source that the code was
- descended from Apple Sample Code, but that you've made changes.
- *************************************************************************************/
-
-
- #include "Scaling.h"
- #include "QDOffscreen.h"
- #include "Error Macros.h"
-
- SInt32 gWorldCoordX = 0;
- SInt32 gWorldCoordY = 0;
- Rect gClipRect = {0,0,0,0};
- SInt32 gClipCenterX = 0;
- SInt32 gClipCenterY = 0;
-
- PixMapHandle gDestPixMap = NULL;
- PixMapHandle gBackPixMap = NULL;
- unsigned char *gDestBaseAddr = NULL;
- unsigned char *gBackBaseAddr = NULL;
- UInt32 gRowBytes;
-
-
-
-
-
-
-
- /*************************************************************************************
- SetDestinationBuffer
-
- This routine takes in the pix maps and sets up all the right variables for drawing. Any
- drawing using the TGraphic objects or TTiles must be done through a destination PixMap.
- Ideally, if you are about to dispose of the buffers, you should call SetDestinationBuffer
- with NULL for both pixmaps. In the debugging version, this will cause an error if any
- drawing is attempted through the NULL pix.
-
- If you specify a background pixmap, it must be the same dimensions, depth and rowbytes as
- the main pix.
-
- *************************************************************************************/
- void SetDestinationBuffer(PixMapHandle inDestPixMap, PixMapHandle inBackPixMap)
- {
- // save the pix map info (so we can use it)
- gDestPixMap = inDestPixMap;
- gBackPixMap = inBackPixMap;
-
- // get info from the pix map
- if (gDestPixMap != NULL)
- {
- gDestBaseAddr = ( unsigned char * ) GetPixBaseAddr( gDestPixMap );
- gRowBytes = (*gDestPixMap )->rowBytes & 0x3fff;
- }
-
- if (gBackPixMap != NULL)
- gBackBaseAddr = ( unsigned char * )GetPixBaseAddr (gBackPixMap );
-
-
- }
-
-
- void SetBufferClip(Rect *inClipRect)
- {
- gClipRect = *inClipRect;
- gClipCenterX = (gClipRect.left + gClipRect.right) >> 1;
- gClipCenterY = (gClipRect.top + gClipRect.bottom) >> 1;
- }
-
-
- // This function specifies the point in World Coordinates that coorsponds to the center
- // of the clipping rectangle.
- void SetWorldOrigin (SInt32 x, SInt32 y)
- {
- gWorldCoordX = x;
- gWorldCoordY = y;
- }