/*------------------------------------------------------------------------------
 src/lib/djWidget/djOgl.h
 
 Copyright (c) 2004-2006 Darby Johnston.
 All rights reserved.
 Use is subject to license terms.
------------------------------------------------------------------------------*/

#ifndef DJ_OGL_H
#define DJ_OGL_H
#include <djImage.h>
#include <GL/gl.h>

namespace dj {

// Functions.
//
void oglOrtho(int w, int h, double min = -1.0, double max = 1.0);
void oglPoints(const Box2i &);
GLenum oglFormat(PIXEL_FORMAT);
GLenum oglType(PIXEL_TYPE);

// Debugging.
//
// References:
// * Dave Shreiner, "Performance OpenGL: Platform Independent Techniques",
//   SIGGRAPH 2001.
//
#ifdef DJ_DBG
#include <GL/glu.h>
#define DJ_DBG_OGL(cmd) \
  cmd; \
  { \
    GLenum error; \
    while ((error = glGetError()) != GL_NO_ERROR) \
      DJ_DBG_PRN( \
        Str("%1 = %2 (%3, line %4)"). \
          arg(#cmd).arg((char *)gluErrorString(error)). \
          arg(__FILE__).arg(__LINE__) \
      ); \
  }
#else
#define DJ_DBG_OGL(cmd) cmd;
#endif

}

#endif
