/*
 =======================================================================================
  Name        : OGL_Thread.h
  Author      : Bart     
  Description :
 =======================================================================================
 */

/*
 =======================================================================================
    Include 
 =======================================================================================
 */


/* 1->13 : no param */
#define OGLT0_CREATE 1
#define OGLT0_RESUME 2
#define OGLT0_SWAP   3
//#define OGLT0_RENDER 4
//#define OGLT0_LOADTEXTURES 5
#define OGLT0_INITFLAGS 6
#define OGLT0_FLUSH 7
#define OGLT0_ALPHATEST 8
#define OGLT0_LOCKDEVICE 9
#define OGLT0_UNLOCKDEVICE 10
#define OGLT0_BLACKPOLY 11
#define OGLT0_WAIT 12
#define OGLT0_FOGPARAM 13

/* 31->38 : 1 param */
#define OGLT1_ENABLE 31
#define OGLT1_DISABLE 32
#define OGLT1_DEPTHMASK 33
#define OGLT1_DELETETEXTURE 34
#define OGLT1_BINDTEXTURE 35
#define OGLT1_TEXTUREENV 36
#define OGLT1_RENDER 37
#define OGLT1_LOADTEXTURES 38

/* 51->54 : 2 params */
#define OGLT2_PIXELTRANSFER 51
#define OGLT2_BLENDFUNC 52
#define OGLT2_WRITEBITMAP 53
#define OGLT2_CLEARDEVICE 54

/* 71->71 : 3 params */
//#define OGLT3_CLEARDEVICE 71

/* 81->83 : 1 param + 1 returned (boolean) value */
#define OGLT1_ISTEXTURE 81
#define OGLT1_ISENABLED 82
#define OGLT1_ISRESIDENT 83

/* 98->99 : specific */
#define OGLT0_EXIT 98

#define OGLT0_NB_MSG_MAX 99

/* Post OGL Commands in the thread message queue */

void OGLThread_fn_vPostCmd(int _CommandId);
void OGLThread_fn_vPostCmd_1Long(int _nCommandId, long _lParam1);
void OGLThread_fn_vPostCmd_2Long(int _nCommandId, long _lParam1, long _lParam2);
//void OGLThread_fn_vPostCmd_3Long(int _nCommandId, long _lParam1, long _lParam2, long _lParam3);
BOOL OGLThread_fn_bPostCmdAndWait(int _nCommandId, long _lParam1);


void OGLThread_fn_vCreateThread(void);
void OGLThread_fn_vTerminateThread();

void OGLThread_fn_vCreateContext(BOOL _bReinitDevice);
void OGLThread_fn_vResumeContext(BOOL _bReinitDevice);

void OGLThread_fn_vWaitForSynchro();



/* from OGL_Acces.c */

#if defined (Z_BUFFER)

	//#define M_glVertex(x, y, w) glVertex4f( x, y, 1.0f/w, 1.0f )

	#if defined (PERSP_CORRECTION)
		#define M_glVertex(x, y, w) glVertex4f( x/w, y/w, 1.0f/(w*w), 1.0f/w )
	#else
		#define M_glVertex(x, y, w) glVertex4f( x, y, 1.0f/w, 1.0f )
	#endif

#else // W_BUFFER

	//#define M_glVertex(x, y, w) glVertex4f( x, y, 1.0f, w )

	#if defined (PERSP_CORRECTION)
		#define M_glVertex(x, y, w) glVertex4f( x/w, y/w, 1.0f, 1.0f/w )
	#else
		#define M_glVertex(x, y, w) glVertex4f( x, y, w, 1.0f )
	#endif

#endif

/*
 =======================================================================================
    Vertex Access Macros 
 =======================================================================================
 */

// GET
#define GetX(a) a.sx
#define GetY(a) a.sy
#define GetZ(a) a.sz	//a.rhw
#define GetPackedColor(a) a.color
#define GetPackedSpecular(a) a.specular
#define GetU(a) a.tu
#define GetV(a) a.tv
// SET
#define SetX(a,b) a.sx = b
#define SetY(a,b) a.sy = b
#define SetZ(a,b) a.sz = b //a.rhw
#define SetPackedColor(a,b) a.color = b
#define SetPackedSpecular(a,b) a.specular = b
#define SetU(a,b) a.tu = b
#define SetV(a,b) a.tv = b
#define SetU_Cpy(a,b) a.tu = b
#define SetV_Cpy(a,b) a.tv = b

typedef struct _GLI_tdScreenVertx {
        float sx;  
        float sy;
		float sz;
		//float rhw; 
		unsigned long color;  
		unsigned long specular;   
		float tu;  
		float tv;
} GLI_tdScreenVertx;

/* end of OGL_Acces.c */
