ContextMPR


class  {
public:
 MPRHandle_t  rc;

//___________________________________________________________________________
public:
 ContextMPR ();
 virtual ~ContextMPR () { };
 BOOL Setup( UInt lpDDSBack, UInt MPRdeviceID );
 void Cleanup( void );
 void NewImageBuffer( UInt lpDDSBack );
 void SetState( WORD State, DWORD Value );
 void Primitive( WORD Prim, WORD VtxInfo, WORD Count, WORD VtxSize, void *data );
 void Primitive( WORD Prim, WORD VtxInfo, WORD Count, WORD VtxSize );
 void StorePrimitiveVertexData( WORD VtxSize, void *data );
 void FinishPrimitive( WORD Count );
 void ClearBuffers( WORD ClearInfo );
 void SwapBuffers( WORD SwapInfo );
 void StartFrame( void );
 void FinishFrame( void *lpFnPtr );
 void SetColorCorrection( DWORD color, float percent );

 void SendCurrentPacket( void );

 void SetupMPRState (GLint flag=0);
 void SelectForegroundColor (GLint color) { if (color != currentForegroundColor) pvtSelectForegroundColor( color ); };
 void SelectTexture (GLint texID)   { if (texID != currentTexture) pvtSelectTexture( texID ); };
 void RestoreState (GLint state)    { if (state != currentState) pvtRestoreState( state ); };
 void InvalidateState () {
  currentTexture = -1;
  currentForegroundColor = -1;
  currentState = -1;
 };
 int CurrentForegroundColor (void) {return currentForegroundColor;};

 BYTE *GetContextBufferPtr () {
  return p;
 };
 void SetContextBufferPtr (BYTE *ptr) {
  p = ptr;
 };

//___________________________________________________________________________
public: // This should be protected, but we need it for debugging elsewhere (SCR 12/5/97)
 static GLint StateSetupCounter;
protected:
 static UInt StateTable[MAXIMUM_MPR_STATE];

 BYTE *bufferStart; // First byte in the buffer
 BYTE *bufferEnd;  // Last possible place for the 1st byte of the end of packet message
 BYTE *p;    // First unused byte in the buffer
 MPRPktPrm_t *primStart; // Where to put the final vertex count for a primitive in progress

 GLint currentForegroundColor;
 GLint currentState;
 GLint currentTexture;

//___________________________________________________________________________
protected:
 inline void SetStateTable (GLint state, GLint flag);
 inline void ClearStateTable (GLint state);
 void SetCurrentState (GLint state, GLint flag);
 void CleanupMPRState (GLint flag=0);

 void pvtSelectForegroundColor (GLint color);
 void pvtSelectTexture (GLint texID);
 void pvtRestoreState (GLint state);
//___________________________________________________________________________

#ifdef _DEBUG
  public:
 UInt32  maxBufferSize;
#endif
};