|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef TGL_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define TGL_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//#include "tgeometry.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tmachine.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef WIN32
|
|
Toshihiro Shimizu |
890ddd |
#include <windows.h></windows.h>
|
|
Toshihiro Shimizu |
890ddd |
//#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
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 |
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TNZ_MACHINE_CHANNEL_ORDER_BGRM
|
|
Toshihiro Shimizu |
890ddd |
#define TGL_FMT GL_BGRA_EXT
|
|
Toshihiro Shimizu |
890ddd |
#elif TNZ_MACHINE_CHANNEL_ORDER_MBGR
|
|
Toshihiro Shimizu |
890ddd |
#define TGL_FMt GL_ABGR_EXT
|
|
Toshihiro Shimizu |
890ddd |
#elif TNZ_MACHINE_CHANNEL_ORDER_RGBM
|
|
Toshihiro Shimizu |
890ddd |
#define TGL_FMT GL_RGBA
|
|
Toshihiro Shimizu |
890ddd |
#elif 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 |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifdef _DEBUG
|
|
Toshihiro Shimizu |
890ddd |
#define CHECK_ERRORS_BY_GL \
|
|
Toshihiro Shimizu |
890ddd |
{ \
|
|
Toshihiro Shimizu |
890ddd |
GLenum glErr = glGetError(); \
|
|
Toshihiro Shimizu |
890ddd |
assert(glErr != GL_INVALID_ENUM); \
|
|
Toshihiro Shimizu |
890ddd |
assert(glErr != GL_INVALID_VALUE); \
|
|
Toshihiro Shimizu |
890ddd |
assert(glErr != GL_INVALID_OPERATION); \
|
|
Toshihiro Shimizu |
890ddd |
assert(glErr != GL_STACK_OVERFLOW); \
|
|
Toshihiro Shimizu |
890ddd |
assert(glErr != GL_STACK_UNDERFLOW); \
|
|
Toshihiro Shimizu |
890ddd |
assert(glErr != GL_OUT_OF_MEMORY); \
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
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 |
|
|
Toshihiro Shimizu |
890ddd |
//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 |
|
|
Toshihiro Shimizu |
890ddd |
DVAPI void tglDrawText(const TPointD &p, const string &s, void *font = GLUT_STROKE_ROMAN);
|
|
Toshihiro Shimizu |
890ddd |
DVAPI void tglDrawText(const TPointD &p, const wstring &s, void *font = GLUT_STROKE_ROMAN);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! Returns text width
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DVAPI double tglGetTextWidth(const string &s, 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 |
|
|
Toshihiro Shimizu |
890ddd |
inline void tglDrawSegment(const TPoint &p1, const TPoint &p2)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(convert(p1), convert(p2));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void tglDrawSegment(double x0, double y0, double x1, double y1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
tglDrawSegment(TPointD(x0, y0), TPointD(x1, y1));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//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 |
|
|
Toshihiro Shimizu |
890ddd |
inline void DVAPI tglDrawRect(const TRect &rect)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
tglDrawRect(convert(rect));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void DVAPI tglDrawRect(double x0, double y0, double x1, double y1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
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 |
|
|
Toshihiro Shimizu |
890ddd |
inline void DVAPI tglFillRect(const TRect &rect)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
tglFillRect(convert(rect));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void DVAPI tglFillRect(double x0, double y0, double x1, double y1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
tglFillRect(TRectD(x0, y0, x1, y1));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
inline void tglMultMatrix(const TAffine &aff)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
GLdouble m[] =
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
aff.a11, aff.a21, 0, 0,
|
|
Toshihiro Shimizu |
890ddd |
aff.a12, aff.a22, 0, 0,
|
|
Toshihiro Shimizu |
890ddd |
0, 0, 1, 0,
|
|
Toshihiro Shimizu |
890ddd |
aff.a13, aff.a23, 0, 1};
|
|
Toshihiro Shimizu |
890ddd |
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,
|
|
Toshihiro Shimizu |
890ddd |
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 |
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI tglGetColorMask(GLboolean &red, GLboolean &green, GLboolean &blue, GLboolean &alpha);
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI tglMultColorMask(GLboolean red, GLboolean green, GLboolean blue, 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,
|
|
Toshihiro Shimizu |
890ddd |
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 |
|
|
Toshihiro Shimizu |
890ddd |
enum GlDrawTextIndentation {
|
|
Toshihiro Shimizu |
890ddd |
Left = 0,
|
|
Toshihiro Shimizu |
890ddd |
Right = 1,
|
|
Toshihiro Shimizu |
890ddd |
Center = 2
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// precision is the number of segments to draw the curve
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI tglDraw(const TCubic &cubic, int precision, GLenum pointOrLine = GL_LINE);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI tglDraw(const TRectD &rect,
|
|
Toshihiro Shimizu |
890ddd |
const std::vector<traster32p> &textures,</traster32p>
|
|
Toshihiro Shimizu |
890ddd |
bool blending = true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI tglDraw(const TRectD &rect,
|
|
Toshihiro Shimizu |
890ddd |
const TRaster32P &tex,
|
|
Toshihiro Shimizu |
890ddd |
bool blending = true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DVAPI tglBuildMipmaps(std::vector<traster32p> &rasters,</traster32p>
|
|
Toshihiro Shimizu |
890ddd |
const TFilePath &filepath);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#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
|