/*
 * $Id$
 *
 * $Date$
 * $Revision$
 *
 * (C) 1999 by Hyperion
 * All rights reserved
 *
 * This file is part of the MiniGL library project
 * See the file Licence.txt for more details
 *
 */
#ifndef __MINIGL_COMPILER_H
#define __MINIGL_COMPILER_H

#define __NOGLOBALIFACE__
extern struct Library *Warp3DBase;

#include <proto/exec.h>
#include <proto/warp3d.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include <proto/dos.h>
#include <proto/Picasso96API.h>
#include <proto/utility.h>

#include <exec/types.h>
#include <exec/exec.h>
#include <intuition/intuition.h>
#include <graphics/gfx.h>
#include <graphics/scale.h>
#include <utility/tagitem.h>
#include <dos/dos.h>
#include <dos/exall.h>
#include <devices/timer.h>
#include <warp3D/warp3D.h>

#include "mgl/config.h"

extern struct ExecIFace *IExec;
extern struct DOSIFace *IDOS;

extern struct Library *UtilityBase;
extern struct UtilityIFace *IUtility;
extern struct Library *IntuitionBase;
extern struct IntuitionIFace *IIntuition;
extern struct Library *GfxBase;
extern struct GraphicsIFace *IGraphics;
extern struct Library *Warp3DBase;
extern struct Warp3DIFace *IWarp3D;
extern struct Library *P96Base;
extern struct P96IFace *IP96;
extern struct Device *TimerBase;
extern struct TimerIFace *ITimer;


#ifndef UNUSED
#if defined(__GNUC__)
    #define UNUSED  __attribute__ ((unused))
#else
    #define UNUSED
#endif
#endif

#ifndef GLNDEBUG
	#warning "Debug output enabled"
	#define GLASSERT(c) if (!(c)) dprintf("Assertion failed %s\n", # c);
	#define dprintf(format, args...)((struct ExecIFace *)((*(struct ExecBase **)4)->MainInterface))->DebugPrintF("[%s] " format, __PRETTY_FUNCTION__ , ## args)
	#define kprintf(format, args...)((struct ExecIFace *)((*(struct ExecBase **)4)->MainInterface))->DebugPrintF(format, ## args)
#else
	#define GLASSERT(c)
	#define dprintf(x, args...)
	#define kprintf(x, args...)
#endif

#ifndef GL_NOERRORCHECK
	#define GLFlagError(context,c,err) \
	while ((c)) {\
		kprintf("FlagError in %s:%ld, error = %s\n", __PRETTY_FUNCTION__, __LINE__, #err);\
		context->CurrentError = err;\
		return;\
	}
	#define GLFlagError2(context,c,err,ret) \
	while ((c)) {\
		kprintf("FlagError in %s:%ld, error = %s\n", __PRETTY_FUNCTION__, __LINE__, #err);\
		context->CurrentError = err;\
		return ret;\
	}

#else
	#define GLFlagError(context,c,err)
	#define GLFlagError2(context,c,err,ret)

#endif

#ifndef GET_INSTANCE
#define GET_INSTANCE(self)                          \
          (GLcontext)((uint32)self - self->Data.NegativeSize)
#endif

#include "GL/gl.h"
#include "GL/glext.h"
#include "mgl/matrix.h"

#endif
