Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Tim's Libraries/Scaling.cp
/* |
File: Scaling.cp |
Contains: 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. |
Written by: Timothy Carroll |
Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved. |
You may incorporate this Apple sample source code into your program(s) without |
restriction. This Apple sample source code has been provided "AS IS" and the |
responsibility for its operation is yours. You are not permitted to redistribute |
this Apple sample source code as "Apple sample source 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 source |
code, but that you've made changes. |
Change History (most recent first): |
7/2/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1 |
2/27/97 Timothy Carroll Now properly includes error macros directly |
1/23/97 Timothy Carroll Added include for Moofwars.h so that MrC will compile |
8/15/96 Timothy Carroll Initial Release |
*/ |
#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; |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-10-14