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.
Empty Engine Code/TtTinselTown.h
/****************************************************************************** |
** ** |
** Module: TtTinselTown.h ** |
** ** |
** Purpose: Sample empty drawing engine. ** |
** Include file. ** |
** ** |
** Author: Mike W. Kelley ** |
** ** |
** 2/3/95 Revised for 0.9 SDK release ** |
** ** |
** Copyright (C) 1994-95 Apple Computer, Inc. All rights reserved. ** |
** Apple Computer Confidential ** |
** ** |
*****************************************************************************/ |
#ifdef __cplusplus |
extern "C" { |
#endif |
/************************************************************************************************ |
* Miscellaneous constants. |
***********************************************************************************************/ |
#define kTtMaxTag kQATag_Texture |
#define kTtFalse 0 |
#define kTtTtue 1 |
#define kTtMyVendorID (-1) /* NEED TO GET THIS FROM APPLE! */ |
#define kTtMyEngineID 0 /* Whatever I choose */ |
#define kTtMyRevisionID 0 /* Whatever I choose */ |
/************************************************************************************************ |
* The TQADrawPrivate datatypes. |
***********************************************************************************************/ |
typedef union TTtState |
{ |
unsigned long i; |
float f; |
const void *p; |
} TTtState; |
typedef struct TTtDrawPrivate |
{ |
/* |
* Storage for state variables. All drawing engines need this |
* in some form. |
*/ |
TTtState state [kTtMaxTag + 1]; /* State variables */ |
/* |
* Various private draw engine data. Here we've kept a copy of |
* the TQADevice passed to QADrawContextNew(), the creation flags, |
* and some data that describes the target region of the device. |
*/ |
long flags; /* Creation flags */ |
TQADevice device; /* Creation device */ |
TQARect deviceRect; /* Target rect position */ |
long width; |
long height; |
long rowBytes; |
long depth; |
void *baseAddr; |
} TTtDrawPrivate; |
/************************************************************************************************ |
* The TQAStorePrivate datatypes. This is just a placeholder; these are |
* engine-specific. A single TTtStorePrivate global instance is used to hold |
* information on all bitmaps and textures allocated by the engine. |
***********************************************************************************************/ |
typedef struct TTtBitmap TTtBitmap; |
typedef struct TTtTexture TTtTexture; |
typedef struct TTtStorePrivate TTtStorePrivate; |
struct TTtStorePrivate |
{ |
TTtBitmap *firstBitmap; /* Head of linked list */ |
TTtTexture *firstTextureMap; /* Head of linked list */ |
}; |
extern TTtStorePrivate gTtStorePrivate; |
/************************************************************************************************ |
* Utility function prototypes. |
***********************************************************************************************/ |
#ifdef kTtDebug |
void TtError ( |
const char *message); |
#endif |
#define TtMemoryNew(nBytes) malloc(nBytes) |
#define TtMemoryDelete(target) free(target) |
/************************************************************************************************ |
* TtRegister() causes MAB to register itself with Tinsel Town. When we're linking |
* our engine directly, this should be called before any Tinsel Town calls are made. |
* When we're building as a shared library, this should be called as the library |
* initialization function. Because the initialization function must return an |
* OSErr, that function does so. |
***********************************************************************************************/ |
OSErr TtRegister (void); |
/************************************************************************************************ |
* Tinsel Town system methods. |
***********************************************************************************************/ |
TQAError TtDrawPrivateNew ( |
TQADrawContext *newDrawContext, /* Draw context to initialize */ |
const TQADevice *device, /* Target device */ |
const TQARect *rect, /* Target rectangle (device coordinates) */ |
const TQAClip *clip, /* 2D clip region (or NULL) */ |
unsigned long flags); /* Mask of kQAContext_xxx */ |
void TtDrawPrivateDelete ( |
TQADrawPrivate *drawPrivate); /* Private context data to delete */ |
TQAError TtEngineDeviceCheck ( |
const TQADevice *device); /* Target device */ |
TQAError TtEngineGestalt ( |
TQAGestaltSelector selector, /* Gestalt parameter being requested */ |
void *response); /* Buffer that receives response */ |
/************************************************************************************************ |
* Tinsel Town draw context methods. |
***********************************************************************************************/ |
void TtSetFloat ( |
TQADrawContext *drawContext, /* Draw context */ |
TQATagFloat tag, /* Tag of variable to set */ |
float newValue); /* New value for variable */ |
void TtSetInt ( |
TQADrawContext *drawContext, /* Draw context */ |
TQATagInt tag, /* Tag of variable to set */ |
unsigned long newValue); /* New value for variable */ |
void TtSetPtr ( |
TQADrawContext *drawContext, /* Draw context */ |
TQATagPtr tag, /* Tag of variable to set */ |
const void *newValue); /* New value for variable */ |
float TtGetFloat ( |
const TQADrawContext *drawContext, /* Draw context */ |
TQATagFloat tag); /* Tag of variable to get */ |
unsigned long TtGetInt ( |
const TQADrawContext *drawContext, /* Draw context */ |
TQATagInt tag); /* Tag of variable to get */ |
void *TtGetPtr ( |
const TQADrawContext *drawContext, /* Draw context */ |
TQATagPtr tag); /* Tag of variable to get */ |
void TtDrawPoint ( |
const TQADrawContext *drawContext, /* Draw context */ |
const TQAVGouraud *v0); /* Vertex */ |
void TtDrawLine ( |
const TQADrawContext *drawContext, /* Draw context */ |
const TQAVGouraud *v0, /* Vertex 0 */ |
const TQAVGouraud *v1); /* Vertex 1 */ |
void TtDrawTriGouraud ( |
const TQADrawContext *drawContext, /* Draw context */ |
const TQAVGouraud *v0, /* Vertex 0 */ |
const TQAVGouraud *v1, /* Vertex 1 */ |
const TQAVGouraud *v2, /* Vertex 2 */ |
unsigned long flags); /* Mask of kQATriFlags_xxx flags */ |
void TtDrawTriTexture ( |
const TQADrawContext *drawContext, /* Draw context */ |
const TQAVTexture *v0, /* Vertex 0 */ |
const TQAVTexture *v1, /* Vertex 1 */ |
const TQAVTexture *v2, /* Vertex 2 */ |
unsigned long flags); /* Mask of kQATriFlags_xxx flags */ |
void TtDrawBitmap ( |
const TQADrawContext *drawContext, /* Draw context */ |
const TQAVGouraud *v, /* xyz, and (if a 1 bit/pixel bitmap) argb */ |
TQABitmap *bitmap); /* Previously allocated by QABitmapNew() */ |
void TtRenderStart ( |
const TQADrawContext *drawContext, /* Draw context */ |
const TQARect *dirtyRect, /* Minimum area to clear; NULL means whole buffer */ |
const TQADrawContext *initialContext); /* Initial background image (or NULL) */ |
TQAError TtRenderEnd ( |
const TQADrawContext *drawContext, /* Draw context */ |
const TQARect *modifiedRect); /* Minimum area to swap; NULL means whole buffer */ |
TQAError TtRenderAbort ( |
const TQADrawContext *drawContext); /* Draw context */ |
TQAError TtSync ( |
const TQADrawContext *drawContext); /* Draw context */ |
TQAError TtFlush ( |
const TQADrawContext *drawContext); /* Draw context */ |
/************************************************************************************************ |
* Tinsel Town store context methods. |
***********************************************************************************************/ |
TQAError TtTextureNew ( |
unsigned long flags, /* Mask of kQATexture_xxx flags */ |
TQAImagePixelType pixelType, /* Depth, color space, etc. */ |
const TQAImage images[], /* Image(s) for texture */ |
TQATexture **newTexture); /* (Out) Newly created TQATexture, or NULL on error */ |
TQAError TtTextureDetach ( |
TQATexture *texture); /* Previously allocated by QATextureNew() */ |
void TtTextureDelete ( |
TQATexture *texture); /* Previously allocated by QATextureNew() */ |
TQAError TtBitmapNew ( |
unsigned long flags, /* Mask of kQABitmap_xxx flags */ |
TQAImagePixelType pixelType, /* Depth, color space, etc. */ |
const TQAImage *image, /* Image */ |
TQABitmap **newBitmap); /* (Out) Newly created TQABitmap, or NULL on error */ |
TQAError TtBitmapDetach ( |
TQABitmap *bitmap); /* Previously allocated by QABitmapNew() */ |
void TtBitmapDelete ( |
TQABitmap *bitmap); /* Previously allocated by QABitmapNew() */ |
#ifdef __cplusplus |
}; |
#endif |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14