/*<html><pre>*/
#include <../source/TAL/objbase.h>
#include <../source/PAL/dataman.h>

/*
 *	Vertex drawing functions.
 */
#include <../source/PAL/argsused.h>
void	V_LOCAL
vDrawV(vec_t *v,vec_t *c,vec_t *n,vec_t *t)
{
#ifdef	DOUBLEVEC
	glVertex3dv((GLdouble*)v);
#else	/* DOUBLEVEC */
	glVertex3fv((GLfloat*)v);
#endif	/* DOUBLEVEC */
}

#include <../source/PAL/argsused.h>
void	V_LOCAL
vDrawVN(vec_t *v,vec_t *c,vec_t *n,vec_t *t)
{
#ifdef	DOUBLEVEC
	glNormal3dv((GLdouble*)n);
	glVertex3dv((GLdouble*)v);
#else	/* DOUBLEVEC */
	glNormal3fv((GLfloat*)n);
	glVertex3fv((GLfloat*)v);
#endif	/* DOUBLEVEC */
}

#include <../source/PAL/argsused.h>
void	V_LOCAL
vDrawVT(vec_t *v,vec_t *c,vec_t *n,vec_t *t)
{
#ifdef	DOUBLEVEC
	glTexCoord2dv((GLdouble*)t);
	glVertex3dv((GLdouble*)v);
#else	/* DOUBLEVEC */
	glTexCoord2fv((GLfloat*)t);
	glVertex3fv((GLfloat*)v);
#endif	/* DOUBLEVEC */
}

#include <../source/PAL/argsused.h>
void	V_LOCAL
vDrawVNT(vec_t *v,vec_t *c,vec_t *n,vec_t *t)
{
#ifdef	DOUBLEVEC
	glTexCoord2dv((GLdouble*)t);
	glNormal3dv((GLdouble*)n);
	glVertex3dv((GLdouble*)v);
#else	/* DOUBLEVEC */
	glTexCoord2fv((GLfloat*)t);
	glNormal3fv((GLfloat*)n);
	glVertex3fv((GLfloat*)v);
#endif	/* DOUBLEVEC */
}

#include <../source/PAL/argsused.h>
void	V_LOCAL
vDrawVC(vec_t *v,vec_t *c,vec_t *n,vec_t *t)
{
#ifdef	DOUBLEVEC
	glColor4dv((GLdouble*)c);
	glVertex3dv((GLdouble*)v);
#else	/* DOUBLEVEC */
	glColor4fv((GLfloat*)c);
	glVertex3fv((GLfloat*)v);
#endif	/* DOUBLEVEC */
}

#include <../source/PAL/argsused.h>
void	V_LOCAL
vDrawVCN(vec_t *v,vec_t *c,vec_t *n,vec_t *t)
{
#ifdef	DOUBLEVEC
	glColor4dv((GLdouble*)c);
	glNormal3dv((GLdouble*)n);
	glVertex3dv((GLdouble*)v);
#else	/* DOUBLEVEC */
	glColor4fv((GLfloat*)c);
	glNormal3fv((GLfloat*)n);
	glVertex3fv((GLfloat*)v);
#endif	/* DOUBLEVEC */
}

#include <../source/PAL/argsused.h>
void	V_LOCAL
vDrawVCT(vec_t *v,vec_t *c,vec_t *n,vec_t *t)
{
#ifdef	DOUBLEVEC
	glColor4dv((GLdouble*)c);
	glTexCoord2dv((GLdouble*)t);
	glVertex3dv((GLdouble*)v);
#else	/* DOUBLEVEC */
	glColor4fv((GLfloat*)c);
	glTexCoord2fv((GLfloat*)t);
	glVertex3fv((GLfloat*)v);
#endif	/* DOUBLEVEC */
}

#include <../source/PAL/argsused.h>
void	V_LOCAL
vDrawVCNT(vec_t *v,vec_t *c,vec_t *n,vec_t *t)
{
#ifdef	DOUBLEVEC
	glColor4dv((GLdouble*)c);
	glTexCoord2dv((GLdouble*)t);
	glNormal3dv((GLdouble*)n);
	glVertex3dv((GLdouble*)v);
#else	/* DOUBLEVEC */
	glColor4fv((GLfloat*)c);
	glTexCoord2fv((GLfloat*)t);
	glNormal3fv((GLfloat*)n);
	glVertex3fv((GLfloat*)v);
#endif	/* DOUBLEVEC */
}

/*
 *	Triangle drawing functions.
 */

void	V_LOCAL
triDrawV(tlist_face_t *tri)
{
	int i;
	for(i=0;i<3;i++)
#ifdef	DOUBLEVEC
		glVertex3dv((GLdouble*)tri->verts[i].vert);
#else	/* DOUBLEVEC */
		glVertex3fv((GLfloat*)tri->verts[i].vert);
#endif	/* DOUBLEVEC */
}

void	V_LOCAL
triDrawVN(tlist_face_t *tri)
{
	int i;
	for(i=0;i<3;i++)
	{
#ifdef	DOUBLEVEC
		glNormal3dv((GLdouble*)tri->verts[i].normal);
		glVertex3dv((GLdouble*)tri->verts[i].vert);
#else	/* DOUBLEVEC */
		glNormal3fv((GLfloat*)tri->verts[i].normal);
		glVertex3fv((GLfloat*)tri->verts[i].vert);
#endif	/* DOUBLEVEC */
	}
}

void	V_LOCAL
triDrawVT(tlist_face_t *tri)
{
	int i;
	for(i=0;i<3;i++)
	{
#ifdef	DOUBLEVEC
		glTexCoord2dv((GLdouble*)tri->verts[i].texcoord);
		glVertex3dv((GLdouble*)tri->verts[i].vert);
#else	/* DOUBLEVEC */
		glTexCoord2fv((GLfloat*)tri->verts[i].texcoord);
		glVertex3fv((GLfloat*)tri->verts[i].vert);
#endif	/* DOUBLEVEC */
	}
}

void	V_LOCAL
triDrawVNT(tlist_face_t *tri)
{
	int i;
	for(i=0;i<3;i++)
	{
#ifdef	DOUBLEVEC
		glNormal3dv((GLdouble*)tri->verts[i].normal);
		glTexCoord2dv((GLdouble*)tri->verts[i].texcoord);
		glVertex3dv((GLdouble*)tri->verts[i].vert);
#else	/* DOUBLEVEC */
		glNormal3fv((GLfloat*)tri->verts[i].normal);
		glTexCoord2fv((GLfloat*)tri->verts[i].texcoord);
		glVertex3fv((GLfloat*)tri->verts[i].vert);
#endif	/* DOUBLEVEC */
	}
}

void	V_LOCAL
triDrawVC(tlist_face_t *tri)
{
	int i;
	for(i=0;i<3;i++)
	{
#ifdef	DOUBLEVEC
		glColor4dv((GLdouble*)tri->verts[i].color);
		glVertex3dv((GLdouble*)tri->verts[i].vert);
#else	/* DOUBLEVEC */
		glColor4fv((GLfloat*)tri->verts[i].color);
		glVertex3fv((GLfloat*)tri->verts[i].vert);
#endif	/* DOUBLEVEC */
	}
}

void	V_LOCAL
triDrawVCN(tlist_face_t *tri)
{
	int i;
	for(i=0;i<3;i++)
	{
#ifdef	DOUBLEVEC
		glColor4dv((GLdouble*)tri->verts[i].color);
		glNormal3dv((GLdouble*)tri->verts[i].normal);
		glVertex3dv((GLdouble*)tri->verts[i].vert);
#else	/* DOUBLEVEC */
		glColor4fv((GLfloat*)tri->verts[i].color);
		glNormal3fv((GLfloat*)tri->verts[i].normal);
		glVertex3fv((GLfloat*)tri->verts[i].vert);
#endif	/* DOUBLEVEC */
	}
}

void	V_LOCAL
triDrawVCT(tlist_face_t *tri)
{
	int i;
	for(i=0;i<3;i++)
	{
#ifdef	DOUBLEVEC
		glColor4dv((GLdouble*)tri->verts[i].color);
		glTexCoord2dv((GLdouble*)tri->verts[i].texcoord);
		glVertex3dv((GLdouble*)tri->verts[i].vert);
#else	/* DOUBLEVEC */
		glColor4fv((GLfloat*)tri->verts[i].color);
		glTexCoord2fv((GLfloat*)tri->verts[i].texcoord);
		glVertex3fv((GLfloat*)tri->verts[i].vert);
#endif	/* DOUBLEVEC */
	}
}

void	V_LOCAL
triDrawVCNT(tlist_face_t *tri)
{
	int i;
	for(i=0;i<3;i++)
	{
#ifdef	DOUBLEVEC
		glColor4fv((GLfloat*)tri->verts[i].color);
		glNormal3fv((GLfloat*)tri->verts[i].normal);
		glTexCoord2fv((GLfloat*)tri->verts[i].texcoord);
		glVertex3fv((GLfloat*)tri->verts[i].vert);
#else	/* DOUBLEVEC */
		glColor4fv((GLfloat*)tri->verts[i].color);
		glNormal3fv((GLfloat*)tri->verts[i].normal);
		glTexCoord2fv((GLfloat*)tri->verts[i].texcoord);
		glVertex3fv((GLfloat*)tri->verts[i].vert);
#endif	/* DOUBLEVEC */
	}
}

/*
 *	bit 0 - normal;
 *	bit 1 - texture;
 *	bit 2 - color.
 */
V_LOCAL	vertex_draw_proc_t	vert_draw_procs[8]=
{
	vDrawV,
	vDrawVN,
	vDrawVT,
	vDrawVNT,
	vDrawVC,
	vDrawVCN,
	vDrawVCT,
	vDrawVCNT
};

V_LOCAL	tri_draw_proc_t	tri_draw_procs[8]=
{
	triDrawV,
	triDrawVN,
	triDrawVT,
	triDrawVNT,
	triDrawVC,
	triDrawVCN,
	triDrawVCT,
	triDrawVCNT
};

u32_t	V_CALL
vglGetDrawBits(void)
{
	u32_t draw_bits=0;
	/* glNormalXXX calls useless if lighting disabled */
	if(glIsEnabled(GL_LIGHTING))
		draw_bits|=NORMAL_DRAW_BIT;
	/* glTextureXXX calls useless if texturing disabled */
	if(glIsEnabled(GL_TEXTURE_2D) || glIsEnabled(GL_TEXTURE_2D))
		draw_bits|=TEXTURE_DRAW_BIT;
	/*	what we do to decide wheither or not glColorXXX calls 
	 *	are necessary ? */
	draw_bits|=COLOR_DRAW_BIT;
	return draw_bits;
}

/*
 *	if draw_bits==-1 than appropriate function determined automatically
 */
vertex_draw_proc_t	V_CALL
vglGetVertexDrawProc(int draw_bits)
{
	if(draw_bits<0)
		return vert_draw_procs[vglGetDrawBits()];
	else
		return vert_draw_procs[draw_bits & 7];
}

tri_draw_proc_t	V_CALL
vglGetTriangleDrawProc(int draw_bits)
{
	if(draw_bits<0)
		return tri_draw_procs[vglGetDrawBits()];
	else
		return tri_draw_procs[draw_bits & 7];
}

/*</pre></html>*/
/*EOF*/
