/*
 * grOGLInt.h --
 *
 * Internal definitions for grOGL[1..].c.
 *
 * NOTE:  In order for the these defs to work correctly, this file
 * (grXInt.h) must be included after all the Magic .h files and before
 * the X .h files.
 */

#ifndef	__GRAPHICS_GROGLINT_H__
#define	__GRAPHICS_GROGLINT_H__

/* Constants
 */
#define M_WIDTH		1023
#define M_HEIGHT	750

#define MAX_CURSORS	32	/* Maximum number of cursors */

#define GR_DEFAULT_FONT "9x15"
#define OGL_BATCH_SIZE	10000

#define true		1
#define false		0

#undef TRUE

# define        X_FONT_SMALL    "-*-helvetica-medium-r-normal--10-*-75-75-p-*-iso8859-*"
# define        X_FONT_MEDIUM   "-*-helvetica-medium-r-normal--14-*-75-75-p-*-iso8859-*"
# define        X_FONT_LARGE    "-*-helvetica-medium-r-normal--18-*-75-75-p-*-iso8859-*"
# define        X_FONT_XLARGE   "-*-helvetica-medium-r-normal--24-*-75-75-p-*-iso8859-*"

/* Current settings for X function parameters */
typedef struct {
    XFontStruct		*font;
    int			cursor;
    int			fontSize;
    int			depth;
    int			maskmod;
    Window 		window;
    MagWindow		*mw;
} OGL_CURRENT;

/* used for vertex arrays */
typedef struct {
  Point r_ll, r_ul, r_ur, r_lr;
} OGLRect;

/*------------------------------------------------------*/

extern OGL_CURRENT oglCurrent;

extern bool groglGetCursorPos();
extern bool groglDrawGrid();
extern Void GrOGLEnableTablet();
extern Void GrOGLDisableTablet();
extern Void GrOGLSetCMap();
extern Void GrOGLInitWithArgs();
extern Void groglPutText();
extern Void groglDefineCursor();
extern Void GrOGLSetCursor();
extern Void GrOGLSetWindow();
extern Void GrOGLTextSize();
extern Void GrOGLDrawGlyph();
extern Void GrOGLBitBlt();
extern Void NullBitBlt();
extern int  GrOGLReadPixel();
extern Void groglDrawLine();
extern Void groglSetLineStyle();
extern Void groglSetCharSize();
extern Void groglSetWMandC();
extern Void groglFillRect();
#ifdef NONMANHATTAN
extern Void groglFillPolygon();
#endif

extern Rect groglLines[];
extern OGLRect groglRects[];
extern Void groglDrawLines();
extern int groglNbLines;
extern Void groglFillRects();
extern int groglNbRects;

#define ErrPrint(a)		 { fprintf(stderr, a); fflush(stderr); }
#define ErrPrint1(a, b)		 { fprintf(stderr, a, b); fflush(stderr); }
#define ErrPrint2(a, b, c)	 { fprintf(stderr, a, b, c); fflush(stderr); }
#define ErrPrint3(a, b, c, d)	 { fprintf(stderr, a, b, c, d); fflush(stderr); }
#define ErrPrint4(a, b, c, d, e) { fprintf(stderr, a, b, c, d, e); fflush(stderr); }

#define glTransY(n)	( oglCurrent.mw->w_allArea.r_ytop - (n))

#define GR_X_FLUSH_LINES() {if (groglNbLines>0) {groglDrawLines(groglLines, groglNbLines); groglNbLines=0;}}
#define GR_X_FLUSH_RECTS() {if (groglNbRects>0) {groglFillRects(groglRects, groglNbRects); groglNbRects=0;}}
#define	GR_X_FLUSH_BATCH() {GR_X_FLUSH_LINES(); GR_X_FLUSH_RECTS();}

#endif	/* __GRAPHICS_GROGLINT_H__ */

