Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TGL_INCLUDED
Toshihiro Shimizu 890ddd
#define TGL_INCLUDED
Toshihiro Shimizu 890ddd
Shinya Kitaoka 6f0974
//#include "tgeometry.h"
Toshihiro Shimizu 890ddd
#include "tmachine.h"
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
#include <windows.h></windows.h>
Shinya Kitaoka d4642c
#include <cstdlib></cstdlib>
Shinya Kitaoka 6f0974
Toshihiro Shimizu 890ddd
#include <gl gl.h=""></gl>
Toshihiro Shimizu 890ddd
#include <gl glu.h=""></gl>
Toshihiro Shimizu 890ddd
#include <gl glut.h=""></gl>
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef MACOSX
Toshihiro Shimizu 890ddd
#include <glut glut.h=""></glut>
Toshihiro Shimizu 890ddd
#define GLUT_NO_LIB_PRAGMA
Toshihiro Shimizu 890ddd
#define GLUT_NO_WARNING_DISABLE
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Rozhuk Ivan ac51ab
#if defined(LINUX) || defined(FREEBSD)
Campbell Barton 07f3e8
#include <gl gl.h=""></gl>
Campbell Barton 07f3e8
#include <gl glu.h=""></gl>
Campbell Barton 07f3e8
#include <gl glut.h=""></gl>
Campbell Barton 07f3e8
#endif
Campbell Barton 07f3e8
Toshihiro Shimizu 890ddd
//#include "tcurves.h"
Toshihiro Shimizu 890ddd
#include "traster.h"
Toshihiro Shimizu 890ddd
//#include "tfilepath.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TFilePath;
Toshihiro Shimizu 890ddd
class TCubic;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef DV_LOCAL_DEFINED
Toshihiro Shimizu 890ddd
#define DVAPI
Toshihiro Shimizu 890ddd
#define DVVAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#ifdef TGL_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Campbell Barton d869b5
#if defined(TNZ_MACHINE_CHANNEL_ORDER_BGRM)
Toshihiro Shimizu 890ddd
#define TGL_FMT GL_BGRA_EXT
Campbell Barton d869b5
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_MBGR)
Toshihiro Shimizu 890ddd
#define TGL_FMt GL_ABGR_EXT
Campbell Barton d869b5
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_RGBM)
Toshihiro Shimizu 890ddd
#define TGL_FMT GL_RGBA
Campbell Barton d869b5
#elif defined(TNZ_MACHINE_CHANNEL_ORDER_MRGB)
Toshihiro Shimizu 890ddd
#define TGL_FMT GL_BGRA
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
@undefined chan order
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef TNZ_MACHINE_CHANNEL_ORDER_MRGB
Toshihiro Shimizu 890ddd
#define TGL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define TGL_TYPE GL_UNSIGNED_BYTE
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
shun-iwasawa 215a5b
// settings for 30bit display
shun-iwasawa 215a5b
shun-iwasawa 215a5b
#define TGL_TexFmt10 GL_RGB10_A2
shun-iwasawa 215a5b
#define TGL_TYPE16 GL_UNSIGNED_SHORT
shun-iwasawa 215a5b
shun-iwasawa 215a5b
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Shinya Kitaoka 120a6e
#define CHECK_ERRORS_BY_GL                                                     \
Shinya Kitaoka 120a6e
  {                                                                            \
Shinya Kitaoka 120a6e
    GLenum glErr = glGetError();                                               \
Shinya Kitaoka 120a6e
    assert(glErr != GL_INVALID_ENUM);                                          \
Shinya Kitaoka 120a6e
    assert(glErr != GL_INVALID_VALUE);                                         \
Shinya Kitaoka 120a6e
    assert(glErr != GL_INVALID_OPERATION);                                     \
Shinya Kitaoka 120a6e
    assert(glErr != GL_STACK_OVERFLOW);                                        \
Shinya Kitaoka 120a6e
    assert(glErr != GL_STACK_UNDERFLOW);                                       \
Shinya Kitaoka 120a6e
    assert(glErr != GL_OUT_OF_MEMORY);                                         \
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define CHECK_ERRORS_BY_GL ;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// forward declarations
Toshihiro Shimizu 890ddd
class TStroke;
Toshihiro Shimizu 890ddd
class TVectorImage;
Toshihiro Shimizu 890ddd
class TVectorRenderData;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! Extension to set a vertex
Toshihiro Shimizu 890ddd
inline void tglVertex(const TPointD &p) { glVertex2d(p.x, p.y); }
Toshihiro Shimizu 890ddd
inline void tglVertex(const TPoint &p) { glVertex2i(p.x, p.y); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! Extension to set a color
Toshihiro Shimizu 890ddd
inline void tglColor(const TPixel &p) { glColor4ub(p.r, p.g, p.b, p.m); }
Toshihiro Shimizu 890ddd
inline void tglColor(const TPixelD &p) { glColor4d(p.r, p.g, p.b, p.m); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! retrieve the square of pixel size from current GL_MODELVIEW matrix
Toshihiro Shimizu 890ddd
DVAPI double tglGetPixelSize2();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! Draw text in string s at position p.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
DVAPI void tglDrawText(const TPointD &p, const std::string &s,
Shinya Kitaoka 120a6e
                       void *font = GLUT_STROKE_ROMAN);
Shinya Kitaoka 120a6e
DVAPI void tglDrawText(const TPointD &p, const std::wstring &s,
Shinya Kitaoka 120a6e
                       void *font = GLUT_STROKE_ROMAN);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! Returns text width
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
DVAPI double tglGetTextWidth(const std::string &s,
Shinya Kitaoka 120a6e
                             void *font = GLUT_STROKE_ROMAN);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
 Draw circle of radius r with center c.
Toshihiro Shimizu 890ddd
 Remark: it is possible set number of slices
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
DVAPI void tglDrawCircle(const TPointD &c, double r);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
 Draw circle of radius r with center c.
Toshihiro Shimizu 890ddd
 Remark: it is possible set number of slices
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
DVAPI void tglDrawDisk(const TPointD &c, double r);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
 Draw a segment.
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
DVAPI void tglDrawSegment(const TPointD &p1, const TPointD &p2);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
inline void tglDrawSegment(const TPoint &p1, const TPoint &p2) {
Shinya Kitaoka 120a6e
  tglDrawSegment(convert(p1), convert(p2));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
inline void tglDrawSegment(double x0, double y0, double x1, double y1) {
Shinya Kitaoka 120a6e
  tglDrawSegment(TPointD(x0, y0), TPointD(x1, y1));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// inline  void  glDrawSegment(const TSegment& s){
Toshihiro Shimizu 890ddd
//  glDrawSegment( s.getP0(), s.getP1() );
Toshihiro Shimizu 890ddd
//}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
 Draw a rect.
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
DVAPI void tglDrawRect(const TRectD &rect);
Toshihiro Shimizu 890ddd
2fc36c
inline void tglDrawRect(const TRect &rect) { tglDrawRect(convert(rect)); }
Toshihiro Shimizu 890ddd
2fc36c
inline void tglDrawRect(double x0, double y0, double x1, double y1) {
Shinya Kitaoka 120a6e
  tglDrawRect(TRectD(x0, y0, x1, y1));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
 Fill a rect.
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
DVAPI void tglFillRect(const TRectD &rect);
Toshihiro Shimizu 890ddd
2fc36c
inline void tglFillRect(const TRect &rect) { tglFillRect(convert(rect)); }
Toshihiro Shimizu 890ddd
2fc36c
inline void tglFillRect(double x0, double y0, double x1, double y1) {
Shinya Kitaoka 120a6e
  tglFillRect(TRectD(x0, y0, x1, y1));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
inline void tglMultMatrix(const TAffine &aff) {
Shinya Kitaoka 120a6e
  GLdouble m[] = {aff.a11, aff.a21, 0, 0, aff.a12, aff.a22, 0, 0,
Shinya Kitaoka 120a6e
                  0,       0,       1, 0, aff.a13, aff.a23, 0, 1};
Shinya Kitaoka 120a6e
  glMultMatrixd(m);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI tglRgbOnlyColorMask();
Toshihiro Shimizu 890ddd
void DVAPI tglAlphaOnlyColorMask();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI tglEnableBlending(GLenum src = GL_SRC_ALPHA,
Shinya Kitaoka 120a6e
                             GLenum dst = GL_ONE_MINUS_SRC_ALPHA);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI tglEnableLineSmooth(bool enable = true, double lineSize = 1.0);
Toshihiro Shimizu 890ddd
void DVAPI tglEnablePointSmooth(double pointSize = 1.0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void DVAPI tglGetColorMask(GLboolean &red, GLboolean &green, GLboolean &blue,
Shinya Kitaoka 120a6e
                           GLboolean &alpha);
Shinya Kitaoka 120a6e
void DVAPI tglMultColorMask(GLboolean red, GLboolean green, GLboolean blue,
Shinya Kitaoka 120a6e
                            GLboolean alpha);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  Draw a stroke in a GL context.
Toshihiro Shimizu 890ddd
  \par stroke is element to draw
Toshihiro Shimizu 890ddd
  \par rd: \sa TVectorRenderData
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
/* spostati in tvectorgl.h
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI tglDraw(const TVectorRenderData &rd, const TStroke* stroke);
Toshihiro Shimizu 890ddd
void DVAPI tglDraw(const TVectorRenderData &rd, const TVectorImage* vim);
Toshihiro Shimizu 890ddd
void DVAPI tglDrawMask(const TVectorRenderData &rd, const TVectorImage* vim);
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  Draw a vector image in a GL context.
Toshihiro Shimizu 890ddd
  \par vi vector image to draw
Toshihiro Shimizu 890ddd
 */
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
void DVAPI  drawVectorImage(
Toshihiro Shimizu 890ddd
                     const TVectorImageP& vim,
Shinya Kitaoka 120a6e
                     const TRect& clippingRect,
Toshihiro Shimizu 890ddd
                     const TAffine& aff,
Toshihiro Shimizu 890ddd
                     const TColorFunction *cf = 0);
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#define NEW_DRAW_TEXT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
enum GlDrawTextIndentation { Left = 0, Right = 1, Center = 2 };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// precision is the number of segments to draw the curve
Shinya Kitaoka 120a6e
void DVAPI tglDraw(const TCubic &cubic, int precision,
Shinya Kitaoka 120a6e
                   GLenum pointOrLine = GL_LINE);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void DVAPI tglDraw(const TRectD &rect, const std::vector<traster32p> &textures,</traster32p>
Shinya Kitaoka 120a6e
                   bool blending = true);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void DVAPI tglDraw(const TRectD &rect, const TRaster32P &tex,
Shinya Kitaoka 120a6e
                   bool blending = true);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI tglBuildMipmaps(std::vector<traster32p> &rasters,</traster32p>
Shinya Kitaoka 120a6e
                           const TFilePath &filepath);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 9f5a1b
#ifdef _WIN32
Toshihiro Shimizu 890ddd
typedef std::pair<hdc, hglrc=""> TGlContext;</hdc,>
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
typedef void *TGlContext;
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DVAPI TGlContext tglGetCurrentContext();
Toshihiro Shimizu 890ddd
DVAPI void tglMakeCurrent(TGlContext context);
Toshihiro Shimizu 890ddd
DVAPI void tglDoneCurrent(TGlContext context);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif