#if 0
//<copyright>
//
// Copyright (c) 1992,93,94,95,96,97
// Institute for Information Processing and Computer Supported New Media (IICM),
// Graz University of Technology, Austria.
//
// This file is part of VRweb.
//
// VRweb is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or (at your option)
// any later version.
//
// VRweb is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with VRweb; see the file LICENCE. If not, write to the
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
//</copyright>
#endif

/*
 * File:     ge3d.h
 *
 * Authors:  Michael Hofer (until May 92) and Michael Pichler
 *
 * Created:   1 Apr 92
 *
 * Changed:  20 Dec 97   Karl Heinz Wagenbrunn (stereo view, transparency)
 *
 * Changed:  12 Feb 97   Michael Pichler
 *
 * $Id: ge3d.h,v 1.19 1997/05/13 18:25:28 mpichler Exp $
 *
 */


/*
 * Interface to the Graphics Engine 3D
 *
 */


#ifndef ge3d_ge3d_h
#define ge3d_ge3d_h


#ifdef __cplusplus
#define GE3D_PROTOTYPES
extern "C" {
#endif
#ifdef __GNUC__
#define GE3D_PROTOTYPES
#endif

#include "ge3drc.h"  /* revision control */

#include "face.h"
#include "vectors.h"
#include "color.h"
#include "mtl.h"


/* changed from mode_t to ge3d_mode_t (collision with CC/types.h) */

enum ge3d_mode_t
{ ge3d_wireframe,
  ge3d_hidden_line,
  ge3d_flat_shading,
  ge3d_smooth_shading,
  ge3d_texturing
};

enum ge3d_hint_t
{ hint_depthbuffer,
  hint_backfaceculling,
  hint_lighting,
  hint_texlighting,
  hint_ambientcolor,
  hint_quadslices,
  hint_transparency,
  hint_ccw
};

enum ge3d_bitplane_t
{ ge3d_normal_planes,
  ge3d_overlay_planes
};

enum ge3d_bitmapformat_t
{
  ge3d_ubyte_RGB_TB,    /* RGB triples of unsigned byte, no filling byte, top-to-bottom */
  ge3d_ubyte_I_BT,      /* intensity, bottom-to-top */
  ge3d_ubyte_IA_BT,     /* intensity and Alpha, bottom-to-top */
  ge3d_ubyte_RGB_BT,    /* RGB triples, bottom-to-top */
  ge3d_ubyte_RGBA_BT,   /* RGBA quadruples, bottom-to-top */
  ge3d_int_I_BT,        /* int array (32 bit), 0xII values, bottom-to-top */
  ge3d_int_IA_BT,       /* int array (32 bit), 0xIIAA values, bottom-to-top */
  ge3d_int_RGB_BT,      /* int array (32 bit), 0xRRGGBB values, bottom-to-top */
  ge3d_int_RGBA_BT,     /* int array (32 bit), 0xRRGGBBAA values, bottom-to-top */
  ge3d_int_ARGB_TB      /* int array (32 bit), 0xAARRGGBB values, top-to-bottom */
};                      /* all int values in native byte order */

enum ge3d_antialiasing_t
{ ge3d_aa_lines = 0x1,
  ge3d_aa_polygons = 0x2,
  ge3d_aa_polygons_front2back = 0x4,
  ge3d_aa_all = ~0
};

enum ge3d_camera_t  /* constants for ge3dCamera */
{
  /* if neither cam_perspective nor cam_orthographic set, projection matrix unchanged */
  cam_perspective = 0x1,
  cam_orthographic = 0x2,
  /* if neither cam_absolute nor cam_relative set, modelview matrix unchanged */
  cam_absolute = 0x4,
  cam_relative = 0x8
};

enum ge3d_eye_t  /* stereo flags */
{
  eye_monoview = 0,
  eye_right = 1,
  eye_left = 2
};

enum ge3d_transparency_t  /* transparency method */
{
  transp_off = 0,
  transp_stipple = 1,
  transp_blend = 2
};

enum ge3d_cylinder_t  /* cylinder parts */
{
  cyl_sides = 0x1,
  cyl_bottom = 0x2,
  cyl_top = 0x4,
  cyl_all = 0x7
};


/* only C++ treats global const ints const */
#define ge3d_maxmipmap_quality 5



#ifdef GE3D_PROTOTYPES


void ge3d_openwindow ();
void ge3d_linkXwindow (void*, void*);
void ge3d_init_ ();
void ge3dHint (int /*ge3d_hint_t*/, int /*value*/);

void ge3d_clearscreen ();
void ge3d_swapbuffers ();

void ge3d_moveto (float, float, float);
void ge3dMoveTo (const point3D*);
void ge3d_lineto (float, float, float);
void ge3dLineTo (const point3D*);
void ge3d_line (float, float, float, float, float, float);
void ge3dLine (const point3D*, const point3D*);
void ge3d_wirecube (float, float, float, float, float, float);
/* void ge3dWireCube (const point3D*, const point3D*) -- macro */
void ge3dPolyLines2D (float*);

void ge3dCube (const point3D*, const point3D*);
void ge3dShadedPolygon (int, const point3D*, const colorRGB*);

/* void ge3d_polygon (...); */  /* macro */
void ge3dPolygon (const point3D* vl, int nv, const int* vi,
  const vector3D* nl, int nn, const int* ni, const vector3D* fn,
  const point2D* tv, int nt, const int* ti);
/* void ge3d_polyhedron (point3D*, vector3D*, int, face*); */  /* macro */
void ge3dPolyhedron (point3D*, vector3D*, point2D*, int, face*);
void ge3d_wirepolyhedron (point3D*, vector3D*, int, face*);
void ge3dFaceSet (const point3D* vl, int nv, const int* vi,
  const materialsGE3D* ml, int mb, int nm, const int* mi,
  const vector3D* nl, int nn, const int* ni, const vector3D* fn,
  const point2D* tl, int nt, const int* ti);
void ge3dLineSet (const point3D* vl, int nv, const int* vi);
void ge3dPointSet (const point3D*, int);

void ge3dSphere (float);
void ge3dCylinder (float br, float tr, float b, float h, int);

void ge3d_setmode (int);

void ge3d_setbackgcolor (float, float, float);
void ge3dBackgroundColor (const colorRGB*);
void ge3d_setfillcolor (float, float, float);
void ge3dMaterial (int /*ge3d_material_t*/, const materialsGE3D*);  /* front/back, definitions */
void ge3dDefaultMaterial ();
void ge3dFillColor (const colorRGB*);
void ge3d_setlinecolor (float, float, float);
void ge3dLineColor (const colorRGB*);
void ge3d_setlinestyle (short);
void ge3d_setlinewidth (short);
void ge3dAntialiasing (int);  /* ge3d_antialiasing_t */
int ge3dAntialiasingSupport ();
void ge3dAlphaTest (float threshold);

void ge3d_text (float, float, float, const char*);
void ge3dText (const point3D*, const char*);

void ge3d_rect (float, float, float, float);
void ge3d_rectf (float, float, float, float);
void ge3dFilledRect (float, float, float, float, float);
void ge3d_circle (float, float, float);
void ge3d_circf (float, float, float);
void ge3d_arc (float, float, float, float, float);

void ge3dSetLightSource (int index, const colorRGB*, const point3D*, float positional, int camlgt);
void ge3dLightSource (int index, const colorRGB*, /*const*/ matrix4D, float positional, int camlgt);
void ge3dSpotLight (int index, const colorRGB*, const point3D* pos, const vector3D* dir,
  float droprate, float cutangle);
void ge3d_switchlight (int, int);
void ge3dGlobalAmbient (const colorRGB*);

void ge3d_transform_mc_wc (float, float, float, float*, float*, float*);
void ge3dTransformMcWc (const point3D*, point3D*);
void ge3d_transformvector_mc_wc (float, float, float, float*, float*, float*);
void ge3dTransformVectorMcWc (const vector3D*, vector3D*);

void ge3d_clearzbuffer ();
void ge3d_colormask (int, int, int, int);  /* RGBA */

void ge3d_setcamera (const point3D*, const point3D*, const point3D*,
  float, float, float, float, float, int /*ge3d_eye_t*/, float, float);
void ge3d_ortho_cam (const point3D*, const point3D*, const point3D*, float, float, float, float);
void ge3dCamera (int /*ge3d_camera_t*/, const point3D*, float, const vector3D*, float, float, float, float);

void ge3d_push_matrix ();
void ge3dPushIdentity ();
void ge3dLoadIdentity ();
void ge3d_push_this_matrix (const float [4][4]);
void ge3d_push_new_matrix (const float [4][4]);
void ge3dMultMatrix (const float [4][4]);

void ge3d_print_cur_matrix ();
void ge3d_get_and_pop_matrix (matrix4D);
void ge3d_get_matrix (matrix4D);
void ge3d_pop_matrix ();

void ge3d_rotate_axis (char, float);
void ge3dRotate (const vector3D*, float);  /* (angle in radians!) */
void ge3d_translate (float, float, float);
void ge3dTranslate (const vector3D*);
void ge3d_scale (float, float, float, float);
void ge3dScale (const float*);

int ge3dTexturingSupport ();
int ge3dCreateTexture (int width, int height, const void* data, int /* ge3d_bitmapformat_t */, int* retflags);
void ge3dFreeTexture (int handle);
void ge3dDoTexturing (int toggle);
void ge3dApplyTexture (int handle);
void ge3dTextureRepeat (int s, int t);
void ge3dTextureMipmapping (int quality);  /* 0 to 5 */
int ge3dCurrentTextureMipmapping ();
void ge3dLoadTextureIdentity ();
void ge3dMultTextureMatrix (const float [4][4]);
void ge3dLoadTextureMatrix (const float [4][4]);
void ge3dGetTextureMatrix (matrix4D);
void ge3dTexturedPolygon (int nverts, const point3D*, const point2D*, int handle);

int ge3dRequestOverlay ();
void ge3dBitplanes (int);
void ge3dClearOverlay ();
void ge3dMapColori (int, short, short, short);
void ge3dMapColorRGB (int, const colorRGB*);
void ge3dColorIndex (int);

void ge3d_close ();


#else


void ge3d_openwindow ();
void ge3d_linkXwindow ();
void ge3d_init_ ();
void ge3dHint ();

void ge3d_clearscreen ();
void ge3d_swapbuffers ();

void ge3d_moveto ();
void ge3dMoveTo ();
void ge3d_lineto ();
void ge3dLineTo ();
void ge3d_line ();
void ge3dLine ();
void ge3d_wirecube ();
void ge3dPolyLines2D ();

void ge3dCube ();
void ge3dShadedPolygon ();

/* void ge3d_polygon (); */  /* macro */
void ge3dPolygon ();
/* void ge3d_polyhedron (); */  /* macro */
void ge3dPolyhedron ();
void ge3d_wirepolyhedron ();
void ge3dFaceSet ();
void ge3dLineSet ();
void ge3dPointSet ();

void ge3dSphere ();
void ge3dCylinder ();

void ge3d_setmode ();

void ge3d_setbackgcolor ();
void ge3dBackgroundColour ();
void ge3d_setfillcolor ();
void ge3dMaterial ();
void ge3dDefaultMaterial ();
void ge3dFillColor ();
void ge3d_setlinecolor ();
void ge3dLineColor ();
void ge3d_setlinestyle ();
void ge3d_setlinewidth ();
void ge3dAntialiasing ();
int ge3dAntialiasingSupport ();
void ge3dAlphaTest ();

void ge3d_text ();
void ge3dText ();

void ge3d_rect ();
void ge3d_rectf ();
void ge3dFilledRect ();
void ge3d_circle ();
void ge3d_circf ();
void ge3d_arc ();

void ge3dSetLightSource ();
void ge3dLightSource ();
void ge3dSpotLight ();
void ge3d_switchlight ();
void ge3dGlobalAmbient ();

void ge3d_transform_mc_wc ();
void ge3dTransformMcWc ();
void ge3d_transformvector_mc_wc ();
void ge3dTransformVectorMcWc ();

void ge3d_clearzbuffer ();
void ge3d_colormask ();

void ge3d_setcamera ();
void ge3d_ortho_cam ();
void ge3dCamera ();

void ge3d_push_matrix ();
void ge3dPushIdentity ();
void ge3dLoadIdentity ();
void ge3d_push_this_matrix ();
void ge3d_push_new_matrix ();
void ge3dMultMatrix ();

void ge3d_print_cur_matrix ();
void ge3d_get_and_pop_matrix ();
void ge3d_get_matrix ();
void ge3d_pop_matrix ();

void ge3d_rotate_axis ();
void ge3dRotate ();
void ge3d_translate ();
void ge3dTranslate ();
void ge3d_scale ();
void ge3dScale ();

int ge3dTexturingSupport ();
int ge3dCreateTexture ();
void ge3dFreeTexture ();
void ge3dDoTexturing ();
void ge3dApplyTexture ();
void ge3dTextureRepeat ();
void ge3dTextureMipmapping ();
int ge3dCurrentTextureMipmapping ();
void ge3dLoadTextureIdentity ();
void ge3dMultTextureMatrix ();
void ge3dLoadTextureMatrix ();
void ge3dGetTextureMatrix ();
void ge3dTexturedPolygon ();

int ge3dRequestOverlay ();
void ge3dBitplanes ();
void ge3dClearOverlay ();
void ge3dMapColori ();
void ge3dMapColorRGB ();
void ge3dColorIndex ();

void ge3d_close ();


#endif



#define ge3dWireCube(p, q)  ge3d_wirecube ((p)->x, (p)->y, (p)->z, (q)->x, (q)->y, (q)->z)
#define ge3dFillColor(c)  ge3d_setfillcolor ((c)->R, (c)->G, (c)->B)
#define ge3d_polygon(vl, nv, vi, nl, nn, ni, fn)  ge3dPolygon ((vl), (nv), (vi), (nl), (nn), (ni), (fn), 0, 0, 0)
#define ge3d_polyhedron(p, v, n, f)  ge3dPolyhedron ((p), (v), 0, (n), (f))

#ifdef __cplusplus
}
#endif



#endif
